21 #include <sys/types.h>
44 #include <elfutils/libebl.h>
45 #include <elfutils/libdw.h>
46 #include <elfutils/libdwfl.h>
83 char *buf,
unsigned int len,Dwarf *dbg);
87 unsigned int attr,Dwarf_Word offset);
93 static inline char *dwarf_language_string(
int language);
113 reflist = (GSList *)g_hash_table_lookup(srd->
refuselist,
114 (gpointer)(uintptr_t)ref);
115 reflist = g_slist_prepend(reflist,(gpointer)symbol);
117 g_hash_table_insert(srd->
refuselist,(gpointer)(uintptr_t)ref,reflist);
127 reflist = (GSList *)g_hash_table_lookup(srd->
refuselist,
128 (gpointer)(uintptr_t)ref);
130 reflist = g_slist_remove(reflist,(gpointer)symbol);
132 g_hash_table_insert(srd->
refuselist,(gpointer)(uintptr_t)ref,reflist);
139 return (GSList *)g_hash_table_lookup(srd->
refuselist,
140 (gpointer)(uintptr_t)ref);
152 if (sii && sii->origin_ref) {
168 SMOFFSET ref,
struct symbol *refsym) {
203 RHOLD(refsym,symbol);
210 if (sii && sii->origin_ref == ref) {
223 sii->origin = refsym;
274 uselist = (GSList *) \
275 g_hash_table_lookup(srd->
refuselist,(gpointer)(uintptr_t)ref);
299 symbol->
datatype = (
struct symbol *) \
300 g_hash_table_lookup(srd->
reftab,(gpointer)(uintptr_t)ref);
319 sii->origin_ref =
ref;
320 sii->origin = (
struct symbol *) \
321 g_hash_table_lookup(srd->
reftab,(gpointer)(uintptr_t)ref);
348 struct symbol *existing;
351 existing = (
struct symbol *) \
352 g_hash_table_lookup(srd->
reftab,(gpointer)(uintptr_t)ref);
355 if (existing == symbol)
361 g_hash_table_insert(srd->
reftab,(gpointer)(uintptr_t)ref,symbol);
382 g_hash_table_iter_replace(iter,
new);
390 static void dwarf_reftab_clean(
struct symbol *
root,
int force) {
409 g_hash_table_iter_init(&iter,srd->
reftab);
410 while (g_hash_table_iter_next(&iter,NULL,(gpointer *)&tsymbol)) {
417 && g_hash_table_lookup_extended(srd->
refuselist,
418 (gpointer)(uintptr_t)tsymbol->
ref,
423 g_hash_table_iter_remove(&iter);
427 static void dwarf_refuselist_clean(
struct symbol *root,
int force) {
453 g_hash_table_iter_init(&iter,srd->
refuselist);
454 while (g_hash_table_iter_next(&iter,&key,&value)) {
458 tsymbol = (
struct symbol *) \
459 g_hash_table_lookup(srd->
reftab,(gpointer)(uintptr_t)key);
463 if (force || !tsymbol) {
467 g_slist_free((GSList *)value);
468 g_hash_table_iter_remove(&iter);
542 static int dwarf_specify_definition(
struct symbol *spec,
struct symbol *def) {
618 if (sfr->fbloc && !sfw->fbloc)
620 if (sfr->has_entry_pc && !sfw->has_entry_pc) {
621 sfw->has_entry_pc = 1;
622 sfw->entry_pc = sfr->entry_pc;
624 if ((sfr->prologue_known || sfr->prologue_guessed)
625 && !sfw->prologue_known && !sfw->prologue_guessed) {
626 sfw->prologue_known = 1;
627 sfw->prologue_end = sfr->prologue_end;
629 if (sfr->epilogue_known && !sfw->epilogue_known) {
630 sfw->epilogue_known = 1;
631 sfw->epilogue_begin = sfr->epilogue_begin;
638 if (svr->loc && !svw->loc)
661 struct symbol *specification,
662 struct symbol *definition) {
665 rc = dwarf_specify_definition(specification,definition);
668 "used specification ");
671 " to complete definition ");
678 struct symbol *specification,
679 struct symbol *definition) {
682 GSList *nmlist = NULL;
683 GSList *tomove = NULL;
712 tomove = g_slist_append(tomove,m);
734 tomove = g_slist_append(tomove,m);
741 g_slist_free(nmlist);
749 g_slist_free(tomove);
752 "used specification ");
755 " to complete definition (moved %d; updated %d) ",moved,updated);
761 static int attr_callback(Dwarf_Attribute *attrp,
void *arg) {
769 Dwarf_Half version = srd->
version;
770 uint8_t offsize = srd->
offsize;
773 verror(
"cannot get attribute: %s",dwarf_errmsg (-1));
774 return DWARF_CB_ABORT;
777 unsigned int attr = attrp->code;
778 unsigned int form = attrp->form;
781 verror(
"attr code was 0, aborting!\n");
785 verror(
"form code was 0, aborting!\n");
800 uint8_t str_copy = 0;
802 uint8_t addr_set = 0;
803 uint8_t flag_set = 0;
805 uint8_t block_set = 0;
806 uint8_t sec_offset_set = 0;
811 verror(" <%d><%"PRIx64"> %s: %s\n", \
812 level,die_offset,dwarf_attr_string(attr),msg);
817 str = (
char *)attrp->valp;
822 case DW_FORM_indirect:
828 " <%d><%"PRIx64
"> %s: dwarf str at 0x%lx not in dbg_strtab;"
831 (
unsigned long int)*(attrp->valp));
836 str = &debugfile->
dbg_strtab[*((uint32_t *)attrp->valp)];
838 str = &debugfile->
dbg_strtab[*((uint64_t *)attrp->valp)];
839 #ifdef DWDEBUG_NOUSE_STRTAB
847 if (
unlikely(dwarf_formaddr(attrp,&addr) != 0)) {
848 DFE(
"could not get dwarf addr!");
853 case DW_FORM_ref_addr:
855 " <%d><%"PRIx64
"> %s: cross-CU ref %"PRIxADDR"\n",
857 case DW_FORM_ref_udata:
862 if (
unlikely(dwarf_formref_die(attrp,&rref) == NULL)) {
863 DFE(
"could not get dwarf die ref!");
866 ref = dwarf_dieoffset(&rref);
869 #if _INT_ELFUTILS_VERSION > 141
870 case DW_FORM_sec_offset:
874 #if _INT_ELFUTILS_VERSION < 153
876 offsize == 8 ? DW_FORM_data8 : DW_FORM_data4;
887 if (
unlikely(dwarf_formudata(attrp,&num) != 0)) {
888 DFE(
"could not load dwarf num!");
893 #if _INT_ELFUTILS_VERSION > 141
894 case DW_FORM_exprloc:
900 if (
unlikely(dwarf_formblock(attrp,&block) != 0)) {
901 DFE(
"could not load dwarf block!");
907 #if _INT_ELFUTILS_VERSION > 141
908 case DW_FORM_flag_present:
910 if (
unlikely(dwarf_formflag(attrp,&flag) != 0)) {
911 DFE(
"could not load dwarf flag!");
918 " <%d><"PRIx64
"> %s: unrecognized form %s (0x%x)!\n",
928 " <%d><%x> %s = '%s'\n",
932 " <%d><%x> %s = 0x%"PRIxADDR
"\n",
936 " <%d><%x> %s = %d\n",
940 " <%d><%x> %s = 0x%"PRIxADDR
"\n",
948 " <%d><%x> %s = %d\n",
956 #define DAW_STR(msg) \
957 { vwarnopt(6,LA_DEBUG,LF_DWARFATTR, \
958 " <%d><%"PRIx64"> %s (%s): %s\n", \
959 level,die_offset,dwarf_attr_string(attr),str,msg); }
960 #define DAW_ADDR(msg) \
961 { vwarnopt(6,LA_DEBUG,LF_DWARFATTR, \
962 " <%d><%"PRIx64"> %s (0x%"PRIxADDR"): %s\n", \
963 level,die_offset,dwarf_attr_string(attr),addr,msg); }
964 #define DAW_NUM(msg) \
965 { vwarnopt(6,LA_DEBUG,LF_DWARFATTR, \
966 " <%d><%"PRIx64"> %s (%d): %s\n", \
967 level,die_offset,dwarf_attr_string(attr),num,msg); }
968 #define DAW_BLOCK(msg) \
969 { vwarnopt(6,LA_DEBUG,LF_DWARFATTR, \
970 " <%d><%"PRIx64"> %s (0x%"PRIxADDR"): %s\n", \
971 level,die_offset,dwarf_attr_string(attr),block,msg); }
972 #define DAW_REF(msg) \
973 { vwarnopt(6,LA_DEBUG,LF_DWARFATTR, \
974 " <%d><%"PRIx64"> %s (0x%"PRIxSMOFFSET"): %s\n", \
975 level,die_offset,dwarf_attr_string(attr),ref,msg); }
976 #define DAW_FLAG(msg) \
977 { vwarnopt(6,LA_DEBUG,LF_DWARFATTR, \
978 " <%d><%"PRIx64"> %s (%d): %s\n", \
979 level,die_offset,dwarf_attr_string(attr),flag,msg); }
981 { vwarnopt(6,LA_DEBUG,LF_DWARFATTR, \
982 " <%d><%"PRIx64"> %s: %s\n", \
983 level,die_offset,dwarf_attr_string(attr),msg); }
985 { vwarnopt(16,LA_DEBUG,LF_DWARFATTR, \
986 " <%d><%"PRIx64"> %s: %s\n", \
987 level,die_offset,dwarf_attr_string(attr),msg); }
1002 case DW_AT_stmt_list:
1011 case DW_AT_producer:
1017 case DW_AT_comp_dir:
1023 case DW_AT_language:
1041 else if (addr_set) {
1050 case DW_AT_entry_pc:
1060 case DW_AT_decl_file:
1067 case DW_AT_decl_line:
1074 case DW_AT_decl_column:
1075 case DW_AT_call_file:
1076 case DW_AT_call_line:
1077 case DW_AT_call_column:
1079 case DW_AT_encoding:
1087 case DW_AT_declaration:
1093 case DW_AT_external:
1113 case DW_AT_linkage_name:
1114 case DW_AT_MIPS_linkage_name:
1128 case DW_AT_prototyped:
1150 case DW_AT_abstract_origin:
1153 DAW_REF(
"failed to set inline origin");
1167 if (ref_set && symbol) {
1175 DAW_REF(
"bogus: type ref for unknown type symbol");
1192 case DW_AT_const_value:
1197 else if (num_set && symbol->
datatype
1227 case DW_AT_byte_size:
1237 case DW_AT_bit_size:
1247 case DW_AT_bit_offset:
1261 DAW(
"bad form; expected ref");
1263 case DW_AT_data_member_location:
1306 DAW_BLOCK(
"failed symbol_set_location");
1314 if ((version == 3 && (form == DW_FORM_data4
1315 || form == DW_FORM_data8))
1316 || (version >= 4 && sec_offset_set)) {
1318 loc = dwarf_get_loclistloc(srd,attr,num);
1320 DAW_NUM(
"failed get_loclistloc");
1332 DAW_NUM(
"failed symbol_set_location");
1339 case DW_AT_frame_base:
1347 if (num_set && (form == DW_FORM_data4 || form == DW_FORM_data8)) {
1348 loc = dwarf_get_loclistloc(srd,attr,num);
1350 DAW_NUM(
"failed get_loclistloc");
1357 else if (block_set) {
1367 DAW(
"frame_base not num/block");
1371 if (num_set && (sec_offset_set
1372 || form == DW_FORM_data4
1373 || form == DW_FORM_data8)) {
1374 cbargs->
ranges = dwarf_get_ranges(srd,attr,num);
1376 DAW_NUM(
"failed to get_ranges");
1383 case DW_AT_location:
1390 if (num_set && (sec_offset_set
1391 || form == DW_FORM_data4
1392 || form == DW_FORM_data8)) {
1393 loc = dwarf_get_loclistloc(srd,attr,num);
1395 DAW_NUM(
"failed to get_loclistloc");
1399 DAW_NUM(
"failed to set_location!");
1404 else if (block_set) {
1407 DAW(
"failed to get_static_ops");
1411 DAW_NUM(
"failed to set_location!");
1419 case DW_AT_lower_bound:
1420 if (num_set && num) {
1421 DAW_NUM(
"we only support lower_bound attrs of 0");
1424 DAW(
"bad attr/form");
1428 case DW_AT_upper_bound:
1430 if (num_set && !sec_offset_set) {
1436 DAW_NUM(
"non array-type parent or bad context");
1440 DAW(
"bad attr/form");
1442 case DW_AT_specification:
1443 if (ref_set && symbol) {
1448 DAW(
"bad context/form");
1451 if (ref_set && !symbol) {
1456 DAW(
"bad context/form");
1459 case DW_AT_artificial:
1466 case DW_AT_object_pointer:
1467 case DW_AT_accessibility:
1468 case DW_AT_containing_type:
1469 case DW_AT_virtuality:
1470 case DW_AT_vtable_elem_location:
1471 case DW_AT_explicit:
1472 DAWL(
"known unhandled");
1476 DAW(
"unrecognized");
1484 return DWARF_CB_ABORT;
1489 static inline char *dwarf_language_string(
int language) {
1491 case DW_LANG_C89:
return "C89";
1492 case DW_LANG_C:
return "C";
1493 case DW_LANG_Ada83:
return "Ada83";
1494 case DW_LANG_C_plus_plus:
return "C++";
1495 case DW_LANG_Cobol74:
return "Cobol74";
1496 case DW_LANG_Cobol85:
return "Cobol85";
1497 case DW_LANG_Fortran77:
return "Fortran77";
1498 case DW_LANG_Fortran90:
return "Fortran90";
1499 case DW_LANG_Pascal83:
return "Pascal83";
1500 case DW_LANG_Modula2:
return "Modula2";
1501 case DW_LANG_Java:
return "Java";
1502 case DW_LANG_C99:
return "C99";
1503 case DW_LANG_Ada95:
return "Ada95";
1504 case DW_LANG_Fortran95:
return "Fortran95";
1505 case DW_LANG_PL1:
return "PL/1";
1506 #if _INT_ELFUTILS_VERSION >= 155
1507 case DW_LANG_ObjC:
return "ObjectiveC";
1509 case DW_LANG_Objc:
return "ObjectiveC";
1511 case DW_LANG_ObjC_plus_plus:
return "ObjectiveC++";
1512 case DW_LANG_UPC:
return "UnifiedParallelC";
1513 case DW_LANG_D:
return "D";
1514 #if _INT_ELFUTILS_VERSION > 147
1515 case DW_LANG_Python:
return "Python";
1517 #if _INT_ELFUTILS_VERSION > 149
1518 case DW_LANG_Go:
return "Go";
1520 case DW_LANG_Mips_Assembler:
return "Assembler";
1521 default:
return NULL;
1526 unsigned int attr,Dwarf_Word offset) {
1527 struct debugfile *debugfile = srd->
debugfile;
1528 unsigned int addrsize = srd->
addrsize;
1536 Dwarf_Addr base = 0;
1537 struct range *retval = NULL, *lastr = NULL;
1553 readp = debugfile->
rangetab + offset;
1559 while (readp < endp) {
1560 loffset = readp - debugfile->
rangetab;
1563 verror(
"[%6tx] invalid loclist entry\n",loffset);
1567 if (addrsize == 8) {
1574 if (begin == (Dwarf_Addr)(uint32_t)-1)
1575 begin = (Dwarf_Addr)-1l;
1578 if (begin == (Dwarf_Addr)-1l) {
1585 else if (begin == 0 && end == 0) {
1598 retval =
calloc(1,
sizeof(*retval));
1599 retval->
start = (have_base) ? begin + base : begin + cu_base;
1600 retval->
end = (have_base) ? end + base : end + cu_base;
1605 lastr->next->start = (have_base) ? begin + base : begin + cu_base;
1606 lastr->next->end = (have_base) ? end + base : end + cu_base;
1607 lastr = lastr->next;
1617 Dwarf_Word offset) {
1618 struct debugfile *debugfile = srd->
debugfile;
1619 unsigned int addrsize = srd->
addrsize;
1629 Dwarf_Addr base = 0;
1656 while (readp < endp) {
1657 loffset = readp - debugfile->
loctab;
1660 verror(
"[%6tx] invalid loclist entry\n",loffset);
1664 if (addrsize == 8) {
1671 if (begin == (Dwarf_Addr)(uint32_t)-1)
1672 begin = (Dwarf_Addr)-1
l;
1675 if (begin == (Dwarf_Addr)-1
l) {
1682 else if (begin == 0 && end == 0) {
1686 "[%6tx] empty list\n",loffset);
1697 if (endp - readp <= (ptrdiff_t) exprlen) {
1698 verror(
"[%6tx] invalid exprlen (%hd) in entry\n",loffset,exprlen);
1705 "[%6tx] begin (0x%"PRIxADDR
") == end (0x%"PRIxADDR
")\n",
1711 "[%6tx] loc expr range(0x%"PRIxADDR
",0x%"PRIxADDR
") len %hd\n",
1712 loffset,begin,end,exprlen);
1719 "get_static_ops (%d) failed!\n",exprlen);
1724 "get_static_ops (%d) succeeded!\n",exprlen);
1727 rbegin = (have_base) ? begin + base : begin + cu_base;
1728 rend = (have_base) ? end + base : end + cu_base;
1730 verror(
"location_update_loclist failed!\n");
1755 struct symbol *symbol,
1756 struct symbol *parentsymbol,
1757 struct symbol *voidsymbol,
1758 GHashTable *reftab,
struct array_list *die_offsets,
1762 struct symbol *root) {
1764 struct symbol *symbol;
1785 struct symbol *root) {
1788 struct symbol *symbol;
1822 Dwarf_Off *cu_offset,
1823 struct array_list *init_die_offsets,
int expand_dies) {
1824 Dwarf *dbg = srd->
dbg;
1825 struct debugfile *debugfile = srd->
debugfile;
1828 Dwarf_Off offset = *cu_offset;
1832 Dwarf_Die *dies = (Dwarf_Die *)
malloc(maxdies*
sizeof(Dwarf_Die));
1834 struct symbol *
root;
1835 struct scope *root_scope;
1836 struct symbol **
symbols = (
struct symbol **) \
1837 calloc(maxdies,
sizeof(
struct symbol *));
1840 struct symbol **imported_modules = (
struct symbol **) \
1841 calloc(maxdies,
sizeof(
struct symbol *));
1843 struct symbol *voidsymbol;
1844 struct symbol *rsymbol;
1848 Dwarf_Off until_die_offset = 0;
1849 Dwarf_Die top_level_first_die;
1859 int root_preexisting = 0;
1861 int have_stmt_list_offset = 0;
1862 Dwarf_Word cu_stmt_list_offset = 0;
1867 struct symbol *tsymbol;
1872 struct scope *reparent_scope;
1873 struct scope *specification_scope;
1874 struct symbol *specification_symbol;
1875 struct symbol *specification_symbol_parent;
1881 if (init_die_offsets)
1882 die_offsets = array_list_clone(init_die_offsets,0);
1898 "creating new CU symbol at 0x%"PRIx64
"!\n",offset);
1904 NULL,0,(
SMOFFSET)offset,loadtype,NULL);
1915 "using existing CU symbol %s (offset 0x%"PRIx64
")!\n",
1929 root_preexisting = 1;
1956 && (g_hash_table_lookup(debugfile->
srcfiles,root->
name)
1971 args.have_stmt_list_offset = 0;
1972 args.stmt_list_offset = 0;
1975 args.parentsymbol = NULL;
1976 args.voidsymbol = voidsymbol;
1979 offset += srd->
cuhl;
1986 if (dwarf_offdie(dbg,offset,&dies[level]) == NULL) {
1987 verror(
"cannot get DIE at offset %" PRIx64
": %s\n",
1988 offset,dwarf_errmsg(-1));
2014 struct scope *newscope;
2021 offset = dwarf_dieoffset(&dies[level]);
2022 if (offset == ~0ul) {
2023 verror(
"cannot get DIE offset: %s",dwarf_errmsg(-1));
2031 (
void *)(uintptr_t)offset);
2037 symbols[level] = NULL;
2046 ts = (
struct symbol *) \
2047 g_hash_table_lookup(srd->
reftab,(gpointer)(uintptr_t)offset);
2059 symbols[level] = ts;
2063 " skipping to sibling\n",
2082 symbols[level] = ts;
2087 " on symtab; expanding attrs and children\n",
2093 symbols[level] = NULL;
2097 "existing reftab symbol (partial) %s 0x%"PRIxSMOFFSET";"
2098 " skipping to sibling\n",
2110 tag = dwarf_tag(&dies[level]);
2112 if (tag == DW_TAG_invalid) {
2113 verror(
"cannot get tag of DIE at offset %" PRIx64
": %s\n",
2114 offset,dwarf_errmsg(-1));
2143 if (tag == DW_TAG_variable
2144 || tag == DW_TAG_formal_parameter
2145 || tag == DW_TAG_enumerator) {
2146 if (!symbols[level]) {
2149 NULL,0,offset,loadtype,scopes[level]);
2150 if (tag == DW_TAG_formal_parameter)
2152 if (tag == DW_TAG_enumerator) {
2169 symbols[level]->
datatype = symbols[level-1];
2174 else if (tag == DW_TAG_member) {
2175 if (!symbols[level]) {
2178 NULL,0,offset,loadtype,scopes[level]);
2182 else if (tag == DW_TAG_label) {
2183 if (!symbols[level]) {
2186 NULL,0,offset,loadtype,scopes[level]);
2189 else if (tag == DW_TAG_unspecified_parameters) {
2190 if (!symbols[level-1])
2191 vwarn(
"cannot handle unspecified_parameters without parent!\n");
2196 else if (tag == DW_TAG_base_type
2197 || tag == DW_TAG_typedef
2198 || tag == DW_TAG_pointer_type
2199 || tag == DW_TAG_reference_type
2200 || tag == DW_TAG_array_type
2201 || tag == DW_TAG_structure_type
2202 || tag == DW_TAG_enumeration_type
2203 || tag == DW_TAG_union_type
2204 || tag == DW_TAG_const_type
2205 || tag == DW_TAG_volatile_type
2206 || tag == DW_TAG_subroutine_type
2207 || tag == DW_TAG_class_type
2208 || tag == DW_TAG_namespace
2210 if (!symbols[level]) {
2213 NULL,0,offset,loadtype,scopes[level]);
2216 case DW_TAG_base_type:
2218 case DW_TAG_typedef:
2220 case DW_TAG_pointer_type:
2222 case DW_TAG_reference_type:
2224 case DW_TAG_array_type:
2226 case DW_TAG_structure_type:
2228 case DW_TAG_enumeration_type:
2230 case DW_TAG_union_type:
2232 case DW_TAG_const_type:
2234 case DW_TAG_volatile_type:
2236 case DW_TAG_subroutine_type:
2238 case DW_TAG_class_type:
2240 case DW_TAG_namespace:
2255 else if (tag == DW_TAG_subrange_type) {
2262 else if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
2263 if (!symbols[level]) {
2266 NULL,0,offset,loadtype,scopes[level]);
2276 else if (tag == DW_TAG_lexical_block) {
2283 else if (tag == DW_TAG_compile_unit) {
2284 symbols[level] =
root;
2286 else if (tag == DW_TAG_imported_module) {
2293 else if (tag == DW_TAG_imported_declaration
2294 || tag == DW_TAG_template_type_parameter
2295 || tag == DW_TAG_template_value_parameter
2296 || tag == DW_TAG_imported_module
2297 || tag == DW_TAG_inheritance) {
2300 symbols[level] = NULL;
2306 symbols[level] = NULL;
2315 args.parentsymbol = symbols[level-1];
2317 args.parentsymbol = NULL;
2318 args.symbol = symbols[level];
2320 args.lowpc = args.highpc = 0;
2322 args.highpc_set = 0;
2323 args.highpc_is_offset = 0;
2324 args.specification_set = 0;
2325 args.specification_ref = 0;
2329 args.die_offset =
offset;
2330 (void)dwarf_getattrs(&dies[level],attr_callback,&args,0);
2351 "unmarking declaration flag for non-static member!\n");
2355 reparent_scope = NULL;
2371 if (tag == DW_TAG_imported_module) {
2372 if (!args.ref_set) {
2373 verror(
"no AT_import ref for TAG_imported_module"
2377 else if (!(imported_modules[level] = (
struct symbol *) \
2378 g_hash_table_lookup(srd->
reftab,(gpointer)(uintptr_t)args.ref))) {
2381 "forward ref 0x%"PRIxOFFSET" for TAG_imported_module;"
2382 " pushing that in front of us and redoing after\n",
2386 array_list_add_item_at(die_offsets,
2387 (
void *)(uintptr_t)args.ref,i);
2396 " TAG_imported_module at 0x%"PRIxOFFSET"; skipping;"
2397 " scope hier might be wrong!\n",args.ref,offset);
2411 else if (imported_modules[level]) {
2418 symbols[level]->
scope = reparent_scope;
2421 "continuing to use imported module scope 0x%"PRIxSMOFFSET
2423 reparent_scope->
ref,
2438 specification_scope = NULL;
2439 specification_symbol = NULL;
2440 specification_symbol_parent = NULL;
2441 if (args.specification_set && symbols[level]) {
2443 specification_symbol = (
struct symbol *) \
2444 g_hash_table_lookup(srd->
reftab,
2445 (gpointer)(uintptr_t)args.specification_ref);
2446 if (!specification_symbol) {
2457 specification_scope =
2460 reparent_scope = specification_scope;
2465 symbols[level]->
scope = specification_scope;
2471 specification_symbol_parent = specification_scope->
symbol;
2480 g_hash_table_insert(srd->
spec_reftab,symbols[level],
2481 specification_symbol);
2490 if (symbols[level] && args.lowpc_set)
2499 && args.lowpc_set && args.highpc_set) {
2504 if (args.highpc_is_offset || args.highpc >= args.lowpc) {
2505 if (!args.highpc_is_offset)
2506 highpc = args.highpc;
2508 highpc = args.lowpc + args.highpc;
2522 else if (action == 2)
2528 verror(
"bad lowpc/highpc (0x%"PRIxADDR
",0x%"PRIxADDR
")"
2530 args.lowpc,args.highpc,offset);
2533 else if (args.lowpc_set && args.highpc_set) {
2552 range = args.ranges;
2566 else if (action == 2)
2571 range = range->
next;
2582 if (tag == DW_TAG_compile_unit &&
unlikely(!root_added)) {
2584 if (args.have_stmt_list_offset) {
2585 have_stmt_list_offset = 1;
2586 cu_stmt_list_offset = args.stmt_list_offset;
2590 verror(
"CU did not have a src filename; aborting processing!\n");
2592 if (!root_preexisting)
2599 if (root_preexisting) {
2602 "could not update CU symbol %s to debugfile;"
2603 " aborting processing!\n",
2613 "could not add CU symbol %s to debugfile;"
2614 " aborting processing!\n",
2633 && (!die_offsets || array_list_len(die_offsets) == 0))
2650 if (dwarf_child(&dies[level],&top_level_first_die) == 0)
2652 dwarf_dieoffset(&top_level_first_die);
2663 if (tag == DW_TAG_compile_unit && die_offsets) {
2664 if (array_list_len(die_offsets)) {
2666 offset = (
SMOFFSET)(uintptr_t)array_list_item(die_offsets,i);
2689 until_die_offset = offset;
2695 offset = (Dwarf_Off)tstart;
2698 "skipping to top level DIE 0x%x to load DIE 0x%x\n",
2699 offset,until_die_offset);
2709 "skipping to first CU top level DIE 0x%x to load DIE 0x%x\n",
2710 offset,until_die_offset);
2722 if (dwarf_offdie(dbg,offset,&dies[level]) == NULL) {
2723 verror(
"cannot get first DIE at offset 0x%"PRIx64
2724 " during partial CU load: %s\n",
2725 offset,dwarf_errmsg(-1));
2729 "skipping to first DIE 0x%x\n",offset);
2730 scopes[level] = scopes[level-1];
2760 if (symbols[level] && !nofinalize)
2785 if (level == 1 && symbols[level]
2794 if ((tsymbol = (
struct symbol *) \
2803 "inserting shared symbol (quick check) %s (%s"
2832 RHOLD(symbols[level],srd);
2834 RPUT(symbols[level],symbol,srd,trefcnt);
2835 symbols[level] = NULL;
2842 else if (!symbols[level]->isdeclaration) {
2844 "sharing symbol (quick check) %s (%s) of type %s\n",
2855 RHOLD(symbols[level],debugfile);
2870 && symbols[level]->isinlineinstance)
2872 && (symbols[level]->isinlineinstance))
2874 && (symbols[level]->isinlineinstance
2876 && symbols[level]->isparam
2881 && symbols[level]->ismember
2885 "anonymous symbol of type %s at DIE 0x%"PRIx64
"!\n",
2897 if (!ts && symbols[level] && level > 0)
2922 if (level + 1 == maxdies) {
2924 dies = (Dwarf_Die *)
realloc(dies,maxdies*
sizeof(Dwarf_Die));
2925 symbols = (
struct symbol **) \
2926 realloc(symbols,maxdies*
sizeof(
struct symbol *));
2927 scopes = (
struct scope **) \
2929 imported_modules = (
struct symbol **) \
2930 realloc(imported_modules,maxdies*
sizeof(
struct symbol *));
2932 for (tmplpc = level + 1; tmplpc < maxdies; ++tmplpc) {
2933 symbols[tmplpc] = NULL;
2934 imported_modules[tmplpc] = NULL;
2938 int res = dwarf_child(&dies[level],&dies[level + 1]);
2983 if (symbols[level]) {
2984 if (args.specification_set && specification_symbol_parent) {
2988 else if (imported_modules[level]) {
2998 else if (symbols[level-1])
3000 else if (scopes[level])
3003 verror(
"symbol(%s:0x%"PRIxSMOFFSET
") but no parent to add to!\n",
3008 else if (newscope) {
3012 verror(
"scope at 0x%"PRIx64
" has no parent!\n",
3025 if (symbols[level] && !nofinalize) {
3026 struct symbol *finalize_parent;
3027 if (specification_symbol_parent)
3028 finalize_parent = specification_symbol_parent;
3029 else if (imported_modules[level])
3030 finalize_parent = imported_modules[level];
3031 else if (level > 0 && symbols[level - 1])
3032 finalize_parent = symbols[level - 1];
3034 finalize_parent = NULL;
3048 inline int setup_skip_to_next_die(
void) {
3049 int alen = array_list_len(die_offsets);
3060 offset = (
SMOFFSET)(uintptr_t)array_list_item(die_offsets,i);
3063 sss = (
struct symbol *) \
3064 g_hash_table_lookup(srd->
reftab,(gpointer)(uintptr_t)offset);
3075 until_die_offset =
offset;
3081 offset = (Dwarf_Off)tstart;
3084 "skipping to top level DIE 0x%x to load DIE 0x%x\n",
3085 offset,until_die_offset);
3091 "skipping to first CU top level DIE 0x%x to load DIE 0x%x\n",
3092 offset,until_die_offset);
3102 scopes[level] = root_scope;
3103 if (dwarf_offdie(dbg,offset,&dies[level]) == NULL) {
3104 verror(
"cannot get DIE %d at offset 0x%"PRIx64
3105 " during partial CU (0x%"PRIx64
") load: %s\n",
3106 i - 1,offset,*cu_offset,dwarf_errmsg(-1));
3119 "skipping to DIE %d at 0x%x in CU 0x%"PRIx64
"\n",
3120 i,offset,*cu_offset);
3134 if (level >= 0 && symbols[level]
3151 struct symbol *specsym;
3153 specsym = (
struct symbol *) \
3154 g_hash_table_lookup(srd->
spec_reftab,symbols[level]);
3157 g_hash_table_remove(srd->
spec_reftab,symbols[level]);
3164 struct scope *tscope;
3166 if (tscope && tscope->
symbol)
3176 if (die_offsets && level == 1 && offset > until_die_offset) {
3182 if (die_offsets && symbols[level] && symbols[level]->name
3183 && symbols[level]->isdeclaration)
3185 symbols[level]->name);
3186 symbols[level] = NULL;
3188 res2 = setup_skip_to_next_die();
3190 if (res2 == -1)
goto errout;
3192 else if (res2 == 0) { level = -1; }
3194 else if (res2 == 1)
continue;
3197 while ((res = dwarf_siblingof(&dies[level],&dies[level])) == 1) {
3198 int oldlevel = level--;
3206 struct symbol *specsym;
3208 specsym = (
struct symbol *) \
3209 g_hash_table_lookup(srd->
spec_reftab,symbols[level]);
3213 g_hash_table_remove(srd->
spec_reftab,symbols[level]);
3220 struct scope *tscope;
3222 if (tscope && tscope->
symbol)
3237 if (die_offsets && oldlevel == 1 && offset > until_die_offset) {
3244 if (die_offsets && symbols[level] && symbols[level]->name
3245 && symbols[level]->isdeclaration)
3247 symbols[level]->name);
3248 symbols[level] = NULL;
3250 res2 = setup_skip_to_next_die();
3252 if (res2 == -1)
goto errout;
3254 else if (res2 == 0) { level = -1;
break; }
3256 else if (res2 == 1)
continue;
3259 else if (oldlevel == 0)
3268 if (die_offsets && symbols[level] && symbols[level]->name
3269 && symbols[level]->isdeclaration)
3271 symbols[level]->name);
3272 symbols[level] = NULL;
3285 imported_modules[oldlevel] = NULL;
3289 verror(
"cannot get next DIE: %s\n",dwarf_errmsg(-1));
3292 else if (res == 0 && die_offsets && level == 1 && offset > until_die_offset) {
3297 res2 = setup_skip_to_next_die();
3299 if (res2 == -1)
goto errout;
3301 else if (res2 == 0) { level = -1; }
3303 else if (res2 == 1)
continue;
3308 verror(
"cannot get next DIE: %s",dwarf_errmsg(-1));
3322 if ((!quick || expand_dies || tag == DW_TAG_enumeration_type) || level < 1
3323 || (until_die_offset && args.sibling && until_die_offset < args.sibling)) {
3325 symbols[level] = NULL;
3327 scopes[level] = scopes[level-1];
3329 scopes[level] = newscope;
3333 if (until_die_offset && args.sibling && until_die_offset >= args.sibling) {
3409 GSList *klist = g_hash_table_get_keys_slist(srd->
reftab);
3411 GHashTable *eqcache = g_hash_table_new(g_direct_hash,g_direct_equal);
3414 offset = (uintptr_t)key;
3415 rsymbol = (
struct symbol *) \
3416 g_hash_table_lookup(srd->
reftab,(gpointer)(uintptr_t)offset);
3423 if ((tsymbol = (
struct symbol *) \
3425 && rsymbol != tsymbol
3429 "inserting shared symbol (slow check) %s (%s"
3430 " 0x%"PRIxSMOFFSET
") of type %s at offset 0x%"
3431 PRIxSMOFFSET
" into reftab\n",
3456 "no shared match for symbol (slow check) %s (%s"
3457 " 0x%"PRIxSMOFFSET
") of type %s at offset 0x%"
3458 PRIxSMOFFSET
" into reftab\n",
3466 "sharing symbol (slow check) %s (%s"
3467 " 0x%"PRIxSMOFFSET
") of type %s at offset 0x%"
3468 PRIxSMOFFSET
" into reftab\n",
3477 g_hash_table_insert(debugfile->
shared_types,sname,rsymbol);
3481 RHOLD(rsymbol,debugfile);
3488 g_slist_free(klist);
3489 g_hash_table_destroy(eqcache);
3494 if (have_stmt_list_offset) {
3508 array_list_free(die_offsets);
3512 free(imported_modules);
3517 dwarf_refuselist_clean(root,retval ? 1 : 0);
3518 dwarf_reftab_clean(root,retval ? 1 : 0);
3524 struct symbol *old,
struct symbol *
new) {
3525 struct symbol *
root;
3539 verror(
"could not find root symbol for old ");
3541 verrorc(
" replacing with new ");
3553 vwarn(
"no scope for old ");
3561 struct symbol *root,
struct symbol *symbol) {
3562 Dwarf_Off die_offset;
3571 sal = array_list_create(1);
3572 die_offset = root->
ref;
3574 array_list_append(sal,(
void *)(uintptr_t)symbol->
ref);
3577 "expanding symbol(%s:0x%"PRIxOFFSET") in CU %s\n",
3580 retval = dwarf_load_cu(srd,&die_offset,sal,1);
3582 array_list_free(sal);
3603 Dwarf_Off cu_offset = root->
ref;
3614 "loading entire CU %s (offset 0x%"PRIxOFFSET")!\n",
3617 rc = dwarf_load_cu(srd,&cu_offset,NULL,1);
3671 static int debuginfo_load(
struct debugfile *debugfile,
3672 Dwfl_Module *
dwflmod,Dwarf *dbg) {
3676 GHashTable *cu_die_offsets = NULL;
3677 Dwarf_Off offset = 0;
3681 GHashTableIter iter;
3694 cu_die_offsets = g_hash_table_new_full(g_direct_hash,g_direct_equal,
3696 (GDestroyNotify)array_list_free);
3697 g_hash_table_iter_init(&iter,debugfile->
pubnames);
3698 while (g_hash_table_iter_next(&iter,&key,(gpointer)&value)) {
3701 g_hash_table_lookup(cu_die_offsets,
3702 (gpointer)(uintptr_t)dcd->
cu_offset))) {
3703 tmpal = array_list_create(1);
3704 g_hash_table_insert(cu_die_offsets,
3726 array_list_append(tmpal,(
void *)(uintptr_t)(dcd->
die_offset \
3732 g_hash_table_iter_init(&iter,cu_die_offsets);
3733 while (g_hash_table_iter_next(&iter,&cu_offset,&value)) {
3737 for (i = 0; i < array_list_len(tmpal); ++
i) {
3739 (
SMOFFSET)(uintptr_t)array_list_item(tmpal,i));
3745 g_hash_table_iter_init(&iter,cu_die_offsets);
3746 if (!g_hash_table_iter_next(&iter,&cu_offset,&value))
3749 offset = (Dwarf_Off)(uintptr_t)cu_offset;
3760 #if defined(LIBDW_HAVE_NEXT_UNIT) && LIBDW_HAVE_NEXT_UNIT == 1
3761 if ((rc = dwarf_next_unit(dbg,offset,&srd->
nextcu,&srd->
cuhl,
3763 &srd->
offsize,NULL,NULL)) < 0) {
3764 verror(
"dwarf_next_unit: %s (%d)\n",dwarf_errmsg(dwarf_errno()),rc);
3770 "dwarf_next_unit returned (%d), aborting successfully.\n",rc);
3775 if ((rc = dwarf_nextcu(dbg,offset,&srd->
nextcu,&srd->
cuhl,
3778 verror(
"dwarf_nextcu: %s (%d)\n",dwarf_errmsg(dwarf_errno()),rc);
3784 "dwarf_nextcu returned (%d), aborting successfully.\n",rc);
3798 srd->
reftab = g_hash_table_new(g_direct_hash,g_direct_equal);
3825 srd->
refuselist = g_hash_table_new(g_direct_hash,g_direct_equal);
3826 srd->
spec_reftab = g_hash_table_new(g_direct_hash,g_direct_equal);
3828 rc = dwarf_load_cu(srd,&offset,die_offsets,0);
3835 if (cu_die_offsets) {
3836 if (!g_hash_table_iter_next(&iter,&cu_offset,
3840 offset = (Dwarf_Off)(uintptr_t)cu_offset;
3870 g_hash_table_destroy(cu_die_offsets);
3903 struct symbol *symbol,
3904 struct symbol *parentsymbol,
3905 struct symbol *voidsymbol,
3906 GHashTable *reftab,
struct array_list *die_offsets,
3911 verror(
"null symbol!\n");
3933 "setting symbol(%s:0x%"PRIxSMOFFSET
") type %s"
3934 " without type to void\n",
3941 "setting symbol(%s:0x%"PRIxSMOFFSET
") type %s"
3942 " without type to void\n",
3964 g_hash_table_insert(debugfile->
addresses,
3968 "inserted %s %s(0x%"PRIxSMOFFSET
") with base_addr 0x%"PRIxADDR
3969 " into debugfile addresses table\n",
3984 && !(symbol->
datatype = (
struct symbol *) \
3985 g_hash_table_lookup(reftab,
3987 array_list_append(die_offsets,
4002 array_list_append(die_offsets,
4003 (
void *)(uintptr_t)sii->origin_ref);
4048 inname =
malloc(
sizeof(
char)*inlen);
4049 sprintf(inname,
"__INLINED(ref%"PRIxSMOFFSET
":%s)",
4053 inlen = 9 + 1 + 18 + 1 + 4 + 16 + 1 + 1;
4054 inname =
malloc(
sizeof(
char)*inlen);
4055 sprintf(inname,
"__INLINED(ref%"PRIxSMOFFSET
":iref%"PRIxSMOFFSET
")",
4056 symbol->
ref,sii->origin_ref);
4088 unsigned char *buf,
unsigned int len,Dwarf *dbg) {
4089 const unsigned char *readp = buf;
4090 const unsigned char *readendp = buf +
len;
4097 while (readp < readendp) {
4115 if (length == DWARF3_LENGTH_64_BIT) {
4117 "64-bit DWARF length %"PRIu64
"; continuing.\n",length);
4121 else if (
unlikely(length >= DWARF3_LENGTH_MIN_ESCAPE_CODE
4122 && length <= DWARF3_LENGTH_MAX_ESCAPE_CODE))
4124 "bad DWARF length %"PRIu64
"; continuing anyway!\n",length);
4129 "bad DWARF arange version %u; continuing anyway!\n",
4137 Dwarf_Word die_offset;
4145 if (die_offset == 0)
4160 g_hash_table_insert(debugfile->
pubnames,strdup((
const char *)readp),
4162 readp += strlen((
const char *)readp) + 1;
4170 unsigned char *buf,
unsigned int len,Dwarf *dbg) {
4171 struct symbol *
root;
4172 struct scope *cu_scope;
4173 const unsigned char *readp = buf;
4174 const unsigned char *readendp = buf +
len;
4181 while (readp < readendp) {
4182 const unsigned char *hdrstart = readp;
4205 if (length == DWARF3_LENGTH_64_BIT) {
4207 "64-bit DWARF length %"PRIu64
"; continuing.\n",length);
4210 else if (
unlikely(length >= DWARF3_LENGTH_MIN_ESCAPE_CODE
4211 && length <= DWARF3_LENGTH_MAX_ESCAPE_CODE))
4213 "bad DWARF length %"PRIu64
"; continuing anyway!\n",length);
4218 "bad DWARF arange version %u; continuing anyway!\n",
4223 unsigned int address_size = *readp++;
4224 if (address_size != 4 && address_size != 8)
4226 "bad DWARF address size %u; continuing anyway!\n",
4232 readp += ((2 * address_size - ((readp - hdrstart) % (2 * address_size)))
4233 % (2 * address_size));
4248 Dwarf_Word range_address;
4249 Dwarf_Word range_length;
4252 if (address_size == 8) {
4262 if (range_address == 0 && range_length == 0)
4266 range_address + range_length,&action);
4274 range_address + range_length,cu_scope);
4275 else if (action == 2)
4277 range_address + range_length,cu_scope);
4284 static int process_dwflmod (Dwfl_Module *dwflmod,
4289 struct debugfile *debugfile = (
struct debugfile *)arg;
4294 struct binfile *binfile_pointing = NULL;
4305 unsigned int *saveptrlen;
4313 if (binfile_pointing)
4314 bfelf_pointing = (
struct binfile_elf *)binfile_pointing->priv;
4316 dwfl_module_getelf(dwflmod,&dwflbias);
4321 dbg = dwfl_module_getdwarf(dwflmod,&dwbias);
4324 "could not get dwarf module in debugfile %s!\n",
4329 for (i = 0; i < bfelf->ehdr.e_shnum; ++
i) {
4330 shdr = &bfelf->shdrs[
i];
4331 scn = elf_getscn(bfelf->elf,i);
4333 if (shdr && shdr->sh_size > 0) {
4335 name = elf_strptr(bfelf->elf,bfelf->shstrndx,shdr->sh_name);
4337 if (strcmp(name,
".debug_str") == 0) {
4341 else if (strcmp(name,
".debug_loc") == 0) {
4342 saveptr = &debugfile->
loctab;
4345 else if (strcmp(name,
".debug_ranges") == 0) {
4349 else if (strcmp(name,
".debug_line") == 0) {
4350 saveptr = &debugfile->
linetab;
4353 else if (strcmp(name,
".eh_frame") == 0) {
4355 vwarn(
"already saw frame section; not processing"
4365 else if (strcmp(name,
".debug_frame") == 0) {
4367 vwarn(
"already saw frame section; not processing"
4368 " .debug_frame!\n");
4376 else if (strcmp(name,
".debug_aranges") == 0
4377 || strcmp(name,
".debug_pubnames") == 0) {
4389 "found %s section (%d) (%p) in debugfile %s\n",
4390 name,shdr->sh_size,scn,debugfile->
filename);
4392 edata = elf_rawdata(scn,NULL);
4394 verror(
"cannot get raw data for valid section '%s': %s\n",
4395 name,elf_errmsg(-1));
4398 else if (!edata->d_buf && edata->d_size) {
4400 if (bfelf_pointing && bfelf_pointing->
elf) {
4402 "cannot get raw data for valid section '%s': %s;"
4403 " trying getdata on the pointing binfile\n",
4404 name,elf_errmsg(-1));
4406 for (ii = 0; ii < bfelf_pointing->
ehdr.e_shnum; ++ii) {
4407 shdr = &bfelf_pointing->
shdrs[ii];
4408 scn = elf_getscn(bfelf_pointing->
elf,ii);
4410 if (shdr && shdr->sh_size > 0) {
4412 name2 = elf_strptr(bfelf_pointing->
elf,
4413 bfelf_pointing->
shstrndx,shdr->sh_name);
4415 if (strcmp(name,name2) == 0) {
4416 edata = elf_getdata(scn,NULL);
4418 verror(
"still cannot get data for valid section '%s': %s\n",
4419 name,elf_errmsg(-1));
4423 else if (!edata->d_buf) {
4424 vwarn(
"still cannot get data for valid section '%s' (%d);"
4426 name,(
int)edata->d_size);
4438 verror(
"cannot get raw data for valid section '%s': %s;"
4439 " could not getdata on the pointing binfile\n",
4440 name,elf_errmsg(-1));
4445 verror(
"cannot get raw data for valid section '%s': %s;"
4446 " could not try getdata on the pointing binfile\n",
4447 name,elf_errmsg(-1));
4458 if (strcmp(name,
".debug_aranges") == 0) {
4462 else if (strcmp(name,
".debug_pubnames") == 0) {
4472 *saveptrlen = edata->d_size;
4473 *saveptr =
malloc(edata->d_size);
4474 memcpy(*saveptr,edata->d_buf,edata->d_size);
4483 if (strcmp(name,
".debug_frame") == 0
4484 || strcmp(name,
".eh_frame") == 0) {
4489 else if (shdr && shdr->sh_size == 0) {
4494 vwarn(
"no debug string table found for debugfile %s; things may break!\n",
4499 for (i = 0; i < bfelf->ehdr.e_shnum; ++
i) {
4500 shdr = &bfelf->shdrs[
i];
4501 scn = elf_getscn(bfelf->elf,i);
4503 if (shdr && shdr->sh_size > 0 && shdr->sh_type == SHT_PROGBITS) {
4504 name = elf_strptr(bfelf->elf,bfelf->shstrndx,shdr->sh_name);
4506 if (strcmp(name,
".debug_info") == 0) {
4508 "found .debug_info section in debugfile %s\n",
4510 debuginfo_load(debugfile,dwflmod,dbg);
4528 debugfile->
loctab = NULL;
4543 #ifdef DWDEBUG_NOUSE_STRTAB
4557 return DWARF_CB_ABORT;
4564 static int find_no_debuginfo(Dwfl_Module *mod
__attribute__ ((unused)),
4575 static int bfi_find_elf(Dwfl_Module *mod
__attribute__ ((unused)),
4585 if (!(binfile = (
struct binfile *)*userdata)) {
4586 verror(
"no binfile; bug!?\n");
4606 static int bfi_find_section_address(Dwfl_Module *mod,
void **userdata,
4607 const char *modname,Dwarf_Addr base,
4608 const char *secname,GElf_Word shndx,
4609 const GElf_Shdr *shdr,Dwarf_Addr *addr) {
4610 struct binfile *binfile;
4615 if (!(binfile = (
struct binfile *)*userdata)) {
4616 verror(
"no binfile; bug!?\n");
4626 verror(
"no ELF instance info for binfile %s!\n",binfile->
filename);
4639 "section %d out of range (%d) in binfile instance %s!\n",
4648 "shndx = %d addr = %"PRIxADDR
" base = %x\n",
4656 *addr = (Dwarf_Addr)-1L;
4658 *addr = (Dwarf_Addr)tmp;
4670 struct binfile *binfile = debugfile->
binfile;
4674 void **userdata = NULL;
4680 Dwfl_Callbacks callbacks = {
4681 .find_debuginfo = find_no_debuginfo,
4684 bfelf->
dwfl = dwfl_begin(&callbacks);
4685 if (bfelf->
dwfl == NULL) {
4686 verror(
"could not init libdwfl: %s\n",dwfl_errmsg(dwfl_errno()));
4698 if (bfi && bfielf && binfile->
image) {
4699 callbacks.section_address = bfi_find_section_address;
4700 callbacks.find_elf = bfi_find_elf;
4705 dwfl_report_begin(bfelf->
dwfl);
4708 verror(
"could not report relocatable module in binfile instance %s!\n",
4710 dwfl_end(bfelf->
dwfl);
4716 dwfl_module_info(mod,&userdata,NULL,NULL,NULL,NULL,NULL,NULL);
4717 *userdata = binfile;
4719 else if (binfile->
fd > -1) {
4720 callbacks.section_address = dwfl_offline_section_address;
4725 verror(
"dup(%d): %s\n",binfile->
fd,strerror(errno));
4732 if (!dwfl_report_offline(bfelf->
dwfl,debugfile->
filename,
4734 verror(
"dwfl_report_offline: %s\n",dwfl_errmsg(dwfl_errno()));
4735 dwfl_end(bfelf->
dwfl);
4742 verror(
"binfile %s had no fd nor memory image!\n",binfile->
filename);
4743 dwfl_end(bfelf->
dwfl);
4749 dwfl_report_end(bfelf->
dwfl,NULL,NULL);
4755 if (dwfl_getmodules(bfelf->
dwfl,&process_dwflmod,debugfile,0) < 0) {
4756 verror(
"getting dwarf modules: %s\n",dwfl_errmsg(dwfl_errno()));
4757 dwfl_end(bfelf->
dwfl);
4759 if (bfi && bfielf && binfile->
image)
4768 dwfl_end(bfelf->
dwfl);
4770 if (bfi && bfielf && binfile->
image)
4792 dwarf_refuselist_clean(root,1);
4793 dwarf_reftab_clean(root,1);
4796 g_hash_table_destroy(srd->
reftab);
4811 if (debugfile->
priv)
4814 ddi =
calloc(1,
sizeof(*ddi));
4815 debugfile->
priv = ddi;
4823 if (!debugfile->
priv)
4831 debugfile->
priv = NULL;
int debugfile_add_type(struct debugfile *debugfile, struct symbol *symbol)
int debugfile_insert_root(struct debugfile *debugfile, struct symbol *symbol)
const char * dwarf_access_string(unsigned int code)
const char * dwarf_attr_string(unsigned int attrnum)
int symbol_insert_symbol(struct symbol *parent, struct symbol *child)
int dwarf_refuselist_release(struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
const char * dwarf_encoding_string(unsigned int code)
#define vwarnopt(level, area, flags, format,...)
int dwarf_refuselist_hold(struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
struct location * location_copy(struct location *location)
int dwarf_specify_definition_attrs(struct symbol_root_dwarf *srd, struct symbol *specification, struct symbol *definition)
#define SYMBOLX_SUBRANGES(sym)
int dwarf_init(struct debugfile *debugfile)
struct scope * symbol_write_owned_scope(struct symbol *symbol)
unsigned int orig_name_offset
int symbol_set_root_language(struct symbol *symbol, char *language, int copy, short int lang_code)
void symbol_set_bytesize(struct symbol *s, uint32_t b)
const char * dwarf_ordering_string(unsigned int code)
#define SYMBOL_IST_VOL(sym)
void symbol_set_bitoffset(struct symbol *s, uint32_t bo)
void debugfile_save_declaration(struct debugfile *debugfile, struct symbol *symbol)
#define SYMBOL_RX_ROOT(sym, rvar)
clrangesimple_t clrangesimple_create(void)
const char * dwarf_visibility_string(unsigned int code)
int symbol_set_constval(struct symbol *symbol, void *value, int len, int copy)
#define symbol_set_enumval(s)
void * clmatchone_find(clmatchone_t *clf, Word_t index, Word_t *o_index)
Dwarf_Off first_top_level_die_offset
#define SYMBOL_RX_FUNC(sym, rvar)
struct symbol * symbol_create(symbol_type_t symtype, symbol_source_t source, char *name, int name_copy, SMOFFSET offset, load_type_t loadtype, struct scope *scope)
struct scope * symbol_read_owned_scope(struct symbol *symbol)
#define SYMBOL_RX_VAR(sym, rvar)
Dwarf_Word stmt_list_offset
GHashTable * shared_types
#define SYMBOL_WX_VAR(sym, wvar, reterr)
static uint64_t unsigned int i
int dwarf_load_aranges(struct debugfile *debugfile, unsigned char *buf, unsigned int len, Dwarf *dbg)
int scope_insert_symbol(struct scope *scope, struct symbol *symbol)
#define SYMBOLX_MEMBERS(sym)
struct array_list __attribute__
struct symbol * symbol_find_root(struct symbol *symbol)
struct location * dwarf_get_static_ops(struct symbol_root_dwarf *srd, const unsigned char *data, Dwarf_Word len, unsigned int attr)
#define v_g_slist_foreach(gslhead, gslcur, elm)
int dwarf_fini(struct debugfile *debugfile)
struct debugfile_load_opts * opts
int dwarf_reftab_replace(struct symbol_root_dwarf *srd, struct symbol *existing, struct symbol *new, SMOFFSET ref, GHashTableIter *iter)
unsigned int size_is_bytes
#define SYMBOL_IST_ENUM(sym)
void debugfile_handle_declaration(struct debugfile *debugfile, struct symbol *symbol)
clmatchone_t top_level_die_offsets
#define SYMBOL_IS_FULL(sym)
#define SYMBOL_IS_INSTANCE(sym)
ADDR symbol_get_addr(struct symbol *symbol)
#define SYMBOL_IS_INLINEABLE(sym)
const char * dwarf_virtuality_string(unsigned int code)
uint32_t symbol_get_bytesize(struct symbol *symbol)
void symbol_set_srcline(struct symbol *s, int sl)
int symbol_type_equal(struct symbol *t1, struct symbol *t2, GHashTable *eqcache, GHashTable *updated_datatype_refs)
int clmatchone_add(clmatchone_t *clf, Word_t index, void *data)
int debugfile_update_root(struct debugfile *debugfile, struct symbol *symbol)
void debugfile_resolve_declarations(struct debugfile *debugfile)
#define verror(format,...)
debugfile_load_flags_t flags
#define verrorc(format,...)
#define SYMBOL_IST_CONST(sym)
#define SYMBOLX_ROOT(sym)
struct debugfile_ops dwarf_debugfile_ops
#define LOGDUMPSYMBOL_NL(dl, lt, lf, s)
#define SYMBOL_IST_UNION(sym)
int dwarf_refuselist_notify_reftab_changed(struct symbol_root_dwarf *srd, SMOFFSET ref, struct symbol *refsym)
void finalize_die_symbol_name(struct symbol *symbol)
int symbol_set_root_compdir(struct symbol *symbol, char *compdirname, int copy)
GSList * scope_match_syms(struct scope *scope, struct rfilter *symbol_filter, symbol_type_flag_t flags)
#define vwarn(format,...)
int location_update_loclist(struct location *loc, ADDR start, ADDR end, struct location *rloc, int *action)
int dwarf_cfa_read_saved_reg(struct debugfile *debugfile, struct location_ctxt *lctxt, REG reg, REGVAL *o_regval)
int dwarf_get_lines(struct symbol_root_dwarf *srd, Dwarf_Off offset)
int dwarf_symbol_expand(struct debugfile *debugfile, struct symbol *root, struct symbol *symbol)
#define SYMBOL_IS_LABEL(sym)
unsigned int dbg_strtablen
int symbol_set_encoding(struct symbol *symbol, encoding_t num)
int symbol_has_addr(struct symbol *symbol)
char * symbol_get_name_orig(struct symbol *symbol)
int dwarf_cfa_read_retaddr(struct debugfile *debugfile, struct location_ctxt *lctxt, ADDR *o_retaddr)
const char * dwarf_calling_convention_string(unsigned int code)
struct scope * symbol_containing_scope(struct symbol *symbol)
int symbol_set_location(struct symbol *symbol, struct location *loc)
const char * dwarf_discr_list_string(unsigned int code)
#define SYMBOL_RX_INLINE(sym, rvar)
void location_free(struct location *location)
int dwarf_symbol_ref_symbol_changed(struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref, struct symbol *refsym)
datatype_code_t datatype_code
#define SYMBOL_IST_BASE(sym)
unsigned int isprototyped
int(* init)(struct debugfile *debugfile)
#define symbol_set_member(s)
#define SYMBOL_IST_ARRAY(sym)
void finalize_die_symbol(struct debugfile *debugfile, int level, struct symbol *symbol, struct symbol *parentsymbol, struct symbol *voidsymbol, GHashTable *reftab, struct array_list *die_offsets, SMOFFSET cu_offset)
void symbol_set_bitsize(struct symbol *s, uint32_t b)
int location_set_member_offset(struct location *l, OFFSET offset)
int dwarf_reftab_insert(struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
#define SYMBOL_IST_PTR(sym)
#define SYMBOL_IST_FUNC(sym)
#define WARNDUMPSYMBOL_NL(s)
int symbol_add_inline_instance(struct symbol *symbol, struct symbol *instance)
struct debugfile * debugfile
const char * dwarf_tag_string(unsigned int tag)
#define read_8ubyte_unaligned_inc(obo, Addr)
#define ERRORDUMPSYMBOL_NL(s)
unsigned int has_linkage_name
int debugfile_add_global(struct debugfile *debugfile, struct symbol *symbol)
#define SYMBOL_IST_STUNC(sym)
void symbol_set_addr(struct symbol *s, ADDR a)
int scope_remove_symbol(struct scope *scope, struct symbol *symbol)
#define SYMBOL_IST_STUN(sym)
int symbol_set_root_producer(struct symbol *symbol, char *producer, int copy)
int clrange_update_end(clrange_t *clf, Word_t start, Word_t end, void *data)
#define SYMBOL_WX_INLINE(sym, wvar, reterr)
int symbol_set_inline_origin(struct symbol *symbol, SMOFFSET ref, struct symbol *origin)
int dwarf_symbol_root_priv_free(struct debugfile *debugfile, struct symbol *root)
int dwarf_symbol_set_origin_ref(struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
#define vdebug(devel, areas, flags, format,...)
int debugfile_remove_root(struct debugfile *debugfile, struct symbol *symbol)
uint8_t have_stmt_list_offset
uint64_t frame_sec_offset
void * realloc(void *ptr, size_t size)
unsigned int isdeclaration
struct symbol * parentsymbol
struct symbol * do_word_symbol(struct debugfile *debugfile, struct symbol *root)
int dwarf_load_cfa(struct debugfile *debugfile, char *buf, unsigned int len, Dwarf *dbg)
void debugfile_resolve_one_declaration(struct debugfile *debugfile, char *name)
#define SYMBOL_IS_TYPE(sym)
#define vdebugc(devel, areas, flags, format,...)
struct location * location_create(void)
const char * dwarf_inline_string(unsigned int code)
void * calloc(size_t nmemb, size_t size)
GHashTable * srcfiles_multiuse
struct scope * symbol_link_owned_scope(struct symbol *symbol, struct scope *new_parent)
int dwarf_load_debuginfo(struct debugfile *debugfile)
#define SYMBOL_CAN_OWN_SCOPE(sym)
#define SYMBOL_HAS_EXTRA(sym)
struct symbol * debugfile_lookup_root(struct debugfile *debugfile, SMOFFSET offset)
#define SYMBOL_WX_FUNC(sym, wvar, reterr)
#define read_4ubyte_unaligned_inc(obo, Addr)
void scope_update_range(struct scope *scope, ADDR start, ADDR end, int *action)
struct symbol * symbol_get_sym(struct symbol *symbol, const char *name, symbol_type_flag_t flags)
const char * dwarf_lang_string(unsigned int lang)
int dwarf_symbol_set_datatype_ref(struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
struct binfile * binfile_pointing
#define symbol_set_parameter(s)
int dwarf_symbol_root_expand(struct debugfile *debugfile, struct symbol *root)
GSList * dwarf_refuselist_get(struct symbol_root_dwarf *srd, SMOFFSET ref)
void symbol_set_name(struct symbol *symbol, char *name, int copy)
struct symbol_root_dwarf * srd
int dwarf_load_pubnames(struct debugfile *debugfile, unsigned char *buf, unsigned int len, Dwarf *dbg)
struct rfilter * srcfile_filter
int symbol_set_root_priv(struct symbol *symbol, void *priv)
struct rfilter * symbol_filter
int scope_insert_scope(struct scope *parent, struct scope *child)
#define symbol_set_unspec_params(s)
int symbol_change_parent(struct symbol *parent, struct symbol *child, struct symbol *newparent)
#define read_2ubyte_unaligned_inc(obo, Addr)
#define SYMBOL_IS_ROOT(sym)
struct binfile_instance * instance
char * SYMBOL_TYPE(int n)
int symbol_set_inline_info(struct symbol *symbol, int isinlined, int isdeclinline)
int dwarf_symbol_refuselist_release_all(struct symbol_root_dwarf *srd, struct symbol *symbol)
Dwarf_Off specification_ref
struct symbol * do_void_symbol(struct debugfile *debugfile, struct symbol *root)
const char * dwarf_form_string(unsigned int form)
char * symbol_get_name(struct symbol *symbol)
int dwarf_specify_definition_members(struct symbol_root_dwarf *srd, struct symbol *specification, struct symbol *definition)
#define RPUT(x, objtype, hx, rc)
#define SYMBOL_IST_CONTAINER(sym)
struct symbol_root * root
void * malloc(size_t size)
void symbol_build_extname(struct symbol *symbol)
#define ERRORDUMPSYMBOL(s)
int symbol_add_subrange(struct symbol *symbol, int subrange)
const char * dwarf_identifier_case_string(unsigned int code)
unsigned int isinlineinstance
int symbol_set_entry_pc(struct symbol *symbol, ADDR entry_pc)
int vdebug_is_on(int level, log_areas_t areas, log_flags_t flags)
#define SYMBOL_IST_TYPEDEF(sym)
#define SYMBOL_IS_FUNC(sym)
uint8_t specification_set
int clrange_add(clrange_t *clf, Word_t start, Word_t end, void *data)
unsigned int usesshareddatatype
unsigned int size_is_bits
#define SYMBOL_IS_PARTIAL(sym)
int dwarf_symbol_replace(struct debugfile *debugfile, struct symbol *old, struct symbol *new)
struct symbol * voidsymbol
struct bsymbol ** symbols
unsigned int num_sections
#define LOGDUMPSYMBOL(dl, lt, lf, s)
#define SYMBOL_IS_VAR(sym)
int dwarf_unload_cfa(struct debugfile *debugfile)
struct scope * scope_create(struct symbol *owner, SMOFFSET ref)
int debugfile_replace_type(struct debugfile *debugfile, struct symbol *symbol)
int symbol_remove_symbol(struct symbol *parent, struct symbol *child)