]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Add files needed by c++ module from dwarf branch.
authorDjordje Todorovic <djordje.todorovic@rt-rk.com>
Tue, 26 Sep 2017 13:15:44 +0000 (15:15 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 6 Oct 2017 19:38:38 +0000 (21:38 +0200)
* src/dwarf-opcodes.h: Return back the file.
* src/dwarfstrings.c: Likewise.
* src/dwarfstrings.h: Likewise.

Signed-off-by: Djordje Todorovic <djordje.todorovic@rt-rk.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
src/Makefile.am
src/dwarf-opcodes.h [new file with mode: 0644]
src/dwarfstrings.c [new file with mode: 0644]
src/dwarfstrings.h [new file with mode: 0644]

index 2b1c0dcbc824934a787df71a67d9ce01cccf0964..bd1cd0e0db326b3b46c19cb7f606a99b5dde056c 100644 (file)
@@ -32,7 +32,10 @@ noinst_LIBRARIES = libar.a
 
 libar_a_SOURCES = arlib.c arlib2.c arlib-argp.c
 
-EXTRA_DIST = arlib.h debugpred.h
+# XXX dwarf-opcodes and dwarfstrings are only used in dwarflint
+EXTRA_DIST = arlib.h debugpred.h \
+       dwarf-opcodes.h dwarfstrings.c dwarfstrings.h
+
 
 bin_SCRIPTS = make-debug-archive
 EXTRA_DIST += make-debug-archive.in
diff --git a/src/dwarf-opcodes.h b/src/dwarf-opcodes.h
new file mode 100644 (file)
index 0000000..dc644d4
--- /dev/null
@@ -0,0 +1,198 @@
+/* dwarf-opcodes
+   Copyright (C) 2009-2011 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/>.  */
+
+#define DW_OP_OPERANDS                                         \
+  DW_OP_1 (DW_OP_addr, DW_FORM_addr)                           \
+  DW_OP_0 (DW_OP_deref)                                                \
+  DW_OP_0 (DW_OP_xderef)                                       \
+  DW_OP_1 (DW_OP_deref_size, DW_FORM_data1)                    \
+  DW_OP_1 (DW_OP_xderef_size, DW_FORM_data1)                   \
+  DW_OP_1 (DW_OP_const1u, DW_FORM_data1)                       \
+  DW_OP_1 (DW_OP_const1s, DW_FORM_data1)                       \
+  DW_OP_1 (DW_OP_const2u, DW_FORM_data2)                       \
+  DW_OP_1 (DW_OP_const2s, DW_FORM_data2)                       \
+  DW_OP_1 (DW_OP_const4u, DW_FORM_data4)                       \
+  DW_OP_1 (DW_OP_const4s, DW_FORM_data4)                       \
+  DW_OP_1 (DW_OP_const8u, DW_FORM_data8)                       \
+  DW_OP_1 (DW_OP_const8s, DW_FORM_data8)                       \
+  DW_OP_1 (DW_OP_constu, DW_FORM_udata)                                \
+  DW_OP_1 (DW_OP_consts, DW_FORM_sdata)                                \
+  DW_OP_0 (DW_OP_dup)                                          \
+  DW_OP_0 (DW_OP_drop)                                         \
+  DW_OP_0 (DW_OP_over)                                         \
+  DW_OP_1 (DW_OP_pick, DW_FORM_data1)                          \
+  DW_OP_0 (DW_OP_swap)                                         \
+  DW_OP_0 (DW_OP_rot)                                          \
+  DW_OP_0 (DW_OP_abs)                                          \
+  DW_OP_0 (DW_OP_and)                                          \
+  DW_OP_0 (DW_OP_div)                                          \
+  DW_OP_0 (DW_OP_minus)                                                \
+  DW_OP_0 (DW_OP_mod)                                          \
+  DW_OP_0 (DW_OP_mul)                                          \
+  DW_OP_0 (DW_OP_neg)                                          \
+  DW_OP_0 (DW_OP_not)                                          \
+  DW_OP_0 (DW_OP_or)                                           \
+  DW_OP_0 (DW_OP_plus)                                         \
+  DW_OP_1 (DW_OP_plus_uconst, DW_FORM_udata)                   \
+  DW_OP_0 (DW_OP_shl)                                          \
+  DW_OP_0 (DW_OP_shr)                                          \
+  DW_OP_0 (DW_OP_shra)                                         \
+  DW_OP_0 (DW_OP_xor)                                          \
+  DW_OP_1 (DW_OP_bra, DW_FORM_data2)                           \
+  DW_OP_0 (DW_OP_eq)                                           \
+  DW_OP_0 (DW_OP_ge)                                           \
+  DW_OP_0 (DW_OP_gt)                                           \
+  DW_OP_0 (DW_OP_le)                                           \
+  DW_OP_0 (DW_OP_lt)                                           \
+  DW_OP_0 (DW_OP_ne)                                           \
+  DW_OP_1 (DW_OP_skip, DW_FORM_data2)                          \
+  DW_OP_0 (DW_OP_lit0)                                         \
+  DW_OP_0 (DW_OP_lit1)                                         \
+  DW_OP_0 (DW_OP_lit2)                                         \
+  DW_OP_0 (DW_OP_lit3)                                         \
+  DW_OP_0 (DW_OP_lit4)                                         \
+  DW_OP_0 (DW_OP_lit5)                                         \
+  DW_OP_0 (DW_OP_lit6)                                         \
+  DW_OP_0 (DW_OP_lit7)                                         \
+  DW_OP_0 (DW_OP_lit8)                                         \
+  DW_OP_0 (DW_OP_lit9)                                         \
+  DW_OP_0 (DW_OP_lit10)                                                \
+  DW_OP_0 (DW_OP_lit11)                                                \
+  DW_OP_0 (DW_OP_lit12)                                                \
+  DW_OP_0 (DW_OP_lit13)                                                \
+  DW_OP_0 (DW_OP_lit14)                                                \
+  DW_OP_0 (DW_OP_lit15)                                                \
+  DW_OP_0 (DW_OP_lit16)                                                \
+  DW_OP_0 (DW_OP_lit17)                                                \
+  DW_OP_0 (DW_OP_lit18)                                                \
+  DW_OP_0 (DW_OP_lit19)                                                \
+  DW_OP_0 (DW_OP_lit20)                                                \
+  DW_OP_0 (DW_OP_lit21)                                                \
+  DW_OP_0 (DW_OP_lit22)                                                \
+  DW_OP_0 (DW_OP_lit23)                                                \
+  DW_OP_0 (DW_OP_lit24)                                                \
+  DW_OP_0 (DW_OP_lit25)                                                \
+  DW_OP_0 (DW_OP_lit26)                                                \
+  DW_OP_0 (DW_OP_lit27)                                                \
+  DW_OP_0 (DW_OP_lit28)                                                \
+  DW_OP_0 (DW_OP_lit29)                                                \
+  DW_OP_0 (DW_OP_lit30)                                                \
+  DW_OP_0 (DW_OP_lit31)                                                \
+  DW_OP_0 (DW_OP_reg0)                                         \
+  DW_OP_0 (DW_OP_reg1)                                         \
+  DW_OP_0 (DW_OP_reg2)                                         \
+  DW_OP_0 (DW_OP_reg3)                                         \
+  DW_OP_0 (DW_OP_reg4)                                         \
+  DW_OP_0 (DW_OP_reg5)                                         \
+  DW_OP_0 (DW_OP_reg6)                                         \
+  DW_OP_0 (DW_OP_reg7)                                         \
+  DW_OP_0 (DW_OP_reg8)                                         \
+  DW_OP_0 (DW_OP_reg9)                                         \
+  DW_OP_0 (DW_OP_reg10)                                                \
+  DW_OP_0 (DW_OP_reg11)                                                \
+  DW_OP_0 (DW_OP_reg12)                                                \
+  DW_OP_0 (DW_OP_reg13)                                                \
+  DW_OP_0 (DW_OP_reg14)                                                \
+  DW_OP_0 (DW_OP_reg15)                                                \
+  DW_OP_0 (DW_OP_reg16)                                                \
+  DW_OP_0 (DW_OP_reg17)                                                \
+  DW_OP_0 (DW_OP_reg18)                                                \
+  DW_OP_0 (DW_OP_reg19)                                                \
+  DW_OP_0 (DW_OP_reg20)                                                \
+  DW_OP_0 (DW_OP_reg21)                                                \
+  DW_OP_0 (DW_OP_reg22)                                                \
+  DW_OP_0 (DW_OP_reg23)                                                \
+  DW_OP_0 (DW_OP_reg24)                                                \
+  DW_OP_0 (DW_OP_reg25)                                                \
+  DW_OP_0 (DW_OP_reg26)                                                \
+  DW_OP_0 (DW_OP_reg27)                                                \
+  DW_OP_0 (DW_OP_reg28)                                                \
+  DW_OP_0 (DW_OP_reg29)                                                \
+  DW_OP_0 (DW_OP_reg30)                                                \
+  DW_OP_0 (DW_OP_reg31)                                                \
+  DW_OP_1 (DW_OP_breg0, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg1, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg2, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg3, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg4, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg5, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg6, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg7, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg8, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg9, DW_FORM_sdata)                         \
+  DW_OP_1 (DW_OP_breg10, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg11, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg12, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg13, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg14, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg15, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg16, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg17, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg18, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg19, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg20, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg21, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg22, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg23, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg24, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg25, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg26, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg27, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg28, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg29, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg30, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_breg31, DW_FORM_sdata)                                \
+  DW_OP_1 (DW_OP_regx, DW_FORM_udata)                          \
+  DW_OP_1 (DW_OP_fbreg, DW_FORM_sdata)                         \
+  DW_OP_2 (DW_OP_bregx, DW_FORM_udata, DW_FORM_sdata)          \
+  DW_OP_1 (DW_OP_piece, DW_FORM_udata)                         \
+  DW_OP_0 (DW_OP_nop)                                          \
+  DW_OP_0 (DW_OP_push_object_address)                          \
+  DW_OP_1 (DW_OP_call2, DW_FORM_data2)                         \
+  DW_OP_1 (DW_OP_call4, DW_FORM_data4)                         \
+  DW_OP_1 (DW_OP_call_ref, DW_FORM_ref_addr)                   \
+  DW_OP_0 (DW_OP_form_tls_address)                             \
+  DW_OP_0 (DW_OP_GNU_push_tls_address)                         \
+  DW_OP_0 (DW_OP_call_frame_cfa)                               \
+  DW_OP_2 (DW_OP_bit_piece, DW_FORM_udata, DW_FORM_udata)      \
+  DW_OP_0 (DW_OP_GNU_uninit)                                   \
+  /* DWARF 4 */                                                        \
+  DW_OP_0 (DW_OP_stack_value)                                  \
+  DW_OP_1 (DW_OP_implicit_value, DW_FORM_block)                        \
+  /* GNU extensions */                                         \
+  DW_OP_2 (DW_OP_GNU_implicit_pointer, DW_FORM_ref_addr, DW_FORM_sdata) \
+  /* GNU variant for tracking of values passed as arguments to functions.  */ \
+  /* http://www.dwarfstd.org/ShowIssue.php?issue=100909.1 */   \
+  DW_OP_1 (DW_OP_GNU_entry_value, DW_FORM_block)               \
+  /* The GNU typed stack extension.  */                                \
+  /* See http://www.dwarfstd.org/doc/040408.1.html */          \
+  DW_OP_2 (DW_OP_GNU_const_type, DW_FORM_udata, DW_FORM_block1)        \
+  DW_OP_2 (DW_OP_GNU_regval_type, DW_FORM_udata, DW_FORM_udata)        \
+  DW_OP_2 (DW_OP_GNU_deref_type, DW_FORM_data1, DW_FORM_udata) \
+  DW_OP_1 (DW_OP_GNU_convert, DW_FORM_udata)                   \
+  DW_OP_1 (DW_OP_GNU_reinterpret, DW_FORM_udata)
diff --git a/src/dwarfstrings.c b/src/dwarfstrings.c
new file mode 100644 (file)
index 0000000..1df1f6d
--- /dev/null
@@ -0,0 +1,817 @@
+/* Copyright (C) 1999-2011 Red Hat, Inc.
+   This file is part of elfutils.
+   Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+   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 "../libdw/known-dwarf.h"
+#include "../libdw/dwarf.h"
+#include "dwarfstrings.h"
+#include <inttypes.h>
+#include <stdio.h>
+#include <libintl.h>
+
+const char *
+dwarf_tag_string (unsigned int tag)
+{
+  static const char *const known_tags[]  =
+    {
+      [DW_TAG_array_type] = "array_type",
+      [DW_TAG_class_type] = "class_type",
+      [DW_TAG_entry_point] = "entry_point",
+      [DW_TAG_enumeration_type] = "enumeration_type",
+      [DW_TAG_formal_parameter] = "formal_parameter",
+      [DW_TAG_imported_declaration] = "imported_declaration",
+      [DW_TAG_label] = "label",
+      [DW_TAG_lexical_block] = "lexical_block",
+      [DW_TAG_member] = "member",
+      [DW_TAG_pointer_type] = "pointer_type",
+      [DW_TAG_reference_type] = "reference_type",
+      [DW_TAG_compile_unit] = "compile_unit",
+      [DW_TAG_string_type] = "string_type",
+      [DW_TAG_structure_type] = "structure_type",
+      [DW_TAG_subroutine_type] = "subroutine_type",
+      [DW_TAG_typedef] = "typedef",
+      [DW_TAG_union_type] = "union_type",
+      [DW_TAG_unspecified_parameters] = "unspecified_parameters",
+      [DW_TAG_variant] = "variant",
+      [DW_TAG_common_block] = "common_block",
+      [DW_TAG_common_inclusion] = "common_inclusion",
+      [DW_TAG_inheritance] = "inheritance",
+      [DW_TAG_inlined_subroutine] = "inlined_subroutine",
+      [DW_TAG_module] = "module",
+      [DW_TAG_ptr_to_member_type] = "ptr_to_member_type",
+      [DW_TAG_set_type] = "set_type",
+      [DW_TAG_subrange_type] = "subrange_type",
+      [DW_TAG_with_stmt] = "with_stmt",
+      [DW_TAG_access_declaration] = "access_declaration",
+      [DW_TAG_base_type] = "base_type",
+      [DW_TAG_catch_block] = "catch_block",
+      [DW_TAG_const_type] = "const_type",
+      [DW_TAG_constant] = "constant",
+      [DW_TAG_enumerator] = "enumerator",
+      [DW_TAG_file_type] = "file_type",
+      [DW_TAG_friend] = "friend",
+      [DW_TAG_namelist] = "namelist",
+      [DW_TAG_namelist_item] = "namelist_item",
+      [DW_TAG_packed_type] = "packed_type",
+      [DW_TAG_subprogram] = "subprogram",
+      [DW_TAG_template_type_parameter] = "template_type_parameter",
+      [DW_TAG_template_value_parameter] = "template_value_parameter",
+      [DW_TAG_thrown_type] = "thrown_type",
+      [DW_TAG_try_block] = "try_block",
+      [DW_TAG_variant_part] = "variant_part",
+      [DW_TAG_variable] = "variable",
+      [DW_TAG_volatile_type] = "volatile_type",
+      [DW_TAG_dwarf_procedure] = "dwarf_procedure",
+      [DW_TAG_restrict_type] = "restrict_type",
+      [DW_TAG_interface_type] = "interface_type",
+      [DW_TAG_namespace] = "namespace",
+      [DW_TAG_imported_module] = "imported_module",
+      [DW_TAG_unspecified_type] = "unspecified_type",
+      [DW_TAG_partial_unit] = "partial_unit",
+      [DW_TAG_imported_unit] = "imported_unit",
+      [DW_TAG_mutable_type] = "mutable_type",
+      [DW_TAG_condition] = "condition",
+      [DW_TAG_shared_type] = "shared_type",
+      [DW_TAG_type_unit] = "type_unit",
+      [DW_TAG_rvalue_reference_type] = "rvalue_reference_type",
+      [DW_TAG_template_alias] = "template_alias",
+    };
+  const unsigned int nknown_tags = (sizeof (known_tags)
+                                   / sizeof (known_tags[0]));
+  static char buf[40];
+  const char *result = NULL;
+
+  if (likely (tag < nknown_tags))
+    result = known_tags[tag];
+
+  if (unlikely (result == NULL))
+    /* There are a few known extensions.  */
+    switch (tag)
+      {
+      case DW_TAG_MIPS_loop:
+       result = "MIPS_loop";
+       break;
+
+      case DW_TAG_format_label:
+       result = "format_label";
+       break;
+
+      case DW_TAG_function_template:
+       result = "function_template";
+       break;
+
+      case DW_TAG_class_template:
+       result = "class_template";
+       break;
+
+      case DW_TAG_GNU_BINCL:
+       result = "GNU_BINCL";
+       break;
+
+      case DW_TAG_GNU_EINCL:
+       result = "GNU_EINCL";
+       break;
+
+      case DW_TAG_GNU_template_template_param:
+       result = "GNU_template_template_param";
+       break;
+
+      case DW_TAG_GNU_template_parameter_pack:
+       result = "GNU_template_parameter_pack";
+       break;
+
+      case DW_TAG_GNU_formal_parameter_pack:
+       result = "GNU_formal_parameter_pack";
+       break;
+
+      case DW_TAG_GNU_call_site:
+       result = "GNU_call_site";
+       break;
+
+      case DW_TAG_GNU_call_site_parameter:
+       result = "GNU_call_site_parameter";
+       break;
+
+      default:
+       if (tag < DW_TAG_lo_user)
+         snprintf (buf, sizeof buf, gettext ("unknown tag %hx"), tag);
+       else
+         snprintf (buf, sizeof buf, gettext ("unknown user tag %hx"), tag);
+       result = buf;
+       break;
+      }
+
+  return result;
+}
+
+
+const char *
+dwarf_attr_string (unsigned int attrnum)
+{
+  static const char *const known_attrs[] =
+    {
+      [DW_AT_sibling] = "sibling",
+      [DW_AT_location] = "location",
+      [DW_AT_name] = "name",
+      [DW_AT_ordering] = "ordering",
+      [DW_AT_subscr_data] = "subscr_data",
+      [DW_AT_byte_size] = "byte_size",
+      [DW_AT_bit_offset] = "bit_offset",
+      [DW_AT_bit_size] = "bit_size",
+      [DW_AT_element_list] = "element_list",
+      [DW_AT_stmt_list] = "stmt_list",
+      [DW_AT_low_pc] = "low_pc",
+      [DW_AT_high_pc] = "high_pc",
+      [DW_AT_language] = "language",
+      [DW_AT_member] = "member",
+      [DW_AT_discr] = "discr",
+      [DW_AT_discr_value] = "discr_value",
+      [DW_AT_visibility] = "visibility",
+      [DW_AT_import] = "import",
+      [DW_AT_string_length] = "string_length",
+      [DW_AT_common_reference] = "common_reference",
+      [DW_AT_comp_dir] = "comp_dir",
+      [DW_AT_const_value] = "const_value",
+      [DW_AT_containing_type] = "containing_type",
+      [DW_AT_default_value] = "default_value",
+      [DW_AT_inline] = "inline",
+      [DW_AT_is_optional] = "is_optional",
+      [DW_AT_lower_bound] = "lower_bound",
+      [DW_AT_producer] = "producer",
+      [DW_AT_prototyped] = "prototyped",
+      [DW_AT_return_addr] = "return_addr",
+      [DW_AT_start_scope] = "start_scope",
+      [DW_AT_bit_stride] = "bit_stride",
+      [DW_AT_upper_bound] = "upper_bound",
+      [DW_AT_abstract_origin] = "abstract_origin",
+      [DW_AT_accessibility] = "accessibility",
+      [DW_AT_address_class] = "address_class",
+      [DW_AT_artificial] = "artificial",
+      [DW_AT_base_types] = "base_types",
+      [DW_AT_calling_convention] = "calling_convention",
+      [DW_AT_count] = "count",
+      [DW_AT_data_member_location] = "data_member_location",
+      [DW_AT_decl_column] = "decl_column",
+      [DW_AT_decl_file] = "decl_file",
+      [DW_AT_decl_line] = "decl_line",
+      [DW_AT_declaration] = "declaration",
+      [DW_AT_discr_list] = "discr_list",
+      [DW_AT_encoding] = "encoding",
+      [DW_AT_external] = "external",
+      [DW_AT_frame_base] = "frame_base",
+      [DW_AT_friend] = "friend",
+      [DW_AT_identifier_case] = "identifier_case",
+      [DW_AT_macro_info] = "macro_info",
+      [DW_AT_namelist_item] = "namelist_item",
+      [DW_AT_priority] = "priority",
+      [DW_AT_segment] = "segment",
+      [DW_AT_specification] = "specification",
+      [DW_AT_static_link] = "static_link",
+      [DW_AT_type] = "type",
+      [DW_AT_use_location] = "use_location",
+      [DW_AT_variable_parameter] = "variable_parameter",
+      [DW_AT_virtuality] = "virtuality",
+      [DW_AT_vtable_elem_location] = "vtable_elem_location",
+      [DW_AT_allocated] = "allocated",
+      [DW_AT_associated] = "associated",
+      [DW_AT_data_location] = "data_location",
+      [DW_AT_byte_stride] = "byte_stride",
+      [DW_AT_entry_pc] = "entry_pc",
+      [DW_AT_use_UTF8] = "use_UTF8",
+      [DW_AT_extension] = "extension",
+      [DW_AT_ranges] = "ranges",
+      [DW_AT_trampoline] = "trampoline",
+      [DW_AT_call_column] = "call_column",
+      [DW_AT_call_file] = "call_file",
+      [DW_AT_call_line] = "call_line",
+      [DW_AT_description] = "description",
+      [DW_AT_binary_scale] = "binary_scale",
+      [DW_AT_decimal_scale] = "decimal_scale",
+      [DW_AT_small] = "small",
+      [DW_AT_decimal_sign] = "decimal_sign",
+      [DW_AT_digit_count] = "digit_count",
+      [DW_AT_picture_string] = "picture_string",
+      [DW_AT_mutable] = "mutable",
+      [DW_AT_threads_scaled] = "threads_scaled",
+      [DW_AT_explicit] = "explicit",
+      [DW_AT_object_pointer] = "object_pointer",
+      [DW_AT_endianity] = "endianity",
+      [DW_AT_elemental] = "elemental",
+      [DW_AT_pure] = "pure",
+      [DW_AT_recursive] = "recursive",
+      [DW_AT_signature] = "signature",
+      [DW_AT_main_subprogram] = "main_subprogram",
+      [DW_AT_data_bit_offset] = "data_bit_offset",
+      [DW_AT_const_expr] = "const_expr",
+      [DW_AT_enum_class] = "enum_class",
+      [DW_AT_linkage_name] = "linkage_name",
+    };
+  const unsigned int nknown_attrs = (sizeof (known_attrs)
+                                    / sizeof (known_attrs[0]));
+  static char buf[40];
+  const char *result = NULL;
+
+  if (likely (attrnum < nknown_attrs))
+    result = known_attrs[attrnum];
+
+  if (unlikely (result == NULL))
+    /* There are a few known extensions.  */
+    switch (attrnum)
+      {
+      case DW_AT_MIPS_fde:
+       result = "MIPS_fde";
+       break;
+
+      case DW_AT_MIPS_loop_begin:
+       result = "MIPS_loop_begin";
+       break;
+
+      case DW_AT_MIPS_tail_loop_begin:
+       result = "MIPS_tail_loop_begin";
+       break;
+
+      case DW_AT_MIPS_epilog_begin:
+       result = "MIPS_epilog_begin";
+       break;
+
+      case DW_AT_MIPS_loop_unroll_factor:
+       result = "MIPS_loop_unroll_factor";
+       break;
+
+      case DW_AT_MIPS_software_pipeline_depth:
+       result = "MIPS_software_pipeline_depth";
+       break;
+
+      case DW_AT_MIPS_linkage_name:
+       result = "MIPS_linkage_name";
+       break;
+
+      case DW_AT_MIPS_stride:
+       result = "MIPS_stride";
+       break;
+
+      case DW_AT_MIPS_abstract_name:
+       result = "MIPS_abstract_name";
+       break;
+
+      case DW_AT_MIPS_clone_origin:
+       result = "MIPS_clone_origin";
+       break;
+
+      case DW_AT_MIPS_has_inlines:
+       result = "MIPS_has_inlines";
+       break;
+
+      case DW_AT_MIPS_stride_byte:
+       result = "MIPS_stride_byte";
+       break;
+
+      case DW_AT_MIPS_stride_elem:
+       result = "MIPS_stride_elem";
+       break;
+
+      case DW_AT_MIPS_ptr_dopetype:
+       result = "MIPS_ptr_dopetype";
+       break;
+
+      case DW_AT_MIPS_allocatable_dopetype:
+       result = "MIPS_allocatable_dopetype";
+       break;
+
+      case DW_AT_MIPS_assumed_shape_dopetype:
+       result = "MIPS_assumed_shape_dopetype";
+       break;
+
+      case DW_AT_MIPS_assumed_size:
+       result = "MIPS_assumed_size";
+       break;
+
+      case DW_AT_sf_names:
+       result = "sf_names";
+       break;
+
+      case DW_AT_src_info:
+       result = "src_info";
+       break;
+
+      case DW_AT_mac_info:
+       result = "mac_info";
+       break;
+
+      case DW_AT_src_coords:
+       result = "src_coords";
+       break;
+
+      case DW_AT_body_begin:
+       result = "body_begin";
+       break;
+
+      case DW_AT_body_end:
+       result = "body_end";
+       break;
+
+      case DW_AT_GNU_vector:
+       result = "GNU_vector";
+       break;
+
+      case DW_AT_GNU_guarded_by:
+       result = "GNU_guarded_by";
+       break;
+
+      case DW_AT_GNU_pt_guarded_by:
+       result = "GNU_pt_guarded_by";
+       break;
+
+      case DW_AT_GNU_guarded:
+       result = "GNU_guarded";
+       break;
+
+      case DW_AT_GNU_pt_guarded:
+       result = "GNU_pt_guarded";
+       break;
+
+      case DW_AT_GNU_locks_excluded:
+       result = "GNU_locks_excluded";
+       break;
+
+      case DW_AT_GNU_exclusive_locks_required:
+       result = "GNU_exclusive_locks_required";
+       break;
+
+      case DW_AT_GNU_shared_locks_required:
+       result = "GNU_shared_locks_required";
+       break;
+
+      case DW_AT_GNU_odr_signature:
+       result = "GNU_odr_signature";
+       break;
+
+      case DW_AT_GNU_template_name:
+       result = "GNU_template_name";
+       break;
+
+      case DW_AT_GNU_call_site_value:
+       result = "GNU_call_site_value";
+       break;
+
+      case DW_AT_GNU_call_site_data_value:
+       result = "GNU_call_site_data_value";
+       break;
+
+      case DW_AT_GNU_call_site_target:
+       result = "GNU_call_site_target";
+       break;
+
+      case DW_AT_GNU_call_site_target_clobbered:
+       result = "GNU_call_site_target_clobbered";
+       break;
+
+      case DW_AT_GNU_tail_call:
+       result = "GNU_tail_call";
+       break;
+
+      case DW_AT_GNU_all_tail_call_sites:
+       result = "GNU_all_tail_call_sites";
+       break;
+
+      case DW_AT_GNU_all_call_sites:
+       result = "GNU_all_call_sites";
+       break;
+
+      case DW_AT_GNU_all_source_call_sites:
+       result = "GNU_all_source_call_sites";
+       break;
+
+      default:
+       if (attrnum < DW_AT_lo_user)
+         snprintf (buf, sizeof buf, gettext ("unknown attribute %hx"),
+                   attrnum);
+       else
+         snprintf (buf, sizeof buf, gettext ("unknown user attribute %hx"),
+                   attrnum);
+       result = buf;
+       break;
+      }
+
+  return result;
+}
+
+
+const char *
+dwarf_form_string (unsigned int form)
+{
+  static const char *const known_forms[] =
+    {
+      [DW_FORM_addr] = "addr",
+      [DW_FORM_block2] = "block2",
+      [DW_FORM_block4] = "block4",
+      [DW_FORM_data2] = "data2",
+      [DW_FORM_data4] = "data4",
+      [DW_FORM_data8] = "data8",
+      [DW_FORM_string] = "string",
+      [DW_FORM_block] = "block",
+      [DW_FORM_block1] = "block1",
+      [DW_FORM_data1] = "data1",
+      [DW_FORM_flag] = "flag",
+      [DW_FORM_sdata] = "sdata",
+      [DW_FORM_strp] = "strp",
+      [DW_FORM_udata] = "udata",
+      [DW_FORM_ref_addr] = "ref_addr",
+      [DW_FORM_ref1] = "ref1",
+      [DW_FORM_ref2] = "ref2",
+      [DW_FORM_ref4] = "ref4",
+      [DW_FORM_ref8] = "ref8",
+      [DW_FORM_ref_udata] = "ref_udata",
+      [DW_FORM_indirect] = "indirect",
+      [DW_FORM_sec_offset] = "sec_offset",
+      [DW_FORM_exprloc] = "exprloc",
+      [DW_FORM_flag_present] = "flag_present",
+      [DW_FORM_ref_sig8] = "ref_sig8",
+    };
+  const unsigned int nknown_forms = (sizeof (known_forms)
+                                    / sizeof (known_forms[0]));
+  static char buf[40];
+  const char *result = NULL;
+
+  if (likely (form < nknown_forms))
+    result = known_forms[form];
+
+  if (unlikely (result == NULL))
+    {
+      snprintf (buf, sizeof buf, gettext ("unknown form %#" PRIx64),
+               (uint64_t) form);
+      result = buf;
+    }
+
+  return result;
+}
+
+
+const char *
+dwarf_lang_string (unsigned int lang)
+{
+  static const char *const known[] =
+    {
+      [DW_LANG_C89] = "ISO C89",
+      [DW_LANG_C] = "C",
+      [DW_LANG_Ada83] = "Ada83",
+      [DW_LANG_C_plus_plus] = "C++",
+      [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] = "ISO C99",
+      [DW_LANG_Ada95] = "Ada95",
+      [DW_LANG_Fortran95] = "Fortran95",
+      [DW_LANG_PL1] = "PL1",
+      [DW_LANG_ObjC] = "Objective C",
+      [DW_LANG_ObjC_plus_plus] = "Objective C++",
+      [DW_LANG_UPC] = "UPC",
+      [DW_LANG_D] = "D",
+    };
+
+  if (likely (lang < sizeof (known) / sizeof (known[0])))
+    return known[lang];
+  else if (lang == DW_LANG_Mips_Assembler)
+    /* This language tag is used for assembler in general.  */
+    return "Assembler";
+
+  if (lang >= DW_LANG_lo_user && lang <= DW_LANG_hi_user)
+    {
+      static char buf[30];
+      snprintf (buf, sizeof (buf), "lo_user+%u", lang - DW_LANG_lo_user);
+      return buf;
+    }
+
+  return "???";
+}
+
+
+const char *
+dwarf_inline_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_INL_not_inlined] = "not_inlined",
+      [DW_INL_inlined] = "inlined",
+      [DW_INL_declared_not_inlined] = "declared_not_inlined",
+      [DW_INL_declared_inlined] = "declared_inlined"
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  return "???";
+}
+
+
+const char *
+dwarf_encoding_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_ATE_void] = "void",
+      [DW_ATE_address] = "address",
+      [DW_ATE_boolean] = "boolean",
+      [DW_ATE_complex_float] = "complex_float",
+      [DW_ATE_float] = "float",
+      [DW_ATE_signed] = "signed",
+      [DW_ATE_signed_char] = "signed_char",
+      [DW_ATE_unsigned] = "unsigned",
+      [DW_ATE_unsigned_char] = "unsigned_char",
+      [DW_ATE_imaginary_float] = "imaginary_float",
+      [DW_ATE_packed_decimal] = "packed_decimal",
+      [DW_ATE_numeric_string] = "numeric_string",
+      [DW_ATE_edited] = "edited",
+      [DW_ATE_signed_fixed] = "signed_fixed",
+      [DW_ATE_unsigned_fixed] = "unsigned_fixed",
+      [DW_ATE_decimal_float] = "decimal_float",
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  if (code >= DW_ATE_lo_user && code <= DW_ATE_hi_user)
+    {
+      static char buf[30];
+      snprintf (buf, sizeof (buf), "lo_user+%u", code - DW_ATE_lo_user);
+      return buf;
+    }
+
+  return "???";
+}
+
+
+const char *
+dwarf_access_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_ACCESS_public] = "public",
+      [DW_ACCESS_protected] = "protected",
+      [DW_ACCESS_private] = "private"
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  return "???";
+}
+
+
+const char *
+dwarf_visibility_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_VIS_local] = "local",
+      [DW_VIS_exported] = "exported",
+      [DW_VIS_qualified] = "qualified"
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  return "???";
+}
+
+
+const char *
+dwarf_virtuality_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_VIRTUALITY_none] = "none",
+      [DW_VIRTUALITY_virtual] = "virtual",
+      [DW_VIRTUALITY_pure_virtual] = "pure_virtual"
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  return "???";
+}
+
+
+const char *
+dwarf_identifier_case_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_ID_case_sensitive] = "sensitive",
+      [DW_ID_up_case] = "up_case",
+      [DW_ID_down_case] = "down_case",
+      [DW_ID_case_insensitive] = "insensitive"
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  return "???";
+}
+
+
+const char *
+dwarf_calling_convention_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_CC_normal] = "normal",
+      [DW_CC_program] = "program",
+      [DW_CC_nocall] = "nocall",
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  if (code >= DW_CC_lo_user && code <= DW_CC_hi_user)
+    {
+      static char buf[30];
+      snprintf (buf, sizeof (buf), "lo_user+%u", code - DW_CC_lo_user);
+      return buf;
+    }
+
+  return "???";
+}
+
+
+const char *
+dwarf_ordering_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_ORD_row_major] = "row_major",
+      [DW_ORD_col_major] = "col_major"
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  return "???";
+}
+
+
+const char *
+dwarf_discr_list_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      [DW_DSC_label] = "label",
+      [DW_DSC_range] = "range"
+    };
+
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    return known[code];
+
+  return "???";
+}
+
+
+const char *
+dwarf_locexpr_opcode_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+      /* Normally we can't affort building huge table of 64K entries,
+        most of them zero, just because there are a couple defined
+        values at the far end.  In case of opcodes, it's OK.  */
+#define DWARF_ONE_KNOWN_DW_OP_DESC(NAME, CODE, DESC) DWARF_ONE_KNOWN_DW_OP(NAME, CODE)
+#define DWARF_ONE_KNOWN_DW_OP(NAME, CODE) [CODE] = #NAME,
+      DWARF_ALL_KNOWN_DW_OP
+#undef DWARF_ONE_KNOWN_DW_OP
+#undef DWARF_ONE_KNOWN_DW_OP_DESC
+    };
+
+  const char *ret = NULL;
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    ret = known[code];
+
+  if (ret == NULL)
+    {
+      static char buf[40];
+      snprintf (buf, sizeof buf, gettext ("unknown opcode %" PRIx64),
+               (uint64_t) code);
+      ret = buf;
+    }
+
+  return ret;
+}
+
+const char *
+dwarf_line_standard_opcode_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+#define DWARF_ONE_KNOWN_DW_LNS(NAME, CODE) [CODE] = #NAME,
+      DWARF_ALL_KNOWN_DW_LNS
+#undef DWARF_ONE_KNOWN_DW_LNS
+    };
+
+  const char *ret = NULL;
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    ret = known[code];
+
+  if (ret == NULL)
+    {
+      static char buf[40];
+      snprintf (buf, sizeof buf, gettext ("unknown opcode %x"), code);
+      ret = buf;
+    }
+
+  return ret;
+}
+
+const char *
+dwarf_line_extended_opcode_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+#define DWARF_ONE_KNOWN_DW_LNE(NAME, CODE) [CODE] = #NAME,
+      DWARF_ALL_KNOWN_DW_LNE
+#undef DWARF_ONE_KNOWN_DW_LNE
+    };
+
+  const char *ret = NULL;
+  if (likely (code < sizeof (known) / sizeof (known[0])))
+    ret = known[code];
+
+  if (ret == NULL)
+    {
+      static char buf[40];
+      snprintf (buf, sizeof buf, gettext ("unknown opcode %x"), code);
+      ret = buf;
+    }
+
+  return ret;
+}
diff --git a/src/dwarfstrings.h b/src/dwarfstrings.h
new file mode 100644 (file)
index 0000000..a466665
--- /dev/null
@@ -0,0 +1,73 @@
+/* Copyright (C) 1999-2011 Red Hat, Inc.
+   This file is part of elfutils.
+   Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+   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/>.  */
+
+#ifndef DWARFSTRINGS_H
+#define DWARFSTRINGS_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+const char *dwarf_tag_string (unsigned int tag);
+
+const char *dwarf_attr_string (unsigned int attrnum);
+
+const char *dwarf_form_string (unsigned int form);
+
+const char *dwarf_lang_string (unsigned int lang);
+
+const char *dwarf_inline_string (unsigned int code);
+
+const char *dwarf_encoding_string (unsigned int code);
+
+const char *dwarf_access_string (unsigned int code);
+
+const char *dwarf_visibility_string (unsigned int code);
+
+const char *dwarf_virtuality_string (unsigned int code);
+
+const char *dwarf_identifier_case_string (unsigned int code);
+
+const char *dwarf_calling_convention_string (unsigned int code);
+
+const char *dwarf_ordering_string (unsigned int code);
+
+const char *dwarf_discr_list_string (unsigned int code);
+
+const char *dwarf_locexpr_opcode_string (unsigned int code);
+
+const char *dwarf_line_standard_opcode_string (unsigned int code);
+
+const char *dwarf_line_extended_opcode_string (unsigned int code);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* dwarfstrings.h */