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
966edb21
Commit
966edb21
authored
Jul 08, 2016
by
Mark Drayton
Committed by
4ast
Jul 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ProcSyms: deduplicate symbol names (#598)
parent
52561540
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
src/cc/bcc_syms.cc
src/cc/bcc_syms.cc
+5
-4
src/cc/syms.h
src/cc/syms.h
+4
-2
No files found.
src/cc/bcc_syms.cc
View file @
966edb21
...
...
@@ -132,7 +132,8 @@ bool ProcSyms::resolve_name(const char *module, const char *name,
int
ProcSyms
::
Module
::
_add_symbol
(
const
char
*
symname
,
uint64_t
start
,
uint64_t
end
,
int
flags
,
void
*
p
)
{
Module
*
m
=
static_cast
<
Module
*>
(
p
);
m
->
syms_
.
emplace_back
(
symname
,
start
,
end
,
flags
);
auto
res
=
m
->
symnames_
.
emplace
(
symname
);
m
->
syms_
.
emplace_back
(
&*
(
res
.
first
),
start
,
end
,
flags
);
return
0
;
}
...
...
@@ -160,7 +161,7 @@ bool ProcSyms::Module::find_name(const char *symname, uint64_t *addr) {
load_sym_table
();
for
(
Symbol
&
s
:
syms_
)
{
if
(
s
.
name
==
symname
)
{
if
(
*
(
s
.
name
)
==
symname
)
{
*
addr
=
is_so
()
?
start_
+
s
.
start
:
s
.
start
;
return
true
;
}
...
...
@@ -176,7 +177,7 @@ bool ProcSyms::Module::find_addr(uint64_t addr, struct bcc_symbol *sym) {
sym
->
module
=
name_
.
c_str
();
sym
->
offset
=
offset
;
auto
it
=
std
::
upper_bound
(
syms_
.
begin
(),
syms_
.
end
(),
Symbol
(
""
,
offset
,
0
));
auto
it
=
std
::
upper_bound
(
syms_
.
begin
(),
syms_
.
end
(),
Symbol
(
nullptr
,
offset
,
0
));
if
(
it
!=
syms_
.
begin
())
--
it
;
else
...
...
@@ -184,7 +185,7 @@ bool ProcSyms::Module::find_addr(uint64_t addr, struct bcc_symbol *sym) {
if
(
it
!=
syms_
.
end
()
&&
offset
>=
it
->
start
&&
offset
<
it
->
start
+
it
->
size
)
{
sym
->
name
=
it
->
name
.
c_str
();
sym
->
name
=
it
->
name
->
c_str
();
sym
->
offset
=
(
offset
-
it
->
start
);
return
true
;
}
...
...
src/cc/syms.h
View file @
966edb21
...
...
@@ -18,6 +18,7 @@
#include <algorithm>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <sys/types.h>
...
...
@@ -63,9 +64,9 @@ public:
class
ProcSyms
:
SymbolCache
{
struct
Symbol
{
Symbol
(
const
char
*
name
,
uint64_t
start
,
uint64_t
size
,
int
flags
=
0
)
Symbol
(
const
std
::
string
*
name
,
uint64_t
start
,
uint64_t
size
,
int
flags
=
0
)
:
name
(
name
),
start
(
start
),
size
(
size
),
flags
(
flags
)
{}
std
::
string
name
;
const
std
::
string
*
name
;
uint64_t
start
;
uint64_t
size
;
int
flags
;
...
...
@@ -81,6 +82,7 @@ class ProcSyms : SymbolCache {
std
::
string
name_
;
uint64_t
start_
;
uint64_t
end_
;
std
::
unordered_set
<
std
::
string
>
symnames_
;
std
::
vector
<
Symbol
>
syms_
;
void
load_sym_table
();
...
...
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