This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Print .debug_names augmentation as a string
- From: Tom Tromey <tromey at adacore dot com>
- To: binutils at sourceware dot org
- Cc: Tom Tromey <tromey at adacore dot com>
- Date: Thu, 11 Jul 2019 11:00:26 -0600
- Subject: [PATCH] Print .debug_names augmentation as a string
The DWARF 5 .debug_names section includes an "augmentation string"
that can be used to identify the producer. While this string is just
arbitrary data, in practice the two producers I know of (gdb and
clang) use an ASCII string here.
This patch changes display_debug_names to display the augmentation as
a string when possible. This makes it a bit simpler to see what
producer created the section.
With the patch the output for a gdb-created section now looks like
this:
Augmentation string: 47 44 42 00 ("GDB")
Tested on x86-64 Fedora 29. Ok?
binutils/ChangeLog
2019-07-11 Tom Tromey <tromey@adacore.com>
* dwarf.c (display_debug_names): Print augmentation string as
string when possible.
---
binutils/ChangeLog | 5 +++++
binutils/dwarf.c | 17 +++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index f86e20db40f..fcfb9550a70 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -30,6 +30,7 @@
#include "gdb/gdb-index.h"
#include "filenames.h"
#include <assert.h>
+#include "safe-ctype.h"
#undef MAX
#undef MIN
@@ -8544,6 +8545,8 @@ display_debug_names (struct dwarf_section *section, void *file)
uint32_t augmentation_string_size;
unsigned int i;
unsigned long sec_off;
+ int augmentation_printable;
+ const char *augmentation_string;
unit_start = hdrptr;
@@ -8608,12 +8611,26 @@ display_debug_names (struct dwarf_section *section, void *file)
augmentation_string_size += (-augmentation_string_size) & 3;
}
printf (_("Augmentation string:"));
+ augmentation_printable = 1;
+ augmentation_string = (const char *) hdrptr;
for (i = 0; i < augmentation_string_size; i++)
{
unsigned char uc;
SAFE_BYTE_GET_AND_INC (uc, hdrptr, 1, unit_end);
printf (" %02x", uc);
+
+ if (uc != 0 && !ISPRINT (uc))
+ augmentation_printable = 0;
+ }
+ if (augmentation_printable)
+ {
+ printf (" (\"");
+ for (i = 0;
+ i < augmentation_string_size && augmentation_string[i];
+ ++i)
+ putchar (augmentation_string[i]);
+ printf ("\")");
}
putchar ('\n');
putchar ('\n');
--
2.20.1