Author Topic: Any hints for starting GDB / SE debugger on C++ program run from a script?  (Read 4704 times)

redcar

  • Community Member
  • Posts: 30
  • Hero Points: 0
I am working on a piece of data processing software that has a perl test harness that starts, stops and restarts the application while supplying various data-sets and monitoring various output files.  All on Linux BTW.

I want to be able to catch exceptions and set breakpoints in the C++ application but these often won't be hit until the application has been run several times by the script.

Any ideas about the best way to configure SE to be configuring breakpoints and waiting for exceptions in this kind of environment?

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: Any hints for starting GDB / SE debugger on C++ program run from a script?
« Reply #1 on: December 17, 2020, 06:44:10 PM »
I suggest that you put an endless loop where you want your breakpoint to be (with a print just before it). Run it outside of SE and when it hits then you can "attach" to it from SE's debugger. If you use a global variable to test to exit your endless loop you can change the global's value to continue stepping.

crawford

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Re: Any hints for starting GDB / SE debugger on C++ program run from a script?
« Reply #2 on: December 25, 2020, 01:51:37 PM »
Hi, I have a question about this solution: How to stop the endless loop, though? It sounds okay theoretically but I can't do it. Maybe I should abort the loop after you get the result outside of the loop? I'm trying every possibility since the morning at my property in Bavaria but nothing works for me so far.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: Any hints for starting GDB / SE debugger on C++ program run from a script?
« Reply #3 on: December 25, 2020, 03:28:57 PM »
Use a global variable for the loop such as:

Code: [Select]
int global_var = 1;

void some_function()
{
  while(global_var == 1);
}

When you attach and are in the debugger, use the debugger to set global_var to 0, then when you step through you will exit the loop.

Your code should only invoke this loop when it detects the "error condition" where you want something like a "breakpoint".