[hatari-devel] Separate CPU video cycles under its own "cpu_video_cycles" trace flag?

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


Hi,

Any objections on the attached patch?

This was requested in Atari forum:
https://www.atari-forum.com/viewtopic.php?p=448383#p448383

And I like it myself too, as I've never needed that extra video cycles info in disassembly.

That info is still there when using either:
	--trace cpu_disasm,cpu_video_cycles
or:
	--trace cpu_all


	- Eero
From 5fe5484167170d79b0b8418e24653139b65b1497 Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Fri, 30 Jun 2023 20:50:39 +0300
Subject: [PATCH] Separate CPU video cycles under its own trace flag

As requested on:
https://www.atari-forum.com/viewtopic.php?p=448383#p448383
---
 doc/release-notes.txt |  1 +
 src/cpu/newcpu.c      | 91 +++++++++++++------------------------------
 src/debug/log.c       |  1 +
 src/debug/log.h       |  4 +-
 4 files changed, 31 insertions(+), 66 deletions(-)

diff --git a/doc/release-notes.txt b/doc/release-notes.txt
index 3e0d98a7..9643d6e9 100644
--- a/doc/release-notes.txt
+++ b/doc/release-notes.txt
@@ -67,6 +67,7 @@ Emulator improvements:
     calls (in addition to earlier pexec/pterm & file create/open calls)
   - Suppress repeats of identical log & trace messages by default
     (show only their count) and add "--msg-repeat" option to toggle that
+  - Separate CPU video cycles under its own "cpu_video_cycles" trace flag
   - Preliminary support for disassembly output options working also for
     CPU core disassembler in addition to external disassember output
   - When entering debugger with 'history' enabled, disassembly address
diff --git a/src/cpu/newcpu.c b/src/cpu/newcpu.c
index 4c62d18b..aedc904a 100644
--- a/src/cpu/newcpu.c
+++ b/src/cpu/newcpu.c
@@ -934,6 +934,19 @@ static void set_x_ifetches(void)
 
 #ifdef WINUAE_FOR_HATARI
 
+static void trace_cpu_disasm(void)
+{
+	if (LOG_TRACE_LEVEL(TRACE_CPU_VIDEO_CYCLES)) {
+		int FrameCycles, HblCounterVideo, LineCycles;
+		Video_GetPosition ( &FrameCycles, &HblCounterVideo, &LineCycles );
+		LOG_TRACE_DIRECT_INIT ();
+		LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : ",
+				   FrameCycles, LineCycles, HblCounterVideo,
+				   CyclesGlobalClockCounter );
+	}
+	m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+}
+
 void (*x_do_cycles_hatari_blitter_save)(int);
 void (*x_do_cycles_pre_hatari_blitter_save)(int);
 void (*x_do_cycles_post_hatari_blitter_save)(int, uae_u32);
@@ -5397,11 +5410,7 @@ static void m68k_run_1 (void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 
@@ -5542,11 +5551,7 @@ static void m68k_run_1_ce (void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 
@@ -6145,11 +6150,7 @@ static void m68k_run_jit(void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 
@@ -6309,11 +6310,7 @@ static void m68k_run_mmu060 (void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 				f.cznv = regflags.cznv;
@@ -6402,11 +6399,7 @@ static void m68k_run_mmu040 (void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 				f.cznv = regflags.cznv;
@@ -6549,11 +6542,7 @@ insretry:
 					//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 					if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 					{
-						int FrameCycles, HblCounterVideo, LineCycles;
-						Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-						LOG_TRACE_DIRECT_INIT ();
-						LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-						m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+						trace_cpu_disasm();
 					}
 #endif
 					regs.opcode = regs.irc = mmu030_opcode;
@@ -6723,11 +6712,7 @@ static void m68k_run_3ce (void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 				currcycle = CYCLE_UNIT / 2;	/* Assume at least 1 cycle per instruction */
 #endif
@@ -6826,11 +6811,7 @@ static void m68k_run_3p(void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 				r->instruction_pc = m68k_getpc();
@@ -6964,11 +6945,7 @@ static void m68k_run_2ce (void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 #if 0
 // logs to debug data cache issues
 struct cache030 *c1 ,*c2;
@@ -7165,11 +7142,7 @@ static void m68k_run_2p (void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 				r->instruction_pc = m68k_getpc ();
@@ -7364,11 +7337,7 @@ static void m68k_run_2_000(void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(stderr, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 				r->instruction_pc = m68k_getpc ();
@@ -7458,11 +7427,7 @@ static void m68k_run_2_020(void)
 				//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 				if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 				{
-					int FrameCycles, HblCounterVideo, LineCycles;
-					Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-					LOG_TRACE_DIRECT_INIT ();
-					LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-					m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+					trace_cpu_disasm();
 				}
 #endif
 				r->instruction_pc = m68k_getpc();
@@ -7536,11 +7501,7 @@ static void m68k_run_mmu (void)
 		//m68k_dumpstate_file(stderr, NULL, 0xffffffff);
 		if ((LOG_TRACE_LEVEL(TRACE_CPU_DISASM)) && (!regs.stopped))
 		{
-			int FrameCycles, HblCounterVideo, LineCycles;
-			Video_GetPosition ( &FrameCycles , &HblCounterVideo , &LineCycles );
-			LOG_TRACE_DIRECT_INIT ();
-			LOG_TRACE_DIRECT ( "cpu video_cyc=%6d %3d@%3d %"PRIu64" : " , FrameCycles, LineCycles, HblCounterVideo , CyclesGlobalClockCounter );
-			m68k_disasm_file(TraceFile, m68k_getpc (), NULL, m68k_getpc (), 1);
+			trace_cpu_disasm();
 		}
 #endif
 		regs.opcode = get_iiword (0);
diff --git a/src/debug/log.c b/src/debug/log.c
index 0b719dcb..f19bdea6 100644
--- a/src/debug/log.c
+++ b/src/debug/log.c
@@ -79,6 +79,7 @@ static flagname_t TraceFlags[] = {
 	{ TRACE_CPU_PAIRING	 , "cpu_pairing" },
 	{ TRACE_CPU_REGS	 , "cpu_regs" },
 	{ TRACE_CPU_SYMBOLS	 , "cpu_symbols" },
+	{ TRACE_CPU_VIDEO_CYCLES , "cpu_video_cycles" },
 
 	{ TRACE_CROSSBAR  	 , "crossbar" },
 
diff --git a/src/debug/log.h b/src/debug/log.h
index bab3ec03..1b7f9247 100644
--- a/src/debug/log.h
+++ b/src/debug/log.h
@@ -116,6 +116,7 @@ enum {
 	TRACE_BIT_CPU_PAIRING,
 	TRACE_BIT_CPU_REGS,
 	TRACE_BIT_CPU_SYMBOLS,
+	TRACE_BIT_CPU_VIDEO_CYCLES,
 
 	TRACE_BIT_CROSSBAR,
 
@@ -200,6 +201,7 @@ enum {
 #define TRACE_CPU_PAIRING        (1ll<<TRACE_BIT_CPU_PAIRING)
 #define TRACE_CPU_REGS           (1ll<<TRACE_BIT_CPU_REGS)
 #define TRACE_CPU_SYMBOLS        (1ll<<TRACE_BIT_CPU_SYMBOLS)
+#define TRACE_CPU_VIDEO_CYCLES   (1ll<<TRACE_BIT_CPU_VIDEO_CYCLES)
 
 #define TRACE_CROSSBAR           (1ll<<TRACE_BIT_CROSSBAR)
 
@@ -286,7 +288,7 @@ enum {
 
 #define	TRACE_PSG_ALL		( TRACE_PSG_READ | TRACE_PSG_WRITE )
 
-#define	TRACE_CPU_ALL		( TRACE_CPU_PAIRING | TRACE_CPU_DISASM | TRACE_CPU_EXCEPTION )
+#define	TRACE_CPU_ALL		( TRACE_CPU_PAIRING | TRACE_CPU_DISASM | TRACE_CPU_EXCEPTION | TRACE_CPU_VIDEO_CYCLES )
 
 #define	TRACE_IKBD_ALL		( TRACE_IKBD_CMDS | TRACE_IKBD_ACIA | TRACE_IKBD_EXEC )
 
-- 
2.39.2



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