Install SIGINT signal handler for debugger

This commit is contained in:
Jeffrey Pfau 2013-04-18 01:52:46 -07:00
parent 0b468a9db8
commit 0ba7451e3a
1 changed files with 11 additions and 0 deletions

View File

@ -30,6 +30,8 @@ struct DebugBreakpoint {
static const char* ERROR_MISSING_ARGS = "Arguments missing"; static const char* ERROR_MISSING_ARGS = "Arguments missing";
static struct ARMDebugger* _activeDebugger;
typedef void (DebuggerComamnd)(struct ARMDebugger*, struct DebugVector*); typedef void (DebuggerComamnd)(struct ARMDebugger*, struct DebugVector*);
static void _breakInto(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 _readWord(struct ARMDebugger*, struct DebugVector*);
static void _setBreakpoint(struct ARMDebugger*, struct DebugVector*); static void _setBreakpoint(struct ARMDebugger*, struct DebugVector*);
static void _breakIntoDefault(int signal);
struct { struct {
const char* name; const char* name;
DebuggerComamnd* command; 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 { enum _DVParseState {
PARSE_ERROR = -1, PARSE_ERROR = -1,
PARSE_ROOT = 0, PARSE_ROOT = 0,
@ -523,6 +532,8 @@ void ARMDebuggerInit(struct ARMDebugger* debugger, struct ARMCore* cpu) {
debugger->state = DEBUGGER_PAUSED; debugger->state = DEBUGGER_PAUSED;
debugger->lastCommand = 0; debugger->lastCommand = 0;
debugger->breakpoints = 0; debugger->breakpoints = 0;
_activeDebugger = debugger;
signal(SIGINT, _breakIntoDefault);
} }
void ARMDebuggerRun(struct ARMDebugger* debugger) { void ARMDebuggerRun(struct ARMDebugger* debugger) {