From 8283a0db67d305b19ffec0083db5884a03d0cfd7 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Wed, 9 Sep 2009 15:40:23 +0200 Subject: [PATCH] dwarflint: Used wrong formatter for DW_LNS_ opcodes * add the right formatter to dwarfstrings.[ch] --- src/ChangeLog | 6 ++++++ src/dwarflint.c | 2 +- src/dwarfstrings.c | 25 +++++++++++++++++++++++++ src/dwarfstrings.h | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 21aed9dd1..96826fb53 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -111,6 +111,12 @@ * dwarfcmp.cc (talker, noisy_cmp): Describe context mismatch details at the end. +2009-09-09 Petr Machata + + * 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 * dwarfcmp.cc (do_writer_test): New function, broken out of ... diff --git a/src/dwarflint.c b/src/dwarflint.c index c594c4418..2335887ff 100644 --- a/src/dwarflint.c +++ b/src/dwarflint.c @@ -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); diff --git a/src/dwarfstrings.c b/src/dwarfstrings.c index fdb3ede41..bfccece8d 100644 --- a/src/dwarfstrings.c +++ b/src/dwarfstrings.c @@ -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; +} diff --git a/src/dwarfstrings.h b/src/dwarfstrings.h index 77d63b390..a38c27481 100644 --- a/src/dwarfstrings.h +++ b/src/dwarfstrings.h @@ -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 -- 2.47.3