all repos — mgba @ b5182915d75c1d4ef055d0ab040356e4836bc7ea

mGBA Game Boy Advance Emulator

Command to break into attached debugger
Jeffrey Pfau jeffrey@endrift.com
Fri, 12 Apr 2013 21:27:43 -0700
commit

b5182915d75c1d4ef055d0ab040356e4836bc7ea

parent

a7bc99c84610f578e41613bf05a2042b3f42775d

1 files changed, 16 insertions(+), 0 deletions(-)

jump to
M src/debugger.csrc/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) {