Gdb not working with compiled root program

Hello all,

I am having problems debuging my compiled root applications. I am using the clang compiler to compile my application which uses root via cmake with debug flags on. Using cling is no alternative in this case.
My minimal code is without includes etc. is:

int main(int argc, char** argv)
{
  process_cmd_line(argc, argv);
  
  // ... some more stuff...

  TApplication app("app", &argc, argv);
  gStyle->SetImageScaling(3.);
  TCanvas c("c", "c", 1024, 768);

  // more stuff
}

Gdb is working and accepting break points just to the moment were TApplication is created. From this point on the gdb prompt is not working anymore and I am forced to kill gdb and my application.

Hope anybody can help me.


ROOT Version: 6.14
Platform: Ubuntu 14.04
Compiler: clang 5.02


Is ROOT itself compiled with debug symbols? Also, are you sure your code is not entering an infinite loop somewhere?

Hi,
I tried to reproduce your problem with the little snippet below, but everything worked fine.
As @amadio says you could double-check that you are compiling with -g and -O0 (debug symbols and optimizations). Also, if you are calling app.Run() somewhere, that’s starting an infinite loop as part of its job, but you can interrupt it with a ctrl-C from the terminal where gdb is running.

Cheers,
Enrico

#include <TApplication.h>

int foo(int a) { return a*a; }

int main(int argc, char **argv)
{
   int a = 3;
   int b = foo(a);
   TApplication app("app", &argc, argv);

   int c = foo(b);
   return 0;
}

Hello all,
thanks for your help. The code was compiled with debug flags enabled.
I investigated the problem further. It seems that at the first line of code including a root component a child process is started and gdb did not catch this correctly, even though I activated the child process switch in gdb.
I just wonder why this context switch appears. Maybe because it is a Ubuntu in a Windows Linux Subsystem. I will have another look at this problem in more detail.

Hi,
I’m not sure how we can help at this point.
If you have a minimal reproducer of something that you want to debug but cannot, I’ll be happy to try it out and check what’s going on.

Cheers,
Enrico

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.