From 6457b396aa60d09efe2df6a658a4761073ac150a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 30 Mar 2009 22:45:55 -0300 Subject: [PATCH] core: Allow reusing the symtab already loaded and relocated Via cu__for_each_cached_symtab_entry. Signed-off-by: Arnaldo Carvalho de Melo --- dwarf_loader.c | 1 + dwarves.h | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dwarf_loader.c b/dwarf_loader.c index 03a9653..91cc8ea 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -1842,6 +1842,7 @@ static int cus__load_module(struct cus *self, struct conf_load *conf, if (cu == NULL) return DWARF_CB_ABORT; cu->elf = elf; + cu->dwfl = mod; cu->extra_dbg_info = conf ? conf->extra_dbg_info : 0; if (die__process(cu_die, cu) != 0) return DWARF_CB_ABORT; diff --git a/dwarves.h b/dwarves.h index 40777d0..e915202 100644 --- a/dwarves.h +++ b/dwarves.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include "dutil.h" #include "list.h" @@ -124,7 +124,8 @@ struct cu { struct ptr_table tags_table; char *name; char *filename; - void *elf; + Elf *elf; + Dwfl_Module *dwfl; void *priv; struct cu_orig_info *orig_info; uint8_t addr_size; @@ -146,11 +147,25 @@ struct cu *cu__new(const char *name, uint8_t addr_size, const char *filename); void cu__delete(struct cu *self); +/** + * cu__for_each_cached_symtab_entry - iterate thru the cached symtab entries + * @cu: struct cu instance + * @id: uint32_t tag id + * @pos: struct GElf_Sym iterator + * @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, name = dwfl_module_getsym(cu->dwfl, id, &sym, NULL)) + /** * cu__for_each_type - iterate thru all the type tags * @cu: struct cu instance to iterate - * @pos: struct tag iterator * @id: uint16_t tag id + * @pos: struct tag iterator * * See cu__table_nullify_type_entry and users for the reason for * the NULL test (hint: CTF Unknown types)