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
f762df56
Commit
f762df56
authored
Apr 05, 2017
by
4ast
Committed by
GitHub
Apr 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1093 from palmtenor/symfree
Free demangle_name after use
parents
0e96bd8d
9f066e40
Changes
7
Show 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 @
f762df56
...
@@ -61,9 +61,11 @@ std::vector<std::string> BPFStackTable::get_stack_symbol(int stack_id,
...
@@ -61,9 +61,11 @@ std::vector<std::string> BPFStackTable::get_stack_symbol(int stack_id,
bcc_symbol
symbol
;
bcc_symbol
symbol
;
for
(
auto
addr
:
addresses
)
for
(
auto
addr
:
addresses
)
if
(
bcc_symcache_resolve
(
cache
,
addr
,
&
symbol
)
!=
0
)
if
(
bcc_symcache_resolve
(
cache
,
addr
,
&
symbol
)
!=
0
)
res
.
push
_back
(
"[UNKNOWN]"
);
res
.
emplace
_back
(
"[UNKNOWN]"
);
else
else
{
res
.
push_back
(
symbol
.
demangle_name
);
res
.
push_back
(
symbol
.
demangle_name
);
bcc_symbol_free_demangle_name
(
&
symbol
);
}
return
res
;
return
res
;
}
}
...
...
src/cc/bcc_syms.cc
View file @
f762df56
...
@@ -307,6 +307,11 @@ void bcc_free_symcache(void *symcache, int pid) {
...
@@ -307,6 +307,11 @@ void bcc_free_symcache(void *symcache, int pid) {
delete
static_cast
<
ProcSyms
*>
(
symcache
);
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
,
int
bcc_symcache_resolve
(
void
*
resolver
,
uint64_t
addr
,
struct
bcc_symbol
*
sym
)
{
struct
bcc_symbol
*
sym
)
{
SymbolCache
*
cache
=
static_cast
<
SymbolCache
*>
(
resolver
);
SymbolCache
*
cache
=
static_cast
<
SymbolCache
*>
(
resolver
);
...
...
src/cc/bcc_syms.h
View file @
f762df56
...
@@ -34,6 +34,10 @@ typedef int (*SYM_CB)(const char *symname, uint64_t addr);
...
@@ -34,6 +34,10 @@ typedef int (*SYM_CB)(const char *symname, uint64_t addr);
void
*
bcc_symcache_new
(
int
pid
);
void
*
bcc_symcache_new
(
int
pid
);
void
bcc_free_symcache
(
void
*
symcache
,
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
(
void
*
symcache
,
uint64_t
addr
,
struct
bcc_symbol
*
sym
);
int
bcc_symcache_resolve_no_demangle
(
void
*
symcache
,
uint64_t
addr
,
int
bcc_symcache_resolve_no_demangle
(
void
*
symcache
,
uint64_t
addr
,
struct
bcc_symbol
*
sym
);
struct
bcc_symbol
*
sym
);
...
...
src/lua/bcc/libbcc.lua
View file @
f762df56
...
@@ -118,6 +118,7 @@ int bcc_resolve_symname(const char *module, const char *symname, const uint64_t
...
@@ -118,6 +118,7 @@ int bcc_resolve_symname(const char *module, const char *symname, const uint64_t
int pid, struct bcc_symbol *sym);
int pid, struct bcc_symbol *sym);
void bcc_procutils_free(const char *ptr);
void bcc_procutils_free(const char *ptr);
void *bcc_symcache_new(int pid);
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);
int bcc_symcache_resolve(void *symcache, uint64_t addr, struct bcc_symbol *sym);
void bcc_symcache_refresh(void *resolver);
void bcc_symcache_refresh(void *resolver);
]]
]]
...
...
src/lua/bcc/sym.lua
View file @
f762df56
...
@@ -25,7 +25,9 @@ local function create_cache(pid)
...
@@ -25,7 +25,9 @@ local function create_cache(pid)
if
libbcc
.
bcc_symcache_resolve
(
self
.
_CACHE
,
addr
,
sym
)
<
0
then
if
libbcc
.
bcc_symcache_resolve
(
self
.
_CACHE
,
addr
,
sym
)
<
0
then
return
"[unknown]"
,
0x0
return
"[unknown]"
,
0x0
end
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
}
}
end
end
...
...
src/python/bcc/__init__.py
View file @
f762df56
...
@@ -69,9 +69,13 @@ class SymbolCache(object):
...
@@ -69,9 +69,13 @@ class SymbolCache(object):
return
(
None
,
sym
.
offset
,
return
(
None
,
sym
.
offset
,
ct
.
cast
(
sym
.
module
,
ct
.
c_char_p
).
value
.
decode
())
ct
.
cast
(
sym
.
module
,
ct
.
c_char_p
).
value
.
decode
())
return
(
None
,
addr
,
None
)
return
(
None
,
addr
,
None
)
return
(
if
demangle
:
sym
.
demangle_name
.
decode
()
if
demangle
else
sym
.
name
.
decode
(),
name_res
=
sym
.
demangle_name
.
decode
()
sym
.
offset
,
ct
.
cast
(
sym
.
module
,
ct
.
c_char_p
).
value
.
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
):
def
resolve_name
(
self
,
module
,
name
):
addr
=
ct
.
c_ulonglong
()
addr
=
ct
.
c_ulonglong
()
...
...
src/python/bcc/libbcc.py
View file @
f762df56
...
@@ -152,6 +152,9 @@ lib.bcc_symcache_new.argtypes = [ct.c_int]
...
@@ -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
.
restype
=
ct
.
c_void_p
lib
.
bcc_free_symcache
.
argtypes
=
[
ct
.
c_void_p
,
ct
.
c_int
]
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
.
restype
=
ct
.
c_int
lib
.
bcc_symcache_resolve
.
argtypes
=
[
ct
.
c_void_p
,
ct
.
c_ulonglong
,
ct
.
POINTER
(
bcc_symbol
)]
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