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:
Arnaldo Carvalho de Melo 2009-03-31 15:15:08 -03:00
parent e97d952744
commit 879f483daf
2 changed files with 11 additions and 4 deletions

View File

@ -253,6 +253,8 @@ int cu__encode_ctf(struct cu *self)
hlist_add_head(&function->tool_hnode, head);
}
cu__cache_symtab(self);
GElf_Sym sym;
const char *sym_name;
cu__for_each_cached_symtab_entry(self, id, sym, sym_name) {

View File

@ -124,10 +124,11 @@ struct cu {
struct ptr_table tags_table;
char *name;
char *filename;
Elf *elf;
Dwfl_Module *dwfl;
void *priv;
struct cu_orig_info *orig_info;
Elf *elf;
Dwfl_Module *dwfl;
uint32_t cached_symtab_nr_entries;
uint8_t addr_size;
uint8_t extra_dbg_info:1;
uint16_t language;
@ -147,6 +148,11 @@ struct cu *cu__new(const char *name, uint8_t addr_size,
const char *filename);
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: struct cu instance
@ -155,10 +161,9 @@ void cu__delete(struct cu *self);
* @name: char pointer where the symbol_name will be stored
*/
#define cu__for_each_cached_symtab_entry(cu, id, pos, name) \
uint32_t n = dwfl_module_getsymtab(cu->dwfl); \
for (id = 1, \
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))
/**