From ec7e97602695b7e4a49013b525d0bf7a0c8d13fc Mon Sep 17 00:00:00 2001 From: Tomasz Malesinski Date: Sat, 4 Feb 2006 00:04:02 +0000 Subject: Added GDB API - a way to call stub procedures from a DEBUG build. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8561 a1c6a512-1295-4272-9138-f99709370657 --- firmware/debug.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'firmware/debug.c') diff --git a/firmware/debug.c b/firmware/debug.c index ba19a9616a..4031ba432d 100644 --- a/firmware/debug.c +++ b/firmware/debug.c @@ -22,6 +22,9 @@ #include #include "config.h" #include "cpu.h" +#ifdef HAVE_GDB_API +#include "gdb_api.h" +#endif #ifdef DEBUG static char debugmembuf[200]; @@ -196,6 +199,34 @@ static void debug(const char *msg) putpacket(debugbuf); } #endif /* SH7034 */ + +#ifdef HAVE_GDB_API +static void *get_api_function(int n) +{ + struct gdb_api *api = (struct gdb_api *)GDB_API_ADDRESS; + if (api->magic == GDB_API_MAGIC) + return api->func[n]; + else + return NULL; +} + +void breakpoint(void) +{ + void (*f)(void) = get_api_function(0); + if (f) (*f)(); +} + +static void debug(char *msg) +{ + void (*f)(char *) = get_api_function(1); + if (f) (*f)(msg); +} + +void debug_init() +{ +} + +#endif /* HAVE_GDB_API */ #endif /* end of DEBUG section */ #ifdef __GNUC__ -- cgit v1.2.3