Re: [hatari-devel] tracing of cpu (dsp) registers

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


Hi,

Attached is patch to add "cpu_registers" trace option using
the normal (Win)UAE core register dump functionality.

Is it useful enough that it's worth spending one of the free
trace bits for it?

I.e. should I commit/push it?


	- Eero

On 01/25/2018 10:58 AM, Nicolas Pomarède wrote:
Le 24/01/2018 à 23:43, Miro Kropáček a écrit :

On 25 January 2018 at 09:41, Miro Kropáček <miro.kropacek@xxxxxxxxx <mailto:miro.kropacek@xxxxxxxxx>> wrote:


    On 25 January 2018 at 06:30, Eero Tamminen <oak@xxxxxxxxxxxxxx
    <mailto:oak@xxxxxxxxxxxxxx>> wrote:

        Just to verify, do you mean running "registers" command after
        *each* executed CPU instruction?

    Yes. Literally a command like "trace cpu_reg" (dsp_reg wouldn't hurt
    either). Sometimes it's more useful to see the flow of register
    changes than the instructions alone.


Just a suggestion, don't do this trace output so huge -- maybe just basic registers (Dn, An, PC, SR) to keep the output simple and easy to follow.

Hi

I sometimes does this myself when I want to trace a problematic emulation issue : I add a call to m68k_dumpstate after each call to disasm at current PC.

This makes a pretty big output file in the end, but I think that's something you have to accept in case you want to get such low level of details. Outputting the result of several seconds of emulation can easily gives some text file of 1 or 2 GB (when combined with "--trace all")

Then you can filter this output file with some dedicated tools / scripts (grep, awk, perl, whatever you like), but I don't think the overhead of maintaining a simpler dump function with basic registers is worth the effort

Nicolas




diff -r 67a9c6eb4686 src/debug/debugcpu.c
--- a/src/debug/debugcpu.c	Wed Jan 24 23:34:27 2018 +0100
+++ b/src/debug/debugcpu.c	Thu Jan 25 21:29:06 2018 +0200
@@ -635,6 +635,15 @@
 	{
 		DebugCpu_ShowAddressInfo(M68000_GetPC(), TraceFile);
 	}
