Skip to content

Commit

Permalink
Expose destruction of SymbolCache in libbcc
Browse files Browse the repository at this point in the history
  • Loading branch information
palmtenor committed Oct 31, 2016
1 parent 7671594 commit 81eae65
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cc/bcc_syms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ void *bcc_symcache_new(int pid) {
return static_cast<void *>(new ProcSyms(pid));
}

void bcc_free_symcache(void *symcache, int pid) {
if (pid < 0)
delete static_cast<KSyms*>(symcache);
else
delete static_cast<ProcSyms*>(symcache);
}

int bcc_symcache_resolve(void *resolver, uint64_t addr,
struct bcc_symbol *sym) {
SymbolCache *cache = static_cast<SymbolCache *>(resolver);
Expand Down Expand Up @@ -286,7 +293,7 @@ static int _list_sym(const char *symname, uint64_t addr, uint64_t end,
return 0;

SYM_CB cb = (SYM_CB) payload;
return cb(symname, addr);
return cb(symname, addr);
}

int bcc_foreach_symbol(const char *module, SYM_CB cb) {
Expand Down
2 changes: 2 additions & 0 deletions src/cc/bcc_syms.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct bcc_symbol {
typedef int(* SYM_CB)(const char *symname, uint64_t addr);

void *bcc_symcache_new(int pid);
void bcc_free_symcache(void *symcache, int pid);

int bcc_symcache_resolve(void *symcache, uint64_t addr, struct bcc_symbol *sym);
int bcc_symcache_resolve_name(void *resolver, const char *name, uint64_t *addr);
void bcc_symcache_refresh(void *resolver);
Expand Down
3 changes: 3 additions & 0 deletions src/python/bcc/libbcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ class bcc_symbol(ct.Structure):
lib.bcc_symcache_new.restype = ct.c_void_p
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_symcache_resolve.restype = ct.c_int
lib.bcc_symcache_resolve.argtypes = [ct.c_void_p, ct.c_ulonglong, ct.POINTER(bcc_symbol)]

Expand Down

0 comments on commit 81eae65

Please sign in to comment.