Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] Re: Re: Debugging C++ code/shlib in wxManta.py


Chronological Thread 
  • From: Abe Stephens < >
  • To:
  • Subject: [Manta] Re: Re: Debugging C++ code/shlib in wxManta.py
  • Date: Tue, 17 Jun 2008 13:01:13 -0600

I have the most luck with debugging via python by specifying source code lines too. It's a bit tricky because the target executable is python- so the files and symbols I want to debug aren't loaded until after python starts running. It's necessary to run python without any break points, then interrupt it at an arbitrary point, add the break points I want to test, and finally restart the program. For some reason setting pending breakpoints doesn't seem to work.

Typically a session on Mac looks something like this:

[metroliner:~/Manta/build-leopard] abe% gdb python

Debug the python executable.

GNU gdb 6.3.50-20050815 (Apple version gdb-768) (Tue Oct 2 04:07:49 UTC 2007)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"...Reading symbols for shared libraries ... done

(gdb) r ../SwigInterface/runwxmanta.py

Invoke the python script-


Starting program: /usr/bin/python ../SwigInterface/runwxmanta.py
Reading symbols for shared libraries ++. done

Program received signal SIGTRAP, Trace/breakpoint trap.
0x8fe01010 in __dyld__dyld_start ()
(gdb) c

This signal only gets sent on Mac.

Continuing.
Reading symbols for shared libraries . done
Reading symbols for shared libraries

Many, many more shared libraries are loaded...

Reading symbols for shared libraries .. done
^C

Send interrupt signal.

Program received signal SIGINT, Interrupt.
0x924b14a6 in mach_msg_trap ()
(gdb) b RTRT.cc:736
Breakpoint 1 at 0x2258d66: file /Users/abe/Manta/Engine/Control/ RTRT.cc, line 736.
Breakpoint 2 at 0x335a682: file /Users/abe/Manta/Engine/Control/ RTRT.cc, line 736.
warning: Multiple breakpoints were set.
Use the "delete" command to delete unwanted breakpoints.

Next add the breakpoints. I'm not sure why it adds multiple copies, it only hits breakpoint 2.

(gdb) R
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Restart the program from the beginning.

Starting program: /usr/bin/python ../SwigInterface/runwxmanta.py
;
Program received signal SIGTRAP, Trace/breakpoint trap.
0x8fe01010 in __dyld__dyld_start ()
(gdb) c
Continuing.
Reading symbols for shared libraries . done
Reading symbols for shared libraries . done
[Switching to process 4296 thread 0x5103]

Breakpoint 2, Manta::RTRT::internalRenderLoop (this=0x95a600, proc=0, lateComerFlag=false) at /Users/abe/Manta/Engine/Control/ RTRT.cc:736
736         barrier1.wait(workersRendering);
(gdb)


Finally you've hit the breakpoint.

Also note that you only have to go through this strange process of starting, stopping, then restarting, about once per debugging session- you can run make from inside the debugger (just make -sj2 on the command prompt), to avoid having to quit gdb and reassign all of the breakpoints.


Abe



On Jun 17, 2008, at 12:31 PM, James Bigler wrote:

gdb isn't good about stopping in breakpoints by function name.  Set
them using file:linenumber notation ( MyFile.cc:230 ).

Try adding "gdb --args" in front of the command used to run manta.
After gdb starts you can execute "run".

Another alternative is to see what the process number is and use the
"attach <PID>" after starting a plain gdb.

James

On Tue, Jun 17, 2008 at 10:19 AM, Li-Ta Lo 
< >
 wrote:
Hi,

What is the correct way to debug C++ code while running Manta as
a python script? I tried use "gdb /usr/bin/python" and
"b Manta:Somefunction". The breakpoint is reached but the program
is not stopped.

Ollie






Archive powered by MHonArc 2.6.16.

Top of page