From 0ba7451e3a0a5b6a1d88a39c79bd13f462ee1a4b Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 18 Apr 2013 01:52:46 -0700 Subject: [PATCH] Install SIGINT signal handler for debugger --- src/debugger/debugger.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/debugger/debugger.c b/src/debugger/debugger.c index 6f850eabf..651ae6f5e 100644 --- a/src/debugger/debugger.c +++ b/src/debugger/debugger.c @@ -30,6 +30,8 @@ struct DebugBreakpoint { static const char* ERROR_MISSING_ARGS = "Arguments missing"; +static struct ARMDebugger* _activeDebugger; + typedef void (DebuggerComamnd)(struct ARMDebugger*, struct DebugVector*); static void _breakInto(struct ARMDebugger*, struct DebugVector*); @@ -44,6 +46,8 @@ static void _readHalfword(struct ARMDebugger*, struct DebugVector*); static void _readWord(struct ARMDebugger*, struct DebugVector*); static void _setBreakpoint(struct ARMDebugger*, struct DebugVector*); +static void _breakIntoDefault(int signal); + struct { const char* name; DebuggerComamnd* command; @@ -217,6 +221,11 @@ static void _checkBreakpoints(struct ARMDebugger* debugger) { } } +static void _breakIntoDefault(int signal) { + (void)(signal); + _activeDebugger->state = DEBUGGER_PAUSED; +} + enum _DVParseState { PARSE_ERROR = -1, PARSE_ROOT = 0, @@ -523,6 +532,8 @@ void ARMDebuggerInit(struct ARMDebugger* debugger, struct ARMCore* cpu) { debugger->state = DEBUGGER_PAUSED; debugger->lastCommand = 0; debugger->breakpoints = 0; + _activeDebugger = debugger; + signal(SIGINT, _breakIntoDefault); } void ARMDebuggerRun(struct ARMDebugger* debugger) {