Years ago I had a little #define
which I used in Borland C++ Builder. From memory, it was something approximately like
#define BREAK_IF_DEBUGGING asm(0xA3);
or something like that. It relied on 0XA3 (or whatever it was) being the op code for the interrupt which Borland were using to trigger a breakpoint.
Can I do the same thing in Eclipse? (I'll probably wrap it in a few #idef ECLIPSE
and #ifdef TESTING
)
What I hope to achieve here is that
- the code compiles away to nothing in the release version, of course.
- if I run by unit tests with Ctrl-F11 then I don't want a breakpint to be triggered (which it won't because of Ctrl-F11 being "Run")
- if I "Run with Debug" using F11) then if executions hits any use of the macro then it will stop at a breakpoint.
Why? Because I want to set & forget. Just put one of these in each error leg (or embed it in my LOG_ERROR
macro).
Often when I choose my initial breakpoint, it is too late, so this macro says "I think I want to run to line X, but if execution passes through one of those error branches first, I'd like to stop there & sniff around".
Whether you like the idea or not, can you tell me how to do it?