Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* gdb problem with  'malloc' in unnamed namespace
@ 2008-08-05 12:05 André Pönitz
  2008-08-05 12:13 ` Daniel Jacobowitz
  2008-08-05 12:40 ` Andreas Schwab
  0 siblings, 2 replies; 4+ messages in thread
From: André Pönitz @ 2008-08-05 12:05 UTC (permalink / raw)
  To: gdb


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é 


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

end of thread, other threads:[~2008-08-05 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-05 12:05 gdb problem with 'malloc' in unnamed namespace André Pönitz
2008-08-05 12:13 ` Daniel Jacobowitz
2008-08-05 12:40 ` Andreas Schwab
2008-08-05 12:56   ` André Pönitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox