Detecting debugger at run time


#1

Hi,

I know code for this for Windows. However, do you know of a way to detect if the code is being run under a debugger under other platforms ?

BTW, any Juce independent function to know this ?
The idea is to avoid showing that damn splash screen while running in the debugger.


#2

#if JUCE_DEBUG ?


#3

aye, personally i don’t know any code off the top of my head to detect whether or not a debugger is running, but you can always just tweak your code to miss the splash screen out in the debug build.


#4

Sure, preprocessor is good for compile-time detection.
I’m speaking of runtime detection.

I’m looking for a cross platform solution of “IsDebuggerPresent” under Win32.

I don’t like having 2 paths for the code (one with #define DEBUG and the other without), as 100% sure a fatal bug will appear in the #ifndef DEBUG part.

On the other side, it’s just the splash screen…

Under linux, I know about the “get parent pid of our pid, and if it is gdb, then we are under a debugger” trick, but I don’t know of any trick like this in MacOSX

Another solution, is to do something like :

bool debugHere = false;
   try
{
    asm int 3; 
    debugHere = true;
} catch(...)
{ 
    
}

But it’s very x86 specific (due to asm part).
I don’t know of any other cross platform way, and I was wondering if any of you know about.


#5

Well if you can use that pid trick in linux, it should work on the mac too - XCode uses gdb internally.


#6