Debugging ROOT with GDB

 This page explains how to find the cause for a program abort, or any other unexpected behaviour of a program - where "a program" can be any of:

  • an interpreted ROOT macro
  • a library (compiled with Aclic or outside ROOT)
  • ROOT itself.

GDB only works with code built with GCC, i.e. on all unix flavored operating systems, but also on windows/cygwin, if ROOT was built as win32gcc - NOT win32 or win32gdk! If you try to debug a regular ROOT windows build with GDB you won't get anywhere - you've built it with Microsoft VC++, and you'll have to debug it with that, too.
 

Prerequisite: Debug Symbols

GDB will be able to debug whatever you pass it, but you'll only be able to interpret the result if GDB finds debug symbols in your code: file names, method names, line numbers, names of variables and parameters. In general you can get those symbols (which are added to the object files and make their way into the library or executable) by adding the -g switch to g++ (or gcc and ld if you call it by hand) - both during the compilation and linking stage. For compiled macros, you can tell ROOT to generate debug symbold by compiling them with .L myMacro.C++g.

When building ROOT from sources you can simply specify --build=debug when calling ./configure. You don'tneed a debug build of ROOT - only if you want to see the calls that come from (e.g. Cint calling your macro) or go into (e.g your macro calling TTree::Fill) ROOT a debug version will help. Well - my personal opinion: build your own ROOT debug version, with debug symbols. It often comes in handy, and it's quite simple to do.

http://www.muenster.de/~naumana/rootgdb.html