X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dwarf_prototypes.c;h=9c369048ef5aa07ab34a73cbef764d520a1056ea;hb=6372bf3677c216ce8dd4dad90c51a6f2bff17f12;hp=4a23ae75faaaf46aeaf9881be5df03a579602cb0;hpb=150e91ca55bd5d3935c1d865327c676a6b5c9ce7;p=platform%2Fupstream%2Fltrace.git diff --git a/dwarf_prototypes.c b/dwarf_prototypes.c index 4a23ae7..9c36904 100644 --- a/dwarf_prototypes.c +++ b/dwarf_prototypes.c @@ -201,7 +201,7 @@ static bool get_integer_base_type(enum arg_type *type, int byte_size, static enum arg_type get_base_type(Dwarf_Die *die) { uint64_t encoding; - if (!get_die_numeric((uint64_t*)&encoding, die, DW_AT_encoding)) + if (!get_die_numeric(&encoding, die, DW_AT_encoding)) return ARGTYPE_VOID; if (encoding == DW_ATE_void) @@ -904,23 +904,10 @@ static bool get_prototype(struct prototype *result, #undef CLEANUP_AND_RETURN_ERROR } -static bool import_subprogram(struct protolib *plib, struct library *lib, - struct dict *type_dieoffset_hash, - Dwarf_Die *die) +static bool import_subprogram_name(struct protolib *plib, struct library *lib, + struct dict *type_dieoffset_hash, + Dwarf_Die *die, const char* function_name) { - // I use the linkage function name if there is one, otherwise the - // plain name - const char *function_name = NULL; - Dwarf_Attribute attr; - if (dwarf_attr(die, DW_AT_linkage_name, &attr) != NULL) - function_name = dwarf_formstring(&attr); - if (function_name == NULL) - function_name = dwarf_diename(die); - if (function_name == NULL) { - complain(die, "Function has no name. Not importing"); - return true; - } - if (!filter_matches_symbol(options.plt_filter, function_name, lib) && !filter_matches_symbol(options.static_filter, function_name, lib) && !filter_matches_symbol(options.export_filter, function_name, lib)) { @@ -955,6 +942,36 @@ static bool import_subprogram(struct protolib *plib, struct library *lib, return true; } +static bool import_subprogram_die(struct protolib *plib, struct library *lib, + struct dict *type_dieoffset_hash, + Dwarf_Die *die) +{ + // If there is a linkage name, I use it (this is required for C++ code, + // in particular). + // + // I use the plain name regardless, since sometimes the exported symbol + // corresponds to the plain name, NOT the linkage name. For instance I + // see this on my Debian/sid amd64 box. In its libc, the linkage name of + // __nanosleep is __GI___nanosleep, but the export is __nanosleep + const char *function_name; + Dwarf_Attribute attr; + + if (dwarf_attr(die, DW_AT_linkage_name, &attr) != NULL && + (function_name = dwarf_formstring(&attr)) != NULL && + !import_subprogram_name(plib, lib, type_dieoffset_hash, die, + function_name)) { + return false; + } + + if ((function_name = dwarf_diename(die)) != NULL && + !import_subprogram_name(plib, lib, type_dieoffset_hash, die, + function_name)) { + return false; + } + + return true; +} + static bool process_die_compileunit(struct protolib *plib, struct library *lib, struct dict *type_dieoffset_hash, Dwarf_Die *parent) @@ -968,8 +985,8 @@ static bool process_die_compileunit(struct protolib *plib, struct library *lib, while (1) { if (dwarf_tag(&die) == DW_TAG_subprogram) - if (!import_subprogram(plib, lib, type_dieoffset_hash, - &die)) + if (!import_subprogram_die(plib, lib, type_dieoffset_hash, + &die)) complain(&die, "Error importing subprogram. " "Skipping"); @@ -979,7 +996,8 @@ static bool process_die_compileunit(struct protolib *plib, struct library *lib, return true; } -static void import(struct protolib *plib, struct library *lib, Dwfl *dwfl) +static void import(struct protolib *plib, struct library *lib, + Dwfl_Module *dwfl_module) { // A map from DIE addresses (Dwarf_Off) to type structures (struct // arg_type_info*). This is created and filled in at the start of each @@ -992,7 +1010,7 @@ static void import(struct protolib *plib, struct library *lib, Dwfl *dwfl) Dwarf_Addr bias; Dwarf_Die *die = NULL; - while ((die = dwfl_nextcu(dwfl, die, &bias)) != NULL) { + while ((die = dwfl_module_nextcu(dwfl_module, die, &bias)) != NULL) { if (dwarf_tag(die) == DW_TAG_compile_unit) process_die_compileunit(plib, lib, &type_dieoffset_hash, die); @@ -1007,7 +1025,6 @@ static void import(struct protolib *plib, struct library *lib, Dwfl *dwfl) bool import_DWARF_prototypes(struct library *lib) { struct protolib *plib = lib->protolib; - Dwfl *dwfl = lib->dwfl; debug(DEBUG_FUNCTION, "Importing DWARF prototypes from '%s'", lib->soname); @@ -1026,7 +1043,7 @@ bool import_DWARF_prototypes(struct library *lib) } } - import(plib, lib, dwfl); + import(plib, lib, lib->dwfl_module); lib->protolib = plib; return true;