Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Frederic RISS <frederic.riss@st.com>
To: Michael Veksler <mveksler@techunix.technion.ac.il>
Cc: gdb@sourceware.org
Subject: Re: Get versioned minsyms from dynamic symtab (Was: Re:	How	to	call operator<< functions?)
Date: Thu, 31 Aug 2006 16:48:00 -0000	[thread overview]
Message-ID: <1157042884.3429.344.camel@crx549.cro.st.com> (raw)
In-Reply-To: <1157030582.3429.316.camel@crx549.cro.st.com>

On Thu, 2006-08-31 at 15:23 +0200, Frederic RISS wrote:
> On Thu, 2006-08-31 at 16:02 +0300, Michael Veksler wrote:
> > Take the two files from my test case in:
> >    http://sources.redhat.com/ml/gdb/2006-08/msg00271.html
> > [...]
> > (gdb) p x.Print(std::cout)
> > Enter B::Print() this=0xbfffec00
> > $1 = void
> > (gdb) p x.Print(myCout)
> > Cannot resolve method B::Print to any overloaded instance
> > (gdb) p x.Print(std::cout)
> > Cannot resolve method B::Print to any overloaded instance
> > (gdb)
> > ==============
> > What is going on here. Why the second Print(std::cout) no longer works?
> > Let's try to rerun without exiting GDB:
> 
> Sorry, I can't reproduce that... this is working fine here. 

In fact I managed to reproduce this behavour using a libstdc++ compiled
without debug information. What's happening is quite strange, and it
might very well be a GCC bug and not a GDB one.

What happens is that you get 2 definitions of std::cout in the debug
information of your example. One definition for each file. The gotcha is
that neither of these definitions are complete. They're just empty
shells specifying that the symbol is of type 
``typedef  basic_ostream<char,std::char_traits<char> >  std::ostream''
without giving a clue to the debugger what this type is made of.
I think GCC should emit a complete type because you use std::ostream in
each of your files.

The first 'p x.Print(std::cout)' works because at this point, the
debugger has only read the full debug information of the first file.
This file contains a definition of std::cout and the definition of
B::Print which both point to the same instance of the std::ostream type.
Being the same instance, even if the type is incomplete GDB resolves the
overload correctly.
After you've referenced 'myCout' which is defined in the second file,
the debug info of the latter has been read, bringing a second definition
of std::cout in the global scope. This second definition is found by
further lookups of this symbol, and this time, the symbol type isn't the
same instance as before. GDB tries to compare to incomplete types and of
course it fails...

I thought that using -feliminate-dwarf2-dups would help, but it doesn't.

One thing we could do is to compare the TYPE_TAG_NAME for overload
resoltion if there's no type name. During my tests, it was set to
'std::basic_ostream<char,std::char_traits<char> >' but I've read some
comments stating that it shouldn't be used. Or maybe the bug is that we
don't fill TYPE_NAME with that information?



  reply	other threads:[~2006-08-31 16:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-30 10:11 How to call operator<< functions? Michael Veksler
2006-08-30 11:13 ` Frederic RISS
2006-08-30 13:30   ` Frederic RISS
2006-08-30 13:40     ` Breakpoint Handling in GDB Veenu Verma (AS/EAB)
2006-08-30 13:43       ` Daniel Jacobowitz
2006-08-30 20:30       ` Michael Snyder
2006-08-31 11:34     ` Get versioned minsyms from dynamic symtab (Was: Re: How to call operator<< functions?) Frederic RISS
2006-08-31 12:09       ` Michael Veksler
2006-08-31 12:26         ` Frederic RISS
2006-08-31 13:02           ` Michael Veksler
2006-08-31 13:23             ` Frederic RISS
2006-08-31 16:48               ` Frederic RISS [this message]
2006-08-31 16:57                 ` Daniel Jacobowitz
2006-08-31 17:41                   ` Frédéric Riss
2006-08-31 17:45                     ` Daniel Jacobowitz
2006-08-31 19:48                   ` Michael Veksler
2006-08-31 19:52                     ` Daniel Jacobowitz
2006-08-30 12:46 ` How to call operator<< functions? Daniel Jacobowitz
2006-08-30 20:05   ` Michael Veksler
2006-08-30 20:24     ` Daniel Jacobowitz
2006-08-30 20:45       ` Michael Veksler
2006-08-30 20:54         ` Daniel Jacobowitz
2006-08-31 12:05           ` Michael Veksler

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=1157042884.3429.344.camel@crx549.cro.st.com \
    --to=frederic.riss@st.com \
    --cc=gdb@sourceware.org \
    --cc=mveksler@techunix.technion.ac.il \
    /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