]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Used wrong formatter for DW_LNS_ opcodes
authorPetr Machata <pmachata@redhat.com>
Wed, 9 Sep 2009 13:40:23 +0000 (15:40 +0200)
committerPetr Machata <pmachata@redhat.com>
Wed, 18 Aug 2010 12:55:09 +0000 (14:55 +0200)
* add the right formatter to dwarfstrings.[ch]

src/ChangeLog
src/dwarflint.c
src/dwarfstrings.c
src/dwarfstrings.h

index 21aed9dd1e6c1f05d57abccb8ca4a725d8954dbd..96826fb5341eb1696df1eab3f92198f440e01c16 100644 (file)
        * dwarfcmp.cc (talker, noisy_cmp): Describe context mismatch details
        at the end.
 
+2009-09-09  Petr Machata  <pmachata@redhat.com>
+
+       * dwarfstrings.c (dwarf_line_standard_opcode_string): New function.
+       * dwarfstrings.h: Declare it.
+       * dwarflint.c (check_line_structural): Use it.
+
 2009-08-27  Roland McGrath  <roland@redhat.com>
 
        * dwarfcmp.cc (do_writer_test): New function, broken out of ...
index c594c44188f074d28172dfded81ed4c6634da5e4..2335887ffed30e970c5f5fb58c38bcde2c7b5159 100644 (file)
@@ -5161,7 +5161,7 @@ check_line_structural (struct elf_file *file,
              char buf[128];
              if (opcode != 0)
                sprintf (buf, "operand #%d of DW_LNS_%s",
-                        i, dwarf_locexpr_opcode_string (opcode));
+                        i, dwarf_line_standard_opcode_string (opcode));
              else
                sprintf (buf, "operand #%d of extended opcode %d",
                         i, extended);
index fdb3ede418fe1c1e9e59ce83f98b519b3fe00f25..bfccece8d6a831bde955af67139865d3ca6bad0c 100644 (file)
@@ -630,3 +630,28 @@ dwarf_locexpr_opcode_string (unsigned int code)
 
   return ret;
 }
+
+
+const char *
+dwarf_line_standard_opcode_string (unsigned int code)
+{
+  static const char *const known[] =
+    {
+#define ONE_KNOWN_DW_LNS(NAME, CODE) [CODE] = #NAME,
+      ALL_KNOWN_DW_LNS
+#undef 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;
+}
index 77d63b3908d2b4179482560394306deddb7f65c7..a38c274819de0c940d158c15408f26729b02d205 100644 (file)
@@ -34,6 +34,8 @@ 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);
+
 #ifdef __cplusplus
 }
 #endif