Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Keith Seitz <keiths@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] 12266 Fallout
Date: Fri, 26 Aug 2011 18:31:00 -0000	[thread overview]
Message-ID: <20110826183108.GA25559@host1.jankratochvil.net> (raw)
In-Reply-To: <4E56D4A3.7000306@redhat.com>

On Fri, 26 Aug 2011 01:02:59 +0200, Keith Seitz wrote:
> The reporter's test case (C++):
> 
> typedef std::string foo;
> void calltest (foo) {}
> 
> Setting a break at "calltest(foo)" does not work because
> inspect_type (part of 12266 patchset) uses check_typedef, which
> resolves foo -> std::string -> std::basic_string<char,
> std::char_traits<char>, std::alloactor<char> >. But because we are
> no longer using DMGL_VERBOSE in dwarf2_physname (and other places)
> to do demangling, the symbol table actually stores
> "calltest(std::string)".

check_typedef always unwinds only the toplevel typedefs, not any inner ones.

I think you should move the comparison block

  /* Ignore any typedefs that should not be substituted.  */
  for (i = 0; i < ARRAY_SIZE (ignore_typedefs); ++i)
    {
      if (strcmp (name, ignore_typedefs[i]) == 0)
	return 0;
    }

into the later comparisons:

              /* Find the last typedef for the type.  */
              while (TYPE_TARGET_TYPE (last) != NULL
                     && (TYPE_CODE (TYPE_TARGET_TYPE (last))
                         == TYPE_CODE_TYPEDEF))
                last = TYPE_TARGET_TYPE (last);

and it would get properly caught, wouldn't be?


> There are two ways I can see to fix this.
> 1) Add DMGL_VERBOSE where it is needed so that NO typedefs ever
> appear in a (non-TYPE_CODE_TYPEDEF) symbol's name, i.e, store
> "calltest(std::basic_string<...>)" in the symbol table instead of
> "calltest(std::string)".
> Actually in this case, the "right" output would be "calltest(foo)",
> but that is a different, but related, problem, for which I developed
> a patch a long time ago, part of the first 12266 patch submissions
> (dwarf2_print_name).

As I stated off-list before I agree the primary goal is to make working
`break func(any_form_of_types)'.

And as also Tom said when there is the possibility to print the DWARF type
- incl. typedefs - it should be also printed as was implemented in:

But if you just lookup the minimal (ELF) symbol - where the dwarf2_print_name
form cannot apply - by:
(gdb) info sym 0x0000003f1b25ed70

I guess it should say:
std::hash<std::string>::operator()(std::string) const in section .text of /usr/lib64/libstdc++.so.6

and not:
std::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::operator()(std::basic_string<char, std::char_traits<char>, std::allocator<char> >) const
in section .text of /usr/lib64/libstdc++.so.6

while nm -C says:
0000003f1b25ed70 T std::hash<std::string>::operator()(std::string) const


IMO if GDB starts to use DMGL_VERBOSE we should ask binutils to use
DMGL_VERBOSE for `nm -C' and other tools there.


> So, I humbly ask maintainers:
> 
> - Shall I continue #1 and start submitting patches?
> - Shall I start teaching gdb about std::string et al and how to deal
> with them in the environment we have today?
> - Have I missed something that would be preferable to anything I've
> mentioned?

I would prefer to keep `std::string' to be `std::string' as possible, which
I naively believe could be done without modifying/duplicating check_typedef by
the change suggested above.


Thanks,
Jan


      parent reply	other threads:[~2011-08-26 18:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 23:03 Keith Seitz
2011-08-26 18:05 ` Tom Tromey
2011-08-26 18:17   ` Keith Seitz
2011-08-26 18:31 ` Jan Kratochvil [this message]

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=20110826183108.GA25559@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.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