This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

detecting gdb at runtime?


Is there any way to detect GDB at runtime?

I am currently experimenting with different ways to handle errors in a C++ library I am writing. I am using an Assert() macro to verify conditions throughout the program, much like C's assert() function. I believe that the best way to respond to a failed assertion is to throw an exception because it gives the client application a chance to recover as best it can. However, if the program is running in a debugger, throwing an exception is sub-optimal because it cannot give you a stack trace.

My goal is to have my Assert() macro SIGTRAP if a debugger is running to break into the debugger, otherwise throw an exception. Is there any way to make this happen?

(Please CC me, I am not subscribed).

Josh Haberman


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]