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
9f066e40
Commit
9f066e40
authored
Apr 04, 2017
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Free demangle_name after use
parent
304b75d2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
6 deletions
+27
-6
src/cc/BPFTable.cc
src/cc/BPFTable.cc
+4
-2
src/cc/bcc_syms.cc
src/cc/bcc_syms.cc
+5
-0
src/cc/bcc_syms.h
src/cc/bcc_syms.h
+4
-0
src/lua/bcc/libbcc.lua
src/lua/bcc/libbcc.lua
+1
-0
src/lua/bcc/sym.lua
src/lua/bcc/sym.lua
+3
-1
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+7
-3
src/python/bcc/libbcc.py
src/python/bcc/libbcc.py
+3
-0
No files found.
src/cc/BPFTable.cc
View file @
9f066e40
...
...
@@ -61,9 +61,11 @@ std::vector<std::string> BPFStackTable::get_stack_symbol(int stack_id,
bcc_symbol
symbol
;
for
(
auto
addr
:
addresses
)
if
(
bcc_symcache_resolve
(
cache
,
addr
,
&
symbol
)
!=
0
)
res
.
push
_back
(
"[UNKNOWN]"
);
else
res
.
emplace
_back
(
"[UNKNOWN]"
);
else
{
res
.
push_back
(
symbol
.
demangle_name
);
bcc_symbol_free_demangle_name
(
&
symbol
);
}
return
res
;
}
...
...
src/cc/bcc_syms.cc
View file @
9f066e40
...
...
@@ -307,6 +307,11 @@ void bcc_free_symcache(void *symcache, int pid) {
delete
static_cast
<
ProcSyms
*>
(
symcache
);
}
void
bcc_symbol_free_demangle_name
(
struct
bcc_symbol
*
sym
)
{
if
(
sym
->
demangle_name
&&
(
sym
->
demangle_name
!=
sym
->
name
))
free
(
const_cast
<
char
*>
(
sym
->
demangle_name
));
}
int
bcc_symcache_resolve
(
void
*
resolver
,
uint64_t
addr
,
struct
bcc_symbol
*
sym
)
{
SymbolCache
*
cache
=
static_cast
<
SymbolCache
*>
(
resolver
);
...
...
src/cc/bcc_syms.h
View file @
9f066e40
...
...
@@ -34,6 +34,10 @@ typedef int (*SYM_CB)(const char *symname, uint64_t addr);
void
*
bcc_symcache_new
(
int
pid
);
void
bcc_free_symcache
(
void
*
symcache
,
int
pid
);
// The demangle_name pointer in bcc_symbol struct is returned from the
// __cxa_demangle function call, which is supposed to be freed by caller. Call
// this function after done using returned result of bcc_symcache_resolve.
void
bcc_symbol_free_demangle_name
(
struct
bcc_symbol
*
sym
);
int
bcc_symcache_resolve
(
void
*
symcache
,
uint64_t
addr
,
struct
bcc_symbol
*
sym
);
int
bcc_symcache_resolve_no_demangle
(
void
*
symcache
,
uint64_t
addr
,
struct
bcc_symbol
*
sym
);
...
...
src/lua/bcc/libbcc.lua
View file @
9f066e40
...
...
@@ -118,6 +118,7 @@ int bcc_resolve_symname(const char *module, const char *symname, const uint64_t
int pid, struct bcc_symbol *sym);
void bcc_procutils_free(const char *ptr);
void *bcc_symcache_new(int pid);
void bcc_symbol_free_demangle_name(struct bcc_symbol *sym);
int bcc_symcache_resolve(void *symcache, uint64_t addr, struct bcc_symbol *sym);
void bcc_symcache_refresh(void *resolver);
]]
...
...
src/lua/bcc/sym.lua
View file @
9f066e40
...
...
@@ -25,7 +25,9 @@ local function create_cache(pid)
if
libbcc
.
bcc_symcache_resolve
(
self
.
_CACHE
,
addr
,
sym
)
<
0
then
return
"[unknown]"
,
0x0
end
return
ffi
.
string
(
sym
[
0
].
demangle_name
),
sym
[
0
].
offset
local
name_res
=
ffi
.
string
(
sym
[
0
].
demangle_name
)
libbcc
.
bcc_symbol_free_demangle_name
(
sym
);
return
name_res
,
sym
[
0
].
offset
end
}
end
...
...
src/python/bcc/__init__.py
View file @
9f066e40
...
...
@@ -69,9 +69,13 @@ class SymbolCache(object):
return
(
None
,
sym
.
offset
,
ct
.
cast
(
sym
.
module
,
ct
.
c_char_p
).
value
.
decode
())
return
(
None
,
addr
,
None
)
return
(
sym
.
demangle_name
.
decode
()
if
demangle
else
sym
.
name
.
decode
(),
sym
.
offset
,
ct
.
cast
(
sym
.
module
,
ct
.
c_char_p
).
value
.
decode
())
if
demangle
:
name_res
=
sym
.
demangle_name
.
decode
()
lib
.
bcc_symbol_free_demangle_name
(
psym
)
else
:
name_res
=
sym
.
name
.
decode
()
return
(
name_res
,
sym
.
offset
,
ct
.
cast
(
sym
.
module
,
ct
.
c_char_p
).
value
.
decode
())
def
resolve_name
(
self
,
module
,
name
):
addr
=
ct
.
c_ulonglong
()
...
...
src/python/bcc/libbcc.py
View file @
9f066e40
...
...
@@ -152,6 +152,9 @@ lib.bcc_symcache_new.argtypes = [ct.c_int]
lib
.
bcc_free_symcache
.
restype
=
ct
.
c_void_p
lib
.
bcc_free_symcache
.
argtypes
=
[
ct
.
c_void_p
,
ct
.
c_int
]
lib
.
bcc_symbol_free_demangle_name
.
restype
=
ct
.
c_void_p
lib
.
bcc_symbol_free_demangle_name
.
argtypes
=
[
ct
.
POINTER
(
bcc_symbol
)]
lib
.
bcc_symcache_resolve
.
restype
=
ct
.
c_int
lib
.
bcc_symcache_resolve
.
argtypes
=
[
ct
.
c_void_p
,
ct
.
c_ulonglong
,
ct
.
POINTER
(
bcc_symbol
)]
...
...
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