]> 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, 9 Sep 2009 13:40:23 +0000 (15:40 +0200)
* add the right formatter to dwarfstrings.[ch]

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

index a201b1709adead617521e2deb6f6262ee655f5f5..517fad622c722d9464901b222802303c2ebde110 100644 (file)
@@ -1,3 +1,9 @@
+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 b1df4b84769a49abaade9048665f53a3b4f347dc..6c585bed269513b970f589f4c1b851cace578a9e 100644 (file)
@@ -5171,7 +5171,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 f25e83acb5ae10f55ee048c72289178606cecd91..46f9d4b25d3a0abebf57e0a0a6722fc66fde6b0e 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