public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Re: Failed breakpoint for C++ in gdb
@ 2005-07-28 21:13 Alain Magloire
  2005-07-28 21:16 ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Alain Magloire @ 2005-07-28 21:13 UTC (permalink / raw)
  To: gdb

From Daniel:
>On Tue, Jul 26, 2005 at 09:31:10AM -0400, Alain Magloire wrote:
>> Why is gdb so fussy about the argument order ?
>
> GDB generally matches the compiler-generated debug info.  There's a
> long-term plan to be more forgiving about this, but it's hard to
> implement that without slowing down symbol reading...
> 
> > (gdb) b foo(const char *)
> > Function "foo(const char *)" not defined
> > (gdb) b foo(char const *)
> > Breakpoint 1 at 0x....... file testing.cpp line 4.
> > 
> > So is there something I should do ? Do I have to reorder my arguments to
> put
> > the const last ?
> 
> Is this for command line use?  Try: b 'foo<TAB>

Niet, for front-end.

Is the "const char *" vs. "char const *" example consistent in GDB i.e. can
I assume this and do some mangling on my own to satisfy the pickiness of
GDB?

^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: Failed breakpoint for C++ in gdb
@ 2005-07-29 15:20 Alain Magloire
  2005-07-29 15:29 ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Alain Magloire @ 2005-07-29 15:20 UTC (permalink / raw)
  To: gdb



> 
> It's completely at the whim of the compiler.  Whatever strings the
> compiler has put in the debug information, those are the ones GDB will
> use in symbol names.  It varies between GCC versions; I believe it also
> varies between formats.
> 

And the good news kept coming ;-(

On the same topic:

void String::check(int i) const
{
	if (i<0 || rep->sz<=i) throw Range();
}

int main() { ... }


(gdb) b String::check(int) const
Function "String::check(int)" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) b "String::check(int) const"
Function "String::check(int)" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) b 'String::check(int) const'
Breakpoint 1 at 0x4015bc: file 100992.cpp, line 150.

I'm curious to know why ("") double quotes are not working, but single quote
seems to do the job.  This is particular disturbing in the MI protocol where
it is clearly stated options/arguments containing spaces must be surrounded
with double quotes.

Anyway just curious, this was sent by the folks from MontaVista 8-). It is
too late for the front to deal with it, but for the next version, is this PR
(bugzilla/gnats) material?

^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: Failed breakpoint for C++ in gdb
@ 2005-07-28 21:39 Alain Magloire
  2005-07-28 21:44 ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Alain Magloire @ 2005-07-28 21:39 UTC (permalink / raw)
  To: gdb



> >
> > Is the "const char *" vs. "char const *" example consistent in GDB i.e.
> can
> > I assume this and do some mangling on my own to satisfy the pickiness of
> > GDB?
> 
> This is not GDB's pickiness.

Agreed, but for the user, with code source like this foobar(const char *p);
and then having the debugger insisting on only accepting foobar(char const
*p) for breakpoint is ... heu ... bizarre.

> It is following whatever the compiler has
> specified in debug information.  You could still query GDB for the
> overloads in some fashion, I expect, but I don't know for sure.
>

That may not be possible (the query) for the front-end.  Let me ask you
rephrase the question, is this behavior dependent of the type of debug info?
i.e. if I use dwarf-2 vs. stabs++, GDB will not refuse "char const *" I can
work around this if the behavior is consistent.

Anyway, thanks for the feedback.
 

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Failed breakpoint for C++ in gdb
@ 2005-07-26 13:31 Alain Magloire
  2005-07-26 14:01 ` Daniel Jacobowitz
  0 siblings, 1 reply; 8+ messages in thread
From: Alain Magloire @ 2005-07-26 13:31 UTC (permalink / raw)
  To: gdb

Why is gdb so fussy about the argument order ?

For example:
int foo(const char *p) {
  int i = 0;
  i++;
  return i;
}

int foo() {
  int y = 0;
   y += 2;
  return y;
}

int main(int argc, char **argv) {
  Const char *p = "foobar";
  foo(p);
  foo();
  Return 0;
}

(gdb) b foo(const char *)
Function "foo(const char *)" not defined
(gdb) b foo(char const *)
Breakpoint 1 at 0x....... file testing.cpp line 4.

So is there something I should do ? Do I have to reorder my arguments to put
the const last ?
??

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-07-29 15:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-28 21:13 Failed breakpoint for C++ in gdb Alain Magloire
2005-07-28 21:16 ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2005-07-29 15:20 Alain Magloire
2005-07-29 15:29 ` Daniel Jacobowitz
2005-07-28 21:39 Alain Magloire
2005-07-28 21:44 ` Daniel Jacobowitz
2005-07-26 13:31 Alain Magloire
2005-07-26 14:01 ` Daniel Jacobowitz

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).