core: Introduce cu__cache_symtab
We need it to be able to call cu__for_each_cached_symtab_entry more than once in the same function. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
e97d952744
commit
879f483daf
|
@ -253,6 +253,8 @@ int cu__encode_ctf(struct cu *self)
|
||||||
hlist_add_head(&function->tool_hnode, head);
|
hlist_add_head(&function->tool_hnode, head);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cu__cache_symtab(self);
|
||||||
|
|
||||||
GElf_Sym sym;
|
GElf_Sym sym;
|
||||||
const char *sym_name;
|
const char *sym_name;
|
||||||
cu__for_each_cached_symtab_entry(self, id, sym, sym_name) {
|
cu__for_each_cached_symtab_entry(self, id, sym, sym_name) {
|
||||||
|
|
13
dwarves.h
13
dwarves.h
|
@ -124,10 +124,11 @@ struct cu {
|
||||||
struct ptr_table tags_table;
|
struct ptr_table tags_table;
|
||||||
char *name;
|
char *name;
|
||||||
char *filename;
|
char *filename;
|
||||||
Elf *elf;
|
|
||||||
Dwfl_Module *dwfl;
|
|
||||||
void *priv;
|
void *priv;
|
||||||
struct cu_orig_info *orig_info;
|
struct cu_orig_info *orig_info;
|
||||||
|
Elf *elf;
|
||||||
|
Dwfl_Module *dwfl;
|
||||||
|
uint32_t cached_symtab_nr_entries;
|
||||||
uint8_t addr_size;
|
uint8_t addr_size;
|
||||||
uint8_t extra_dbg_info:1;
|
uint8_t extra_dbg_info:1;
|
||||||
uint16_t language;
|
uint16_t language;
|
||||||
|
@ -147,6 +148,11 @@ struct cu *cu__new(const char *name, uint8_t addr_size,
|
||||||
const char *filename);
|
const char *filename);
|
||||||
void cu__delete(struct cu *self);
|
void cu__delete(struct cu *self);
|
||||||
|
|
||||||
|
static inline void cu__cache_symtab(struct cu *self)
|
||||||
|
{
|
||||||
|
self->cached_symtab_nr_entries = dwfl_module_getsymtab(self->dwfl);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cu__for_each_cached_symtab_entry - iterate thru the cached symtab entries
|
* cu__for_each_cached_symtab_entry - iterate thru the cached symtab entries
|
||||||
* @cu: struct cu instance
|
* @cu: struct cu instance
|
||||||
|
@ -155,10 +161,9 @@ void cu__delete(struct cu *self);
|
||||||
* @name: char pointer where the symbol_name will be stored
|
* @name: char pointer where the symbol_name will be stored
|
||||||
*/
|
*/
|
||||||
#define cu__for_each_cached_symtab_entry(cu, id, pos, name) \
|
#define cu__for_each_cached_symtab_entry(cu, id, pos, name) \
|
||||||
uint32_t n = dwfl_module_getsymtab(cu->dwfl); \
|
|
||||||
for (id = 1, \
|
for (id = 1, \
|
||||||
name = dwfl_module_getsym(cu->dwfl, id, &sym, NULL); \
|
name = dwfl_module_getsym(cu->dwfl, id, &sym, NULL); \
|
||||||
id < n; \
|
id < cu->cached_symtab_nr_entries; \
|
||||||
++id, name = dwfl_module_getsym(cu->dwfl, id, &sym, NULL))
|
++id, name = dwfl_module_getsym(cu->dwfl, id, &sym, NULL))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue