public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org>,
	gdb-patches@sourceware.org
Cc: Bruno Larsen <blarsen@redhat.com>
Subject: Re: [PATCH 2/2] gdb/testsuite: fix running gdb.linespec/cp-completion-aliases.exp with clang
Date: Fri, 03 Feb 2023 15:49:08 +0000	[thread overview]
Message-ID: <877cwysqa3.fsf@redhat.com> (raw)
In-Reply-To: <87a61usw1t.fsf@redhat.com>

Andrew Burgess <aburgess@redhat.com> writes:

> Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org> writes:
>
>> Currently, all important tests in gdb.linespec/cp-completion-aliases.exp
>> are failing when using clang because the wrong type is being suggested
>> for the completion.  For example, running with gcc and clang we get the
>> following output respectively:
>>
>> (gdb) break get_value(object_p) <- gcc version
>> (gdb) break get_value(object*)  <- clang version
>
> You are correct that what we print for Clang is not wrong.  But I don't
> think it's as correct as what we print for GCC.  The user wrote
> object_p, and the DWARF does encode the object_p for both versions.
> It's just in the Clang case there's an extra DW_AT_linkage_name which
> seems to send GDB off doing the "wrong" thing.
>
> I wonder how hard it would actually be to "fix" this so that we print
> object_p for Clang?  I think it would be helpful to really understand at
> which point we diverge when comparing Clang and GCC binaries.

The diff below fixes this issue for the specific test that you were
editing.  I've not tested this at all beyond that one test.  But I
wonder if something like this makes sense?

What's happening is that when we read the DWARF we end up calling
dwarf2_physname to figure out the name of the symbol.  If the DIE has a
linkage name then we just demangle that, and use that as the symbol
name.

But, at least for C++ I don't think that makes sense.  We know that the
demangled name will have stripped any typedefs.  While the computed name
will better reflect what's actually written in the code.

We already have something similar in place for Rust (commit
906bb4c58faa).

Anyway, just and idea...

Thanks,
Andrew


---

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index ee4e7c1530a..00c46197e3c 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9133,7 +9133,7 @@ dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu)
   if (!die_needs_namespace (die, cu))
     return dwarf2_compute_name (name, die, cu, 1);
 
-  if (cu->lang () != language_rust)
+  if (cu->lang () != language_rust && cu->lang () != language_cplus)
     mangled = dw2_linkage_name (die, cu);
 
   /* DW_AT_linkage_name is missing in some cases - depend on what GDB


  reply	other threads:[~2023-02-03 15:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 13:00 [PATCH 0/2] Fix testing gdb.linespec/cp-completion-aliases with Bruno Larsen
2023-01-17 13:00 ` [PATCH 1/2] gdb/testsuite: add test with regex for multiple completion patterns Bruno Larsen
2023-01-17 13:00 ` [PATCH 2/2] gdb/testsuite: fix running gdb.linespec/cp-completion-aliases.exp with clang Bruno Larsen
2023-02-03 13:44   ` Andrew Burgess
2023-02-03 15:49     ` Andrew Burgess [this message]
2023-02-06 14:10     ` Bruno Larsen
2023-02-06 15:48       ` Andrew Burgess
2023-02-03  8:04 ` [PING][PATCH 0/2] Fix testing gdb.linespec/cp-completion-aliases with Bruno Larsen

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=877cwysqa3.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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).