How can I break if gdb is attached, but continue if it is not?

Posted by Michael Anderson on Stack Overflow See other posts from Stack Overflow or by Michael Anderson
Published on 2010-03-17T03:50:57Z Indexed on 2010/03/17 4:01 UTC
Read the original article Hit count: 226

Filed under:
|

I have some debugging code that if executed while running with GBD attached should break the execution of the application, but if GDB is not running it should continue.

The code I'm working with looks something like this in structure:

try
{
  if( some_complex_expression )
  {
     gdb_should_berak_here();
     do_some_stuff();
     throw MyException();
  }
}
catch( const MyException & e )
{
  handle_exception_and_continue();
}

What should gdb_should_break_here be?

© Stack Overflow or respective owner

Related posts about c++

Related posts about gdb