This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
gdb problem with 'malloc' in unnamed namespace
- From: Andrà PÃnitz <apoenitz at trolltech dot com>
- To: gdb at sources dot redhat dot com
- Date: Tue, 5 Aug 2008 14:07:13 +0200
- Subject: gdb problem with 'malloc' in unnamed namespace
Hi all.
Thanks to Andreas Schwab I have now a pretty minimal example
that makes me think that gdb has a problem with handling a
function called "malloc" in the unnamed namespace:
echo 'namespace { void malloc(int, int) {} } int main() {}' | g++ -xc++ -g -
gdb -batch -ex 'b main' -ex 'r' -ex 'p "xxx"' ./a.out
yields:
Breakpoint 1 at 0x400548: file <stdin>, line 1.
Breakpoint 1, main () at <stdin>:1
1 <stdin>: No such file or directory.
in <stdin>
Current language: auto; currently c++
too few arguments in function call
So the 'malloc' from the debugged program is picked up by gdb, even if the
symbol name ("_ZN29_GLOBAL__N__00000000_271D34D06mallocEv") does
not match.
Note that the case of too few argument, the error message is
slightly more useful as it mentions at least 'malloc':
echo 'namespace { void malloc() {} } int main() {}' | g++ -xc++ -g -
gdb -batch -ex 'b main' -ex 'r' -ex 'p "xxx"' ./a.out
yields:
Breakpoint 1 at 0x400542: file <stdin>, line 1.
Breakpoint 1, main () at <stdin>:1
1 <stdin>: No such file or directory.
in <stdin>
Current language: auto; currently c++
No memory available to program: call to malloc failed
What can I do from the user side to inform gdb that it should
not use the malloc from the anon namespace?
AndrÃ