[hatari-devel] Extensions to Hatari's Native Features support for debugging? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi,
Douglas asked how one could direct native code asserts to
invoke Hatari debugger:
http://www.atari-forum.com/viewtopic.php?f=4&t=16682&p=239236#p239233
While one might try something hacky like this with --bios-intercept:
XBios(255, "b pc=pc")
I think best would be to add direct support this this kind of operations
to Hatari's Native Features support, as that is easily extendable
(unlike XBios(255)):
http://wiki.aranym.org/natfeats/proposal
For starters I was thinking of two additional NatFeats operations:
"NF_DEBUGGER" -- invoke Hatari debugger
"NF_COMMAND" -- same as Xbios(255) [1]
Attached untested patch implements them to Hatari.
Comments, standalone test-code for NatFeats and suggestions for
other useful NatFeats commands would be welcome!
(especially the test-code, hint, hint...)
- Eero
[1] I would like to eventually phase out "--bios-intercept"
option and XBIOS calls doing extra things besides tracing.
XBios_Rsconf() is probably already obsolete and XBios(255)
can be replaced with NF_COMMAND, which leaves just a question
of what to do about XBios_Scrdmp().
If Bios interception were enabled always (with no side-effects),
there could be a separate, better named option for enabling
TOS/XBIOS screendump call making a Hatari screenshot.
diff -r 558497b06d63 src/debug/natfeats.c
--- a/src/debug/natfeats.c Mon Oct 07 23:58:34 2013 +0200
+++ b/src/debug/natfeats.c Thu Oct 10 23:51:38 2013 +0300
@@ -1,7 +1,7 @@
/*
* Hatari - natfeats.c
*
- * Copyright (C) 2012 by Eero Tamminen
+ * Copyright (C) 2012-2013 by Eero Tamminen
*
* This file is distributed under the GNU General Public License, version 2
* or at your option any later version. Read the file gpl.txt for details.
@@ -20,6 +20,7 @@
#include "stMemory.h"
#include "m68000.h"
#include "natfeats.h"
+#include "control.h"
#define NF_DEBUG 1
#if NF_DEBUG
@@ -34,6 +35,10 @@
*/
+/*
+ * Native Features shared with Aranym
+ */
+
static bool nf_name(Uint32 stack, Uint32 subid, Uint32 *retval)
{
Uint32 ptr, len;
@@ -91,6 +96,44 @@
return true;
}
+/*
+ * Native Features specific to Hatari
+ */
+
+/**
+ * invoke debugger
+ */
+static bool nf_debugger(Uint32 stack, Uint32 subid, Uint32 *retval)
+{
+ Dprintf(("NF debugger()\n"));
+ M68000_SetSpecial(SPCFLAG_DEBUGGER);
+ return true;
+}
+
+/**
+ * execute Hatari (command line / debugger) command
+ */
+static bool nf_command(Uint32 stack, Uint32 subid, Uint32 *retval)
+{
+ Uint32 ptr;
+ char *str;
+
+ ptr = STMemory_ReadLong(stack);
+ Dprintf(("NF command(0x%x)\n", ptr));
+
+ if (!STMemory_ValidArea(ptr, 1)) {
+ M68000_BusError(ptr, BUS_ERROR_READ);
+ return false;
+ }
+ str = strdup((const char *)STRAM_ADDR(ptr));
+ if (str) {
+ Control_ProcessBuffer(str);
+ free(str);
+ }
+ return true;
+}
+
+
/* ---------------------------- */
#define FEATNAME_MAX 16
@@ -103,7 +146,9 @@
{ "NF_NAME", false, nf_name },
{ "NF_VERSION", false, nf_version },
{ "NF_STDERR", false, nf_stderr },
- { "NF_SHUTDOWN", true, nf_shutdown }
+ { "NF_SHUTDOWN", true, nf_shutdown },
+ { "NF_DEBUGGER", false, nf_debugger },
+ { "NF_COMMAND", false, nf_command }
};
/* macros from Aranym */