|
List Info
Thread: namespace and argument dependent name lookup (ADL) in gdb
|
|
| namespace and argument dependent name
lookup (ADL) in gdb |

|
2007-12-12 21:38:53 |
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
}
|
|
| Re: namespace and argument dependent
name lookup (ADL) in gdb |
  United States |
2007-12-12 22:01:29 |
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
|
|
| Re: namespace and argument dependent
name lookup (ADL) in gdb |

|
2007-12-14 17:15:06 |
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
|
|
| Re: namespace and argument dependent
name lookup (ADL) in gdb |
  United States |
2007-12-14 22:46:37 |
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
|
|
[1-4]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|