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
c924193f
Commit
c924193f
authored
Mar 03, 2017
by
4ast
Committed by
GitHub
Mar 03, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1022 from goldshtn/syms-multiple-regions
Symbol resolution with multiple executable regions per module
parents
b69fe977
f141d1b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
+32
-10
src/cc/bcc_syms.cc
src/cc/bcc_syms.cc
+21
-6
src/cc/syms.h
src/cc/syms.h
+10
-3
src/cc/usdt.cc
src/cc/usdt.cc
+1
-1
No files found.
src/cc/bcc_syms.cc
View file @
c924193f
...
...
@@ -101,7 +101,11 @@ void ProcSyms::refresh() {
int
ProcSyms
::
_add_module
(
const
char
*
modname
,
uint64_t
start
,
uint64_t
end
,
void
*
payload
)
{
ProcSyms
*
ps
=
static_cast
<
ProcSyms
*>
(
payload
);
ps
->
modules_
.
emplace_back
(
modname
,
start
,
end
);
auto
it
=
std
::
find_if
(
ps
->
modules_
.
begin
(),
ps
->
modules_
.
end
(),
[
=
](
const
ProcSyms
::
Module
&
m
)
{
return
m
.
name_
==
modname
;
});
if
(
it
==
ps
->
modules_
.
end
())
it
=
ps
->
modules_
.
insert
(
ps
->
modules_
.
end
(),
modname
);
it
->
ranges_
.
push_back
(
ProcSyms
::
Module
::
Range
(
start
,
end
));
return
0
;
}
...
...
@@ -116,7 +120,7 @@ bool ProcSyms::resolve_addr(uint64_t addr, struct bcc_symbol *sym) {
const
char
*
original_module
=
nullptr
;
for
(
Module
&
mod
:
modules_
)
{
if
(
addr
>=
mod
.
start_
&&
addr
<
mod
.
end_
)
{
if
(
mod
.
contains
(
addr
)
)
{
bool
res
=
mod
.
find_addr
(
addr
,
sym
);
if
(
sym
->
name
)
{
sym
->
demangle_name
=
abi
::
__cxa_demangle
(
sym
->
name
,
nullptr
,
nullptr
,
nullptr
);
...
...
@@ -155,8 +159,8 @@ bool ProcSyms::resolve_name(const char *module, const char *name,
return
false
;
}
ProcSyms
::
Module
::
Module
(
const
char
*
name
,
uint64_t
start
,
uint64_t
end
)
:
name_
(
name
)
,
start_
(
start
),
end_
(
end
)
{
ProcSyms
::
Module
::
Module
(
const
char
*
name
)
:
name_
(
name
)
{
is_so_
=
bcc_elf_is_shared_obj
(
name
)
==
1
;
}
...
...
@@ -184,12 +188,20 @@ void ProcSyms::Module::load_sym_table() {
std
::
sort
(
syms_
.
begin
(),
syms_
.
end
());
}
bool
ProcSyms
::
Module
::
contains
(
uint64_t
addr
)
const
{
for
(
const
auto
&
range
:
ranges_
)
{
if
(
addr
>=
range
.
start
&&
addr
<
range
.
end
)
return
true
;
}
return
false
;
}
bool
ProcSyms
::
Module
::
find_name
(
const
char
*
symname
,
uint64_t
*
addr
)
{
load_sym_table
();
for
(
Symbol
&
s
:
syms_
)
{
if
(
*
(
s
.
name
)
==
symname
)
{
*
addr
=
is_so
()
?
start
_
+
s
.
start
:
s
.
start
;
*
addr
=
is_so
()
?
start
()
+
s
.
start
:
s
.
start
;
return
true
;
}
}
...
...
@@ -197,7 +209,7 @@ bool ProcSyms::Module::find_name(const char *symname, uint64_t *addr) {
}
bool
ProcSyms
::
Module
::
find_addr
(
uint64_t
addr
,
struct
bcc_symbol
*
sym
)
{
uint64_t
offset
=
is_so
()
?
(
addr
-
start
_
)
:
addr
;
uint64_t
offset
=
is_so
()
?
(
addr
-
start
()
)
:
addr
;
load_sym_table
();
...
...
@@ -230,6 +242,9 @@ bool ProcSyms::Module::find_addr(uint64_t addr, struct bcc_symbol *sym) {
sym
->
offset
=
(
offset
-
it
->
start
);
return
true
;
}
// But don't step beyond begin()!
if
(
it
==
syms_
.
begin
())
break
;
}
return
false
;
...
...
src/cc/syms.h
View file @
c924193f
...
...
@@ -79,15 +79,22 @@ class ProcSyms : SymbolCache {
};
struct
Module
{
Module
(
const
char
*
name
,
uint64_t
start
,
uint64_t
end
);
struct
Range
{
uint64_t
start
;
uint64_t
end
;
Range
(
uint64_t
s
,
uint64_t
e
)
:
start
(
s
),
end
(
e
)
{}
};
Module
(
const
char
*
name
);
std
::
string
name_
;
uint64_t
start_
;
uint64_t
end_
;
std
::
vector
<
Range
>
ranges_
;
bool
is_so_
;
std
::
unordered_set
<
std
::
string
>
symnames_
;
std
::
vector
<
Symbol
>
syms_
;
void
load_sym_table
();
bool
contains
(
uint64_t
addr
)
const
;
uint64_t
start
()
const
{
return
ranges_
.
begin
()
->
start
;
}
bool
find_addr
(
uint64_t
addr
,
struct
bcc_symbol
*
sym
);
bool
find_name
(
const
char
*
symname
,
uint64_t
*
addr
);
bool
is_so
()
const
{
return
is_so_
;
}
...
...
src/cc/usdt.cc
View file @
c924193f
...
...
@@ -63,7 +63,7 @@ bool Probe::resolve_global_address(uint64_t *global, const uint64_t addr) {
}
bool
Probe
::
add_to_semaphore
(
int16_t
val
)
{
assert
(
pid_
&&
attached_semaphore_
);
assert
(
pid_
);
if
(
!
attached_semaphore_
)
{
uint64_t
addr
;
...
...
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