From: "Jordan Rupprecht via binutils" <binutils@sourceware.org>
Cc: binutils@sourceware.org, Jordan Rupprecht <rupprecht@google.com>
Subject: [PATCH] Demangle names when using --line-numbers --disassemble.
Date: Fri, 14 Feb 2020 20:15:00 -0000 [thread overview]
Message-ID: <20200214201441.146590-1-rupprecht@google.com> (raw)
This fixes the lack of demangling of names within interleaved disassembly, such as:
```
$ echo "namespace xyz { void foo(){} }" | g++ -x c++ -c - -o foo.o && objdump -ldC foo.o
...
Disassembly of section .text:
0000000000000000 <xyz::foo()>:
_ZN3xyz3fooEv():
0: 55 push %rbp
```
With this patch:
```
Disassembly of section .text:
0000000000000000 <xyz::foo()>:
xyz::foo():
0: 55 push %rbp
```
---
binutils/ChangeLog | 4 ++++
binutils/objdump.c | 16 +++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 06bbf5d6b7..8153160223 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2020-02-14 Jordan Rupprecht <rupprecht@google.com>
+
+ * objdump.c (show_line): call bfd_demangle when using do_demangle.
+
2020-02-10 Fangrui Song <maskray@google.com>
* objcopy.c (parse_flags): Handle "exclude".
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 8182dcc362..6eef38f0e2 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1734,8 +1734,22 @@ show_line (bfd *abfd, asection *section, bfd_vma addr_offset)
&& (prev_functionname == NULL
|| strcmp (functionname, prev_functionname) != 0))
{
- printf ("%s():\n", sanitize_string (functionname));
+ char *demangle_alloc = NULL;
+ if (do_demangle && functionname[0] != '\0')
+ {
+ /* Demangle the name. */
+ demangle_alloc = bfd_demangle (abfd, functionname,
+ demangle_flags);
+ }
+
+ /* Demangling adds trailing parens, so don't print those. */
+ if (demangle_alloc != NULL)
+ printf ("%s:\n", sanitize_string (demangle_alloc));
+ else
+ printf ("%s():\n", sanitize_string (functionname));
+
prev_line = -1;
+ free (demangle_alloc);
}
if (linenumber > 0
&& (linenumber != prev_line
--
2.25.0.265.gbab2e86ba0-goog
next reply other threads:[~2020-02-14 20:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-14 20:15 Jordan Rupprecht via binutils [this message]
2020-02-19 9:03 ` Alan Modra
2020-02-19 21:58 ` Eric Christopher
2020-02-19 22:55 ` Committing patches for other people Alan Modra
2020-02-19 23:35 ` Eric Christopher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200214201441.146590-1-rupprecht@google.com \
--to=binutils@sourceware.org \
--cc=rupprecht@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).