Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
9e02d82d
Commit
9e02d82d
authored
Sep 25, 2017
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix symbol resolution for shared libraries with multiple load sections
parent
a0c5de1a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
18 deletions
+13
-18
src/cc/bcc_syms.cc
src/cc/bcc_syms.cc
+9
-15
src/cc/syms.h
src/cc/syms.h
+4
-3
No files found.
src/cc/bcc_syms.cc
View file @
9e02d82d
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
* limitations under the License.
* limitations under the License.
*/
*/
#include <algorithm>
#include <cxxabi.h>
#include <cxxabi.h>
#include <cstring>
#include <cstring>
#include <fcntl.h>
#include <fcntl.h>
...
@@ -114,7 +113,7 @@ ProcSyms::ProcSyms(int pid, struct bcc_symbol_option *option)
...
@@ -114,7 +113,7 @@ ProcSyms::ProcSyms(int pid, struct bcc_symbol_option *option)
int
ProcSyms
::
_add_load_sections
(
uint64_t
v_addr
,
uint64_t
mem_sz
,
int
ProcSyms
::
_add_load_sections
(
uint64_t
v_addr
,
uint64_t
mem_sz
,
uint64_t
file_offset
,
void
*
payload
)
{
uint64_t
file_offset
,
void
*
payload
)
{
auto
module
=
static_cast
<
Module
*>
(
payload
);
auto
module
=
static_cast
<
Module
*>
(
payload
);
module
->
add_range
(
v_addr
,
v_addr
+
mem_sz
);
module
->
ranges_
.
emplace_back
(
v_addr
,
v_addr
+
mem_sz
,
file_offset
);
return
0
;
return
0
;
}
}
...
@@ -162,7 +161,11 @@ int ProcSyms::_add_module(const char *modname, uint64_t start, uint64_t end,
...
@@ -162,7 +161,11 @@ int ProcSyms::_add_module(const char *modname, uint64_t start, uint64_t end,
else
else
return
0
;
return
0
;
}
}
it
->
add_range
(
start
,
end
);
it
->
ranges_
.
emplace_back
(
start
,
end
,
offset
);
// perf-PID map is added last. We try both inside the Process's mount
// namespace + chroot, and in global /tmp. Make sure we only add one.
if
(
it
->
type_
==
ModuleType
::
PERF_MAP
)
return
-
1
;
return
0
;
return
0
;
}
}
...
@@ -275,21 +278,12 @@ void ProcSyms::Module::load_sym_table() {
...
@@ -275,21 +278,12 @@ void ProcSyms::Module::load_sym_table() {
std
::
sort
(
syms_
.
begin
(),
syms_
.
end
());
std
::
sort
(
syms_
.
begin
(),
syms_
.
end
());
}
}
void
ProcSyms
::
Module
::
add_range
(
uint64_t
st
,
uint64_t
en
)
{
if
(
!
ranges_
.
empty
())
{
Range
&
last
=
ranges_
.
back
();
if
(
st
>=
last
.
start
&&
st
<=
last
.
end
)
{
last
.
end
=
std
::
max
(
en
,
last
.
end
);
return
;
}
}
ranges_
.
emplace_back
(
st
,
en
);
}
bool
ProcSyms
::
Module
::
contains
(
uint64_t
addr
,
uint64_t
&
offset
)
const
{
bool
ProcSyms
::
Module
::
contains
(
uint64_t
addr
,
uint64_t
&
offset
)
const
{
for
(
const
auto
&
range
:
ranges_
)
for
(
const
auto
&
range
:
ranges_
)
if
(
addr
>=
range
.
start
&&
addr
<
range
.
end
)
{
if
(
addr
>=
range
.
start
&&
addr
<
range
.
end
)
{
offset
=
type_
==
ModuleType
::
SO
?
addr
-
range
.
start
:
addr
;
offset
=
(
type_
==
ModuleType
::
SO
)
?
(
addr
-
range
.
start
+
range
.
file_offset
)
:
addr
;
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
...
src/cc/syms.h
View file @
9e02d82d
...
@@ -92,10 +92,12 @@ class ProcSyms : SymbolCache {
...
@@ -92,10 +92,12 @@ class ProcSyms : SymbolCache {
struct
Range
{
struct
Range
{
uint64_t
start
;
uint64_t
start
;
uint64_t
end
;
uint64_t
end
;
Range
(
uint64_t
s
,
uint64_t
e
)
:
start
(
s
),
end
(
e
)
{}
uint64_t
file_offset
;
Range
(
uint64_t
s
,
uint64_t
e
,
uint64_t
f
)
:
start
(
s
),
end
(
e
),
file_offset
(
f
)
{}
};
};
Module
(
const
char
*
name
,
ProcMountNS
*
mount_ns
,
Module
(
const
char
*
name
,
ProcMountNS
*
mount_ns
,
struct
bcc_symbol_option
*
option
);
struct
bcc_symbol_option
*
option
);
bool
init
();
bool
init
();
...
@@ -111,7 +113,6 @@ class ProcSyms : SymbolCache {
...
@@ -111,7 +113,6 @@ class ProcSyms : SymbolCache {
void
load_sym_table
();
void
load_sym_table
();
void
add_range
(
uint64_t
st
,
uint64_t
en
);
bool
contains
(
uint64_t
addr
,
uint64_t
&
offset
)
const
;
bool
contains
(
uint64_t
addr
,
uint64_t
&
offset
)
const
;
uint64_t
start
()
const
{
return
ranges_
.
begin
()
->
start
;
}
uint64_t
start
()
const
{
return
ranges_
.
begin
()
->
start
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment