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
cb06c97f
Commit
cb06c97f
authored
Mar 01, 2017
by
4ast
Committed by
GitHub
Mar 01, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1002 from goldshtn/nested-symbols
cc: Handle nested functions correctly when resolving symbols
parents
4d0d4308
01bb02c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
src/cc/bcc_syms.cc
src/cc/bcc_syms.cc
+24
-9
No files found.
src/cc/bcc_syms.cc
View file @
cb06c97f
...
...
@@ -190,16 +190,31 @@ bool ProcSyms::Module::find_addr(uint64_t addr, struct bcc_symbol *sym) {
sym
->
offset
=
offset
;
auto
it
=
std
::
upper_bound
(
syms_
.
begin
(),
syms_
.
end
(),
Symbol
(
nullptr
,
offset
,
0
));
if
(
it
!=
syms_
.
begin
())
--
it
;
else
it
=
syms_
.
end
();
if
(
it
==
syms_
.
begin
())
return
false
;
if
(
it
!=
syms_
.
end
()
&&
offset
>=
it
->
start
&&
offset
<
it
->
start
+
it
->
size
)
{
sym
->
name
=
it
->
name
->
c_str
();
sym
->
offset
=
(
offset
-
it
->
start
);
return
true
;
// 'it' points to the symbol whose start address is strictly greater than
// the address we're looking for. Start stepping backwards as long as the
// current symbol is still below the desired address, and see if the end
// of the current symbol (start + size) is above the desired address. Once
// we have a matching symbol, return it. Note that simply looking at '--it'
// is not enough, because symbols can be nested. For example, we could be
// looking for offset 0x12 with the following symbols available:
// SYMBOL START SIZE END
// goo 0x0 0x6 0x0 + 0x6 = 0x6
// foo 0x6 0x10 0x6 + 0x10 = 0x16
// bar 0x8 0x4 0x8 + 0x4 = 0xc
// baz 0x16 0x10 0x16 + 0x10 = 0x26
// The upper_bound lookup will return baz, and then going one symbol back
// brings us to bar, which does not contain offset 0x12 and is nested inside
// foo. Going back one more symbol brings us to foo, which contains 0x12
// and is a match.
for
(
--
it
;
offset
>=
it
->
start
;
--
it
)
{
if
(
offset
<
it
->
start
+
it
->
size
)
{
sym
->
name
=
it
->
name
->
c_str
();
sym
->
offset
=
(
offset
-
it
->
start
);
return
true
;
}
}
return
false
;
...
...
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