+	if (LOG_TRACE_LEVEL(TRACE_CPU_REGISTERS))
+	{
+		uaecptr nextpc;
+#ifdef WINUAE_FOR_HATARI
+		m68k_dumpstate_file(TraceFile, &nextpc);
+#else
+		m68k_dumpstate(TraceFile, &nextpc);
+#endif
+	}
 	if (nCpuActiveCBs)
 	{
 		if (BreakCond_MatchCpu())
@@ -674,7 +683,7 @@
 	nCpuActiveCBs = BreakCond_CpuBreakPointCount();
 
 	if (nCpuActiveCBs || nCpuSteps || bCpuProfiling || History_TrackCpu()
-	    || LOG_TRACE_LEVEL((TRACE_CPU_DISASM|TRACE_CPU_SYMBOLS))
+	    || LOG_TRACE_LEVEL((TRACE_CPU_DISASM|TRACE_CPU_SYMBOLS|TRACE_CPU_REGISTERS))
 	    || ConOutDevice != CONOUT_DEVICE_NONE)
 	{
 		M68000_SetSpecial(SPCFLAG_DEBUGGER);
diff -r 67a9c6eb4686 src/debug/log.c
--- a/src/debug/log.c	Wed Jan 24 23:34:27 2018 +0100
+++ b/src/debug/log.c	Thu Jan 25 21:29:06 2018 +0200
@@ -85,6 +85,7 @@
 	{ TRACE_CPU_PAIRING	 , "cpu_pairing" } ,
 	{ TRACE_CPU_DISASM	 , "cpu_disasm" } ,
 	{ TRACE_CPU_EXCEPTION	 , "cpu_exception" } ,
+	{ TRACE_CPU_REGISTERS	 , "cpu_registers" } ,
 	{ TRACE_CPU_ALL 	 , "cpu_all" } ,
 
 	{ TRACE_INT		 , "int" } ,
diff -r 67a9c6eb4686 src/debug/log.h
--- a/src/debug/log.h	Wed Jan 24 23:34:27 2018 +0100
+++ b/src/debug/log.h	Thu Jan 25 21:29:06 2018 +0200
@@ -120,62 +120,63 @@
 #define	TRACE_CPU_PAIRING	 (1<<15)
 #define	TRACE_CPU_DISASM	 (1<<16)
 #define	TRACE_CPU_EXCEPTION	 (1<<17)
-
-#define	TRACE_INT		 (1<<18)
-
-#define	TRACE_FDC		 (1<<19)
-
-#define TRACE_ACIA		 (1<<20)
-
-#define	TRACE_IKBD_CMDS 	 (1<<21)
-#define	TRACE_IKBD_ACIA 	 (1<<22)
-#define	TRACE_IKBD_EXEC 	 (1<<23)
-
-#define TRACE_BLITTER		 (1<<24)
-
-#define TRACE_OS_BIOS		 (1<<25)
-#define TRACE_OS_XBIOS  	 (1<<26)
-#define TRACE_OS_GEMDOS 	 (1<<27)
-#define TRACE_OS_VDI		 (1<<28)
-#define TRACE_OS_AES		 (1<<29)
-
-#define TRACE_IOMEM_RD  	 (1<<30)
-#define TRACE_IOMEM_WR  	 (1ULL<<31)
-
-#define TRACE_DMASND		 (1ll<<32)
-
-#define TRACE_CROSSBAR		 (1ll<<33)
-#define TRACE_VIDEL		 (1ll<<34)
+#define	TRACE_CPU_REGISTERS	 (1<<18)
 
-#define TRACE_DSP_HOST_INTERFACE (1ll<<35)
-#define TRACE_DSP_HOST_COMMAND	 (1ll<<36)
-#define TRACE_DSP_HOST_SSI	 (1ll<<37)
-#define TRACE_DSP_DISASM	 (1ll<<38)
-#define TRACE_DSP_DISASM_REG	 (1ll<<39)
-#define TRACE_DSP_DISASM_MEM	 (1ll<<40)
-#define TRACE_DSP_STATE		 (1ll<<41)
-#define TRACE_DSP_INTERRUPT	 (1ll<<42)
-
-#define TRACE_DSP_SYMBOLS	 (1ll<<43)
-#define TRACE_CPU_SYMBOLS	 (1ll<<44)
-
-#define TRACE_NVRAM		 (1ll<<45)
+#define	TRACE_INT		 (1<<19)
 
-#define TRACE_SCSI_CMD		 (1ll<<46)
-
-#define TRACE_NATFEATS		 (1ll<<47)
-
-#define TRACE_KEYMAP		 (1ll<<48)
+#define	TRACE_FDC		 (1<<20)
 
-#define TRACE_MIDI		 (1ll<<49)
-
-#define TRACE_IDE		 (1ll<<50)
+#define TRACE_ACIA		 (1<<21)
 
-#define TRACE_OS_BASE		 (1ll<<51)
+#define	TRACE_IKBD_CMDS 	 (1<<22)
+#define	TRACE_IKBD_ACIA 	 (1<<23)
+#define	TRACE_IKBD_EXEC 	 (1<<24)
 
-#define TRACE_SCSIDRV		 (1ll<<52)
+#define TRACE_BLITTER		 (1<<25)
+
+#define TRACE_OS_BIOS		 (1<<26)
+#define TRACE_OS_XBIOS  	 (1<<27)
+#define TRACE_OS_GEMDOS 	 (1<<28)
+#define TRACE_OS_VDI		 (1<<29)
+#define TRACE_OS_AES		 (1<<30)
+
+#define TRACE_IOMEM_RD  	 (1ll<<31)
+#define TRACE_IOMEM_WR  	 (1ll<<32)
+
+#define TRACE_DMASND		 (1ll<<33)
+
+#define TRACE_CROSSBAR		 (1ll<<34)
+#define TRACE_VIDEL		 (1ll<<35)
+
+#define TRACE_DSP_HOST_INTERFACE (1ll<<36)
+#define TRACE_DSP_HOST_COMMAND	 (1ll<<37)
+#define TRACE_DSP_HOST_SSI	 (1ll<<38)
+#define TRACE_DSP_DISASM	 (1ll<<39)
+#define TRACE_DSP_DISASM_REG	 (1ll<<40)
+#define TRACE_DSP_DISASM_MEM	 (1ll<<41)
+#define TRACE_DSP_STATE		 (1ll<<42)
+#define TRACE_DSP_INTERRUPT	 (1ll<<43)
+
+#define TRACE_DSP_SYMBOLS	 (1ll<<44)
+#define TRACE_CPU_SYMBOLS	 (1ll<<45)
+
+#define TRACE_NVRAM		 (1ll<<46)
+
+#define TRACE_SCSI_CMD		 (1ll<<47)
+
+#define TRACE_NATFEATS		 (1ll<<48)
+
+#define TRACE_KEYMAP		 (1ll<<49)
+
+#define TRACE_MIDI		 (1ll<<50)
+
+#define TRACE_IDE		 (1ll<<51)
+
+#define TRACE_OS_BASE		 (1ll<<52)
+
+#define TRACE_SCSIDRV		 (1ll<<53)
     
-#define TRACE_MEM		 (1ll<<53)
+#define TRACE_MEM		 (1ll<<54)
 
 #define	TRACE_NONE		 (0)
 #define	TRACE_ALL		 (~0)


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