[PATCH 1/3] Add config option to specify PC offset for disassembly default address

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


This also sorts the related options in code & documentation.

TODO: add support for this also to Python debugger UI
---
 doc/debugger.html            | 26 ++++++++++++++++----------
 src/configuration.c          | 14 ++++++++------
 src/debug/debugcpu.c         |  5 ++++-
 src/includes/configuration.h |  7 ++++---
 4 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/doc/debugger.html b/doc/debugger.html
index 74b4c5b5..1b3457f0 100644
--- a/doc/debugger.html
+++ b/doc/debugger.html
@@ -112,10 +112,11 @@ These are their defaults:</p>
 <pre>
 [Debugger]
 nNumberBase = 10
-nSymbolLines = -1
-nMemdumpLines = -1
-nDisasmLines = -1
 nBacktraceLines = 0
+nDisasmLines = -1
+nDisasmOffset = 0
+nMemdumpLines = -1
+nSymbolLines = -1
 nExceptionDebugMask = 515
 nDisasmOptions = 15
 bDisasmUAE = FALSE
@@ -128,14 +129,19 @@ bMatchAllSymbols = FALSE
 <dt>nNumberBase</dt>
 <dd>Debugger number base.
     Set with the debugger "setopt [bin|dec|hex]" command</dd>
-<dt>nSymbolLines</dt>
-<dd>Number of lines to show when listing debug symbols</dd>
-<dt>nMemdumpLines</dt>
-<dd>Number of memory dump lines to show</dd>
-<dt>nDisasmLines</dt>
-<dd>Number of disassembly lines to show</dd>
 <dt>nBacktraceLines</dt>
-<dd>Number of items to show in stack/bactraces</dd>
+<dd>Number of items to show in stack/bactraces (0 = all)</dd>
+<dt>nDisasmLines</dt>
+<dd>Number of disassembly lines to show (-1 = use console size)</dd>
+<dt>nDisasmOffset</dt>
+<dd>When re-entering debugger, disassembly command defaults
+    to PC address minus this value.  With non-zero value,
+    disassembly output may show wrong information</dd>
+<dt>nMemdumpLines</dt>
+<dd>Number of memory dump lines to show (-1 = use console size)</dd>
+<dt>nSymbolLines</dt>
+<dd>Number of lines to show when listing debug symbols
+    (-1 = use console size)</dd>
 <dt>nExceptionDebugMask</dt>
 <dd>Mask of exceptions which invoke debugger when exceptions catching
     is enabled (-D).  Set with the "--debug-except" option</dd>
diff --git a/src/configuration.c b/src/configuration.c
index 15daca88..54e2bad6 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -59,10 +59,11 @@ static const struct Config_Tag configs_Log[] =
 static const struct Config_Tag configs_Debugger[] =
 {
 	{ "nNumberBase", Int_Tag, &ConfigureParams.Debugger.nNumberBase },
-	{ "nSymbolLines", Int_Tag, &ConfigureParams.Debugger.nSymbolLines },
-	{ "nMemdumpLines", Int_Tag, &ConfigureParams.Debugger.nMemdumpLines },
-	{ "nDisasmLines", Int_Tag, &ConfigureParams.Debugger.nDisasmLines },
 	{ "nBacktraceLines", Int_Tag, &ConfigureParams.Debugger.nBacktraceLines },
+	{ "nDisasmLines", Int_Tag, &ConfigureParams.Debugger.nDisasmLines },
+	{ "nDisasmOffset", Int_Tag, &ConfigureParams.Debugger.nDisasmOffset },
+	{ "nMemdumpLines", Int_Tag, &ConfigureParams.Debugger.nMemdumpLines },
+	{ "nSymbolLines", Int_Tag, &ConfigureParams.Debugger.nSymbolLines },
 	{ "nExceptionDebugMask", Int_Tag, &ConfigureParams.Debugger.nExceptionDebugMask },
 	{ "nDisasmOptions", Int_Tag, &ConfigureParams.Debugger.nDisasmOptions },
 	{ "bDisasmUAE", Bool_Tag, &ConfigureParams.Debugger.bDisasmUAE },
@@ -524,10 +525,11 @@ void Configuration_SetDefault(void)
 
 	/* Set defaults for debugger */
 	ConfigureParams.Debugger.nNumberBase = 10;
-	ConfigureParams.Debugger.nSymbolLines = -1; /* <0: use terminal size */
-	ConfigureParams.Debugger.nMemdumpLines = -1; /* <0: use terminal size */
-	ConfigureParams.Debugger.nDisasmLines = -1; /* <0: use terminal size */
 	ConfigureParams.Debugger.nBacktraceLines = 0; /* <=0: show all */
+	ConfigureParams.Debugger.nDisasmLines = -1; /* <0: use terminal size */
+	ConfigureParams.Debugger.nDisasmOffset = 0; /* <=0: no disasm PC offset */
+	ConfigureParams.Debugger.nMemdumpLines = -1; /* <0: use terminal size */
+	ConfigureParams.Debugger.nSymbolLines = -1; /* <0: use terminal size */
 	ConfigureParams.Debugger.nExceptionDebugMask = DEFAULT_EXCEPTIONS;
 	/* external one has nicer output, but isn't as complete as UAE one */
 	ConfigureParams.Debugger.bDisasmUAE = true;
diff --git a/src/debug/debugcpu.c b/src/debug/debugcpu.c
index 84f0d7d9..294f5fbe 100644
--- a/src/debug/debugcpu.c
+++ b/src/debug/debugcpu.c
@@ -1062,6 +1062,9 @@ int DebugCpu_Init(const dbgcommand_t **table)
  */
 void DebugCpu_InitSession(void)
 {
-	disasm_addr = M68000_GetPC();
+	int offset = ConfigureParams.Debugger.nDisasmOffset;
+	if (offset < 0)
+		offset = 0;
+	disasm_addr = M68000_GetPC() - offset;
 	Profile_CpuStop();
 }
diff --git a/src/includes/configuration.h b/src/includes/configuration.h
index a400e2c8..6c59ffdd 100644
--- a/src/includes/configuration.h
+++ b/src/includes/configuration.h
@@ -28,10 +28,11 @@ typedef struct
 typedef struct
 {
   int nNumberBase;
-  int nSymbolLines;
-  int nMemdumpLines;
-  int nDisasmLines;
   int nBacktraceLines;
+  int nDisasmLines;
+  int nDisasmOffset;
+  int nMemdumpLines;
+  int nSymbolLines;
   int nExceptionDebugMask;
   int nDisasmOptions;
   bool bDisasmUAE;
-- 
2.20.1


--------------813F85CE7FBFE7F2627A59B8--



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/