dwarf_lang_string was different from all other dwarf_foobar_string functions. It used to return a description of the language, not the actual string of the DW_LANG language code. Added a new function dwarf_lang_description that does this and make dwarf_lang_string return the same thing as all other dwarf_foobar_string functions.
Signed-off-by: Mark Wielaard <[email protected]> --- libdw/ChangeLog | 6 ++++++ libdw/dwarfstrings.c | 35 +++++++++++++++++++++++++++++++++++ src/ChangeLog | 4 ++++ src/readelf.c | 6 +++--- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 6abbcd4..5becf01 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,9 @@ +2012-07-24 Mark Wielaard <[email protected]> + + * dwarfstrings.c (dwarf_lang_string): Return just the DW_LANG name. + (dwarf_lang_description): New function, returns the language + description that dwarf_lang_string used to return. + 2012-07-17 Mark Wielaard <[email protected]> * Makefile.am (libdw_a_SOURCES): Add dwarfstrings.c. diff --git a/libdw/dwarfstrings.c b/libdw/dwarfstrings.c index 81ba054..bfd6176 100644 --- a/libdw/dwarfstrings.c +++ b/libdw/dwarfstrings.c @@ -497,6 +497,41 @@ dwarf_lang_string (unsigned int lang) { static const char *const known[] = { + [DW_LANG_C89] = "C89", + [DW_LANG_C] = "C", + [DW_LANG_Ada83] = "Ada83", + [DW_LANG_C_plus_plus] = "C_plus_plus", + [DW_LANG_Cobol74] = "Cobol74", + [DW_LANG_Cobol85] = "Cobol85", + [DW_LANG_Fortran77] = "Fortran77", + [DW_LANG_Fortran90] = "Fortran90", + [DW_LANG_Pascal83] = "Pascal83", + [DW_LANG_Modula2] = "Modula2", + [DW_LANG_Java] = "Java", + [DW_LANG_C99] = "C99", + [DW_LANG_Ada95] = "Ada95", + [DW_LANG_Fortran95] = "Fortran95", + [DW_LANG_PL1] = "PL1", + [DW_LANG_Objc] = "ObjC", + [DW_LANG_ObjC_plus_plus] = "ObjC_plus_plus", + [DW_LANG_UPC] = "UPC", + [DW_LANG_D] = "D", + [DW_LANG_Go] = "Go", + }; + + if (likely (lang < sizeof (known) / sizeof (known[0]))) + return known[lang]; + else if (lang == DW_LANG_Mips_Assembler) + return "Mips_Assembler"; + + return NULL; +} + +const char * +dwarf_lang_description (unsigned int lang) +{ + static const char *const known[] = + { [DW_LANG_C89] = "ISO C89", [DW_LANG_C] = "C", [DW_LANG_Ada83] = "Ada83", diff --git a/src/ChangeLog b/src/ChangeLog index 120249e..31eb350 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2012-07-24 Mark Wielaard <[email protected]> + + * readelf.c (dwarf_lang_name): Use dwarf_lang_description. + 2012-07-17 Mark Wielaard <[email protected]> * readelf.c (dwarf_tag_name): Renamed from dwarf_tag_string. diff --git a/src/readelf.c b/src/readelf.c index 48bd7a0..a0f1b33 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -3228,11 +3228,11 @@ dwarf_form_name (unsigned int form) static const char * dwarf_lang_name (unsigned int lang) { - const char *result = dwarf_lang_string (lang); + const char *result = dwarf_lang_description (lang); if (unlikely (result == NULL)) { - static char buf[25]; - snprintf (buf, sizeof buf, "unknown_lang_%#x", lang); + static char buf[29]; + snprintf (buf, sizeof buf, "Unknown Language %#x", lang); result = buf; } return result; -- 1.7.11.2 _______________________________________________ elfutils-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/elfutils-devel
