[PATCH 2/3] Mark the line in disassembly matching PC

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


---
 src/debug/debugcpu.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/debug/debugcpu.c b/src/debug/debugcpu.c
index 294f5fbe..972d064e 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))
 	{
-- 
2.20.1


--------------813F85CE7FBFE7F2627A59B8
Content-Type: text/x-patch; charset=UTF-8;
 name="0001-Add-config-option-to-specify-PC-offset-for-disassemb.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-Add-config-option-to-specify-PC-offset-for-disassemb.pa";
 filename*1="tch"



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