dwarf_endianity_string for DW_END codes used with DW_AT_endianity.
dwarf_decimal_sign_string for DW_DS codes used with DW_AT_decimal_sign.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
+2012-08-11 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (libdw_a_SOURCES): Add dwarf_endianity_string.c and
+ dwarf_decimal_sign_string.c.
+ * dwarf_endianity_string.c: New file.
+ * dwarf_decimal_sign_string.c: New file.
+ * libdw.h: Declare dwarf_endianity_string and
+ dwarf_decimal_sign_string.
+ * libdw.map (ELFUTILS_0.155): Add dwarf_endianity_string and
+ dwarf_decimal_sign_string.
+
2012-07-27 Mark Wielaard <mjw@redhat.com>
* Makefile.am (libdw_a_SOURCES): Add dwarf_aggregate_size.c,
dwarf_encoding_string.c dwarf_locexpr_opcode_string.c \
dwarf_form_string.c dwarf_ordering_string.c \
dwarf_tag_string.c dwarf_virtuality_string.c \
- dwarf_identifier_case_string.c dwarf_visibility_string.c
+ dwarf_identifier_case_string.c dwarf_visibility_string.c \
+ dwarf_endianity_string.c dwarf_decimal_sign_string.c
if MAINTAINER_MODE
BUILT_SOURCES = $(srcdir)/known-dwarf.h
--- /dev/null
+/* Copyright (C) 2012 Red Hat, Inc.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stddef.h>
+
+#include "known-dwarf.h"
+#include "dwarf.h"
+
+const char *
+dwarf_decimal_sign_string (unsigned int code)
+{
+ static const char *const known[] =
+ {
+#define ONE_KNOWN_DW_DS(NAME, CODE) [CODE] = #NAME,
+ ALL_KNOWN_DW_DS
+#undef ONE_KNOWN_DW_DS
+ };
+
+ if (likely (code < sizeof (known) / sizeof (known[0])))
+ return known[code];
+
+ return NULL;
+}
--- /dev/null
+/* Copyright (C) 2012 Red Hat, Inc.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stddef.h>
+
+#include "known-dwarf.h"
+#include "dwarf.h"
+
+const char *
+dwarf_endianity_string (unsigned int code)
+{
+ static const char *const known[] =
+ {
+#define ONE_KNOWN_DW_END(NAME, CODE) [CODE] = #NAME,
+ ALL_KNOWN_DW_END
+#undef ONE_KNOWN_DW_END
+ };
+
+ if (likely (code < sizeof (known) / sizeof (known[0])))
+ return known[code];
+
+ return NULL;
+}
if known. Returns NULL if the given DW_LNE opcode is unknown. */
extern const char *dwarf_line_extended_opcode_string (unsigned int code);
+/* Returns the endianity name, without the DW_END_ prefix, as used in
+ the DW_AT_endianity attribute, if known. Returns NULL if the given
+ DW_END code is unknown. */
+extern const char *dwarf_endianity_string (unsigned int code);
+
+/* Returns the decimal sign name, without the DW_DS_ prefix, as used in
+ the DW_AT_decimal_sign attribute, if known. Returns NULL if the given
+ DW_DS code is unknown. */
+extern const char *dwarf_decimal_sign_string (unsigned int code);
+
/* Inline optimizations. */
#ifdef __OPTIMIZE__
dwarf_locexpr_opcode_string;
dwarf_line_standard_opcode_string;
dwarf_line_extended_opcode_string;
+ dwarf_endianity_string;
+ dwarf_decimal_sign_string;
} ELFUTILS_0.149;
+2012-08-11 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (dwarf_endianity_name): New function.
+ (dwarf_decimal_sign_string): Likewise.
+ (attr_callback): Use dwarf_endianity_name for DW_AT_endianity
+ and use dwarf_decimal_sign_string for DW_AT_decimal_sign.
+
2012-07-27 Mark Wielaard <mjw@redhat.com>
* readelf.c (dwarf_tag_string): Removed.
return result;
}
+static const char *
+dwarf_endianity_name (unsigned int code)
+{
+ const char *result = dwarf_endianity_string (code);
+ if (unlikely (result == NULL))
+ {
+ if (code >= DW_END_lo_user && code <= DW_END_hi_user)
+ snprintf (unknown_buf, sizeof unknown_buf, "lo_user+%#x",
+ code - DW_END_lo_user);
+ else
+ return "???"; /* Numeric value is always already printed. */
+ result = unknown_buf;
+ }
+ return result;
+}
+
+static const char *
+dwarf_decimal_sign_name (unsigned int code)
+{
+ const char *result = dwarf_decimal_sign_string (code);
+ if (unlikely (result == NULL))
+ result = "???"; /* Numeric value is always already printed. */
+ return result;
+}
static void
print_block (size_t n, const void *block)
case DW_AT_discr_list:
valuestr = dwarf_discr_list_name (num);
break;
+ case DW_AT_endianity:
+ valuestr = dwarf_endianity_name (num);
+ break;
+ case DW_AT_decimal_sign:
+ valuestr = dwarf_decimal_sign_name (num);
+ break;
default:
/* Nothing. */
break;