[PATCH 2/4] Mark the line in CPU & DSP disassembly matching PC

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


---
 src/debug/debugcpu.c | 25 ++++++++++++++++++-------
 src/debug/debugdsp.c | 23 ++++++++++++++++-------
 2 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/src/debug/debugcpu.c b/src/debug/debugcpu.c
index 4f7c1fe5..eeb35529 100644
--- a/src/debug/debugcpu.c
+++ b/src/debug/debugcpu.c
@@ -147,14 +147,22 @@ static int DebugCpu_SaveBin(int nArgc, char *psArgs[])
  * Check whether given address matches any CPU symbol and whether
  * there's profiling information available for it.  If yes, show it.
  * 
- * @return true if symbol was shown, false otherwise
+ * @return true if something was output, false otherwise
  */
-static bool DebugCpu_ShowAddressInfo(Uint32 addr, FILE *fp)
+static bool DebugCpu_ShowAddressInfo(Uint32 addr, FILE *fp, const char *postfix)
 {
 	const char *symbol = Symbols_GetByCpuAddress(addr, SYMTYPE_ALL);
 	if (symbol)
 	{
-		fprintf(fp, "%s:\n", symbol);
+		if (postfix)
+			fprintf(fp, "%s: %s\n", symbol, postfix);
+		else
+			fprintf(fp, "%s:\n", symbol);
+		return true;
+	}
+	else if (postfix)
+	{
+		fprintf(fp, "%s:\n", postfix);
 		return true;
 	}
 	return false;
@@ -165,7 +173,7 @@ static bool DebugCpu_ShowAddressInfo(Uint32 addr, FILE *fp)
  */
 int DebugCpu_DisAsm(int nArgc, char *psArgs[])
 {
-	Uint32 disasm_upper = 0;
+	Uint32 disasm_upper = 0, pc = M68000_GetPC();
 	int shown, lines = INT_MAX;
 	uaecptr nextpc;
 
@@ -188,7 +196,9 @@ int DebugCpu_DisAsm(int nArgc, char *psArgs[])
 	{
 		/* continue */
 		if(!disasm_addr)
-			disasm_addr = M68000_GetPC();
+		{
+			disasm_addr = pc;
+		}
 	}
 
 	/* limit is topmost address or instruction count */
@@ -201,7 +211,8 @@ int DebugCpu_DisAsm(int nArgc, char *psArgs[])
 	/* output a range */
 	for (shown = 0; shown < lines && disasm_addr < disasm_upper; shown++)
 	{
-		if (DebugCpu_ShowAddressInfo(disasm_addr, debugOutput))
+		const char *postfix = (disasm_addr == pc ? "PC" : NULL);
+		if (DebugCpu_ShowAddressInfo(disasm_addr, debugOutput, postfix))
 			shown++;
 		Disasm(debugOutput, (uaecptr)disasm_addr, &nextpc, 1);
 		disasm_addr = nextpc;
@@ -887,7 +898,7 @@ void DebugCpu_Check(void)
 	}
 	if (LOG_TRACE_LEVEL((TRACE_CPU_DISASM|TRACE_CPU_SYMBOLS)))
 	{
-		DebugCpu_ShowAddressInfo(M68000_GetPC(), TraceFile);
+		DebugCpu_ShowAddressInfo(M68000_GetPC(), TraceFile, NULL);
 	}
 	if (LOG_TRACE_LEVEL(TRACE_CPU_REGS))
 	{
diff --git a/src/debug/debugdsp.c b/src/debug/debugdsp.c
index e7cb04d4..18cc1e6e 100644
--- a/src/debug/debugdsp.c
+++ b/src/debug/debugdsp.c
@@ -105,14 +105,22 @@ error_msg:
  * Check whether given address matches any DSP symbol and whether
  * there's profiling information available for it.  If yes, show it.
  * 
- * @return true if symbol was shown, false otherwise
+ * @return true if something was output, false otherwise
  */
-static bool DebugDsp_ShowAddressInfo(Uint16 addr, FILE *fp)
+static bool DebugDsp_ShowAddressInfo(Uint16 addr, FILE *fp, const char *postfix)
 {
 	const char *symbol = Symbols_GetByDspAddress(addr, SYMTYPE_ALL);
 	if (symbol)
 	{
-		fprintf(fp, "%s:\n", symbol);
+		if (postfix)
+			fprintf(fp, "%s: %s\n", symbol, postfix);
+		else
+			fprintf(fp, "%s:\n", symbol);
+		return true;
+	}
+	else if (postfix)
+	{
+		fprintf(fp, "%s:\n", postfix);
 		return true;
 	}
 	return false;
@@ -125,7 +133,7 @@ static bool DebugDsp_ShowAddressInfo(Uint16 addr, FILE *fp)
 int DebugDsp_DisAsm(int nArgc, char *psArgs[])
 {
 	Uint32 lower, upper;
-	Uint16 dsp_disasm_upper = 0;
+	Uint16 dsp_disasm_upper = 0, pc = DSP_GetPC();
 	int shown, lines = INT_MAX;
 
 	if (!bDspEnabled)
@@ -167,7 +175,7 @@ int DebugDsp_DisAsm(int nArgc, char *psArgs[])
 		/* continue */
 		if(!dsp_disasm_addr)
 		{
-			dsp_disasm_addr = DSP_GetPC();
+			dsp_disasm_addr = pc;
 		}
 	}
 	if (!dsp_disasm_upper)
@@ -177,7 +185,8 @@ int DebugDsp_DisAsm(int nArgc, char *psArgs[])
 	}
 	fprintf(debugOutput, "DSP disasm 0x%hx-0x%hx:\n", dsp_disasm_addr, dsp_disasm_upper);
 	for (shown = 1; shown < lines && dsp_disasm_addr < dsp_disasm_upper; shown++) {
-		if (DebugDsp_ShowAddressInfo(dsp_disasm_addr, debugOutput))
+		const char *postfix = (dsp_disasm_addr == pc ? "PC" : NULL);
+		if (DebugDsp_ShowAddressInfo(dsp_disasm_addr, debugOutput, postfix))
 			shown++;
 		dsp_disasm_addr = DSP_DisasmAddress(debugOutput, dsp_disasm_addr, dsp_disasm_addr);
 	}
@@ -518,7 +527,7 @@ void DebugDsp_Check(void)
 	}
 	if (LOG_TRACE_LEVEL((TRACE_DSP_DISASM|TRACE_DSP_SYMBOLS)))
 	{
-		DebugDsp_ShowAddressInfo(DSP_GetPC(), TraceFile);
+		DebugDsp_ShowAddressInfo(DSP_GetPC(), TraceFile, NULL);
 	}
 	if (nDspActiveCBs)
 	{
-- 
2.20.1


--------------4023024045B6B32B00F42206
Content-Type: text/x-patch; charset=UTF-8;
 name="0003-PC-offset-config-option-for-CPU-DSP-disasm-default-a.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0003-PC-offset-config-option-for-CPU-DSP-disasm-default-a.pa";
 filename*1="tch"



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