public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* namespace and argument dependent name lookup (ADL) in gdb
@ 2007-12-13  3:39 Peng Yu
  2007-12-13  4:02 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2007-12-13  3:39 UTC (permalink / raw)
  To: gdb

Hi,

I don't have to write test::f in the following program because of
argument dependent name lookup.

http://en.wikipedia.org/wiki/Argument_dependent_name_lookup

But to debug such program, I have to write the namespace test. For example,
(gdb) tb f
Function "f" not defined.
(gdb) tb test::f
Breakpoint 1 at 0x804867c: file main.cc, line 11.

I'm wondering if gdb supports ADL. In a big program, it might not be
easy for me to find out which namespace is the function "f" in. If gdb
support ADL, it would save user a lot of time.

Thanks,
Peng

#include <iostream>

namespace test {

  struct A {
    A() : x(10) { }
    int x;
  };

  void f(const A &a) {
    std::cout << a.x << std::endl;
  }

}

int main(){
  test::A a;
  f(a);//do not have to write test::f
}

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

* Re: namespace and argument dependent name lookup (ADL) in gdb
  2007-12-13  3:39 namespace and argument dependent name lookup (ADL) in gdb Peng Yu
@ 2007-12-13  4:02 ` Daniel Jacobowitz
  2007-12-14 23:15   ` Peng Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-12-13  4:02 UTC (permalink / raw)
  To: Peng Yu; +Cc: gdb

On Wed, Dec 12, 2007 at 09:38:53PM -0600, Peng Yu wrote:
> Hi,
> 
> I don't have to write test::f in the following program because of
> argument dependent name lookup.
> 
> http://en.wikipedia.org/wiki/Argument_dependent_name_lookup
> 
> But to debug such program, I have to write the namespace test. For example,
> (gdb) tb f
> Function "f" not defined.
> (gdb) tb test::f
> Breakpoint 1 at 0x804867c: file main.cc, line 11.

That's not Koenig lookup.  There's no arguments.  If you were already
in the namespace 'test', GDB would search it.

> I'm wondering if gdb supports ADL. In a big program, it might not be
> easy for me to find out which namespace is the function "f" in. If gdb
> support ADL, it would save user a lot of time.

GDB supports some kinds of context-sensitive lookup, but not this one.
It is too complex to reconstruct the necessary information in the
debugger to do accurate name lookup.


-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: namespace and argument dependent name lookup (ADL) in gdb
  2007-12-13  4:02 ` Daniel Jacobowitz
@ 2007-12-14 23:15   ` Peng Yu
  2007-12-15  4:46     ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Yu @ 2007-12-14 23:15 UTC (permalink / raw)
  To: Peng Yu, gdb

On Dec 12, 2007 10:01 PM, Daniel Jacobowitz <drow@false.org> wrote:
> On Wed, Dec 12, 2007 at 09:38:53PM -0600, Peng Yu wrote:
> > Hi,
> >
> > I don't have to write test::f in the following program because of
> > argument dependent name lookup.
> >
> > http://en.wikipedia.org/wiki/Argument_dependent_name_lookup
> >
> > But to debug such program, I have to write the namespace test. For example,
> > (gdb) tb f
> > Function "f" not defined.
> > (gdb) tb test::f
> > Breakpoint 1 at 0x804867c: file main.cc, line 11.
>
> That's not Koenig lookup.  There's no arguments.

Why there is no argument? a is f's argument.

>  If you were already
> in the namespace 'test', GDB would search it.

What if I'm in the function body of "main"?

>
> > I'm wondering if gdb supports ADL. In a big program, it might not be
> > easy for me to find out which namespace is the function "f" in. If gdb
> > support ADL, it would save user a lot of time.
>
> GDB supports some kinds of context-sensitive lookup, but not this one.
> It is too complex to reconstruct the necessary information in the
> debugger to do accurate name lookup.

What is the best strategy to debug su

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

* Re: namespace and argument dependent name lookup (ADL) in gdb
  2007-12-14 23:15   ` Peng Yu
@ 2007-12-15  4:46     ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-12-15  4:46 UTC (permalink / raw)
  To: Peng Yu; +Cc: gdb

On Fri, Dec 14, 2007 at 05:15:06PM -0600, Peng Yu wrote:
> > > (gdb) tb test::f
> > > Breakpoint 1 at 0x804867c: file main.cc, line 11.
> >
> > That's not Koenig lookup.  There's no arguments.
> 
> Why there is no argument? a is f's argument.

You typed "tb f".  There's no a in that.  GDB only works from
what you type.

> >  If you were already
> > in the namespace 'test', GDB would search it.
> 
> What if I'm in the function body of "main"?

Then type "tb test::f".  You have to know where things are defined by
looking through the source.  You can also use "info function" to search.

-- 
Daniel Jacobowitz
CodeSourcery

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

end of thread, other threads:[~2007-12-15  4:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-13  3:39 namespace and argument dependent name lookup (ADL) in gdb Peng Yu
2007-12-13  4:02 ` Daniel Jacobowitz
2007-12-14 23:15   ` Peng Yu
2007-12-15  4:46     ` 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).