[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[sequoyah-dev] break into debugger with an explicit breakpoint macro?
|
If there's a better forum, please accept my apologies, a pointer to it
would be appreciated.
I'm having trouble porting a macro that triggers a break into the debugger.
in x86, I just do _asm int 3;
In gcc- arm/thumb, this *should* translate to asm ("bkpt 0"); - but
both this and assert(0) - my fallback, don't actually do anything
useful.
There's a google groups post related to this, but no resolution that I can find:
http://groups.google.com/group/android-ndk/browse_thread/thread/e614026a3d360248/9367e70552728dce?lnk=gst&q=asm#9367e70552728dce
//Option 1:
#if defined(__arm__) || defined(__thumb__)
#define EC_BREAKPOINT() asm volatile ("bkpt 0")
#else
#define EC_BREAKPOINT() asm volatile ("int $3")
#endif
This stops the thread, but does not break into the debugger.
//Option2
#define EC_BREAKPOINT() assert(0)
this stops the thread with a SEGV, kills the callstack*and breaks.
// Option3
#define EC_BREAKPOINT() raise(SIGTRAP)
This gives me I get Thread[0] suspended (at address 0xafd0ebfc) , and
Thread[1] Suspended with a SIGTRAP at the same address, but the
callstacks for both are lost. The last executed instruction seems to
be "svc 0", so I try that as my option 4:
//Option 4
#define EC_BREAKPOINT() asm volatile("svc 0")
<< Now this works, to some extent. I usually get breaks at the
desired line of code, but the break is sometimes a SIGILL, sometimes a
SIGSEGV, possibly depending on the instruction following the "svc 0"?
Has anyone come up with a reliable way to break c/c++ code explicitly,
with the possibility of continuing past the break?
best regards,
JP
* when I say "kills the stack" I mean that gdbserver through eclipse
isn't able to tell me what the callstack is, I haven't investigated
the memory contents at sp yet.
----------------
http://forksandhope.com/
"This isn't right; it isn't even wrong." - W. Pauli