Using GDB with root on lxplus

I can’t seem to be able to interract with any root classes while debugging with gdb on lxplus.

I’ve attached a test program. extract and type make with ROOTSYS pointing to a root installation directory.

Then do:

gdb ./test
br test.cpp:19
run

Then, when the program breaks, try to inspect the variable ‘test_hist’

print test_hist

gives:

(gdb) print test_hist
No symbol “test_hist” in current context.

In fact, any variable in that program which is from root somehow doesn’t exist.

I’ve made sure that the libraries in my ROOTSYS are not stripped.

file output showing that the libraries are not stripped: file_libHist.so.txt (173 Bytes)
ldd output showing that my test executable is linking to the correct libraries: ldd_test.txt (2.49 KB)

My output is gdb_output.txt (1.18 KB)
The example is root_gdb_test.tgz (14.1 KB)

Can someone help me figure out how to get something like test_hist.fXaxis.fXmin to work?

I just tried your example on Mac using lldb. it is fine:

   19  	
-> 20  		printf("B\n");
   21  		TRandom* R = new TRandom();
   22  		printf("C\n");
   23  	
(lldb) print test_hist
(TH2D *) $0 = 0x0000000103f5e680

Can you make gdb work on lxplus with a simple program not using ROOT ?

Okay, thanks for your response.

I’ve made a simple test program. simple_gdb_test.tgz (396 Bytes)

If you do

gdb ./simple
br simple.cpp:19
print TestClass

You should get information about TestClass.

When I run with my typical environment, I get simple_gdb_test_output.txt (1.1 KB)

However, working out this example has led me to discover one of my problems.
See, I’ve been trying to use gcc 4.8 lately. I’ve been sourcing /afs/cern.ch/sw/lcg/contrib/gcc/4.8.1/x86_64-slc6-gcc48-opt/setup.sh
To get gcc 4.8.

So, removing all traces of gcc 4.8 from my PATH and LD_LIBRARY_PATH,
I get for the simple test: simple_gdb_test_output_2.txt (1.14 KB)
I get for the root test: gdb_output_2.txt (1.33 KB)

This eliminates one problem, in that now gdb knows about simple classes, However: If you look at ptype test_hist, you can see get that class TH2D is an incomplete type! This is no good, since I need to inspect members of root classes as my program executes.

So now, there are two questions:
1.) Why won’t the lxplus version of gdb work with gcc 4.8? What can I do to make it work?
2.) Why doesn’t gdb have a full definition of TH2D?

[quote] 1.) Why won’t the lxplus version of gdb work with gcc 4.8? What can I do to make it work?
[/quote]
No idea.

Shouldn’t ROOT be compiled in debug mode to do that ?

Okay, so I reproduced the problem on my personal machine which is running ubuntu 14.10.

However, it seems that I didn’t build root with debugging correctly. I forgot to run make distclean.

After using make distclean and then building with --build=debug, I was able to get the correct result with gdb.

I was apparently mistaken to believe that if file says that a library is ‘not striped’ that means it has debugging symbols.

Thanks for your help couet.