Debugging root with gdb

From Etp
Jump to: navigation, search

This is a short description on how to debug a compiled script in root with gdb. It assumes you know how to Debug with gdb

What you do Shell 1 Shell 2
We first have to find the process pid of the root session root

Start your root session

Then get the pid of the running root session ps -ax | grep root

Then look for something like /software/cernlib/gcc-4.4/root_v5.28.00-patches-37583/bin/root.exe -splash, the pid is the number on the left column

Connect gdb to your root session. This will halt the root session gdb -pid $pid

Where $pid is the pid you found in the previous step

Now we set a breakpoint break D3PDSelector.C:170

As D3PDSelector.C is not yet loaded, he will ask if you want to create a breakpoint for a future, library.. answer Y

Continue the execution of the root cont

Continues the execution of root until the breakpoint is reached..

Start the execution of your script .x runSelector.C+g

the flag +g tells root to compile with debugging information. If you have a script that compiles your code (like the runSelector.C) you have to add the +g there as well

Debug You can watch the output of your rootfile in this shell And use the familiar commands like next, step, print, break in the debugging shell