Command to break into attached debugger
Jeffrey Pfau jeffrey@endrift.com
Fri, 12 Apr 2013 21:27:43 -0700
1 files changed,
16 insertions(+),
0 deletions(-)
jump to
M
src/debugger.c
→
src/debugger.c
@@ -2,14 +2,17 @@ #include "debugger.h"
#include "arm.h" +#include <signal.h> #include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <strings.h> +#include <unistd.h> #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 @@ { "info", _printStatus },
{ "q", _quit }, { "quit", _quit }, { "status", _printStatus }, + { "x", _breakInto }, { 0, 0 } };@@ -34,6 +38,18 @@ psr.v ? 'V' : '-',
psr.i ? 'I' : '-', psr.f ? 'F' : '-', 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) {