From b5182915d75c1d4ef055d0ab040356e4836bc7ea Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 12 Apr 2013 21:27:43 -0700 Subject: [PATCH] Command to break into attached debugger --- src/debugger.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/debugger.c b/src/debugger.c index fb2501efb..47d2f4949 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -2,14 +2,17 @@ #include "arm.h" +#include #include #include #include #include +#include #include "linenoise.h" typedef void (DebuggerComamnd)(struct ARMDebugger*); +static void _breakInto(struct ARMDebugger*); static void _printStatus(struct ARMDebugger*); static void _quit(struct ARMDebugger*); @@ -22,6 +25,7 @@ struct { { "q", _quit }, { "quit", _quit }, { "status", _printStatus }, + { "x", _breakInto }, { 0, 0 } }; @@ -36,6 +40,18 @@ static inline void _printPSR(union PSR psr) { psr.t ? 'T' : '-'); } +static void _handleDeath(int sig) { + (void)(sig); + printf("No debugger attached!\n"); +} + +static void _breakInto(struct ARMDebugger* debugger) { + (void)(debugger); + sig_t oldSignal = signal(SIGTRAP, _handleDeath); + kill(getpid(), SIGTRAP); + signal(SIGTRAP, oldSignal); +} + static void _printStatus(struct ARMDebugger* debugger) { int r; for (r = 0; r < 4; ++r) {