[PATCH] Generate trace flag mask from flag list at built time |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- Subject: [PATCH] Generate trace flag mask from flag list at built time
- From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
- Date: Fri, 21 May 2021 01:15:02 +0300
This way one can freely modify / sort the trace list without needing
to worry about mask values.
Symbol flags are now similarly renamed as their user-visible names
in previous commit:
- TRACE_CPU_SYMBOLS -> TRACE_SYMBOLS_CPU
- TRACE_DSP_SYMBOLS -> TRACE_SYMBOLS_DSP
NOTE: I did not find a way tell CMake about log.h depending on
traceflags.h and it needing to be re-created before anything depending
on log.h is built. It's now a dependency for first 2 library targets
which seems to work, but may not be 100% reliable if one uses hugely
parallel builds...
---
src/debug/CMakeLists.txt | 10 +++++
src/debug/debugcpu.c | 4 +-
src/debug/debugdsp.c | 4 +-
src/debug/log.c | 4 +-
src/debug/log.h | 87 ++--------------------------------------
src/debug/traceflags.awk | 9 +++++
src/debug/traceflags.in | 83 ++++++++++++++++++++++++++++++++++++++
7 files changed, 112 insertions(+), 89 deletions(-)
create mode 100755 src/debug/traceflags.awk
create mode 100644 src/debug/traceflags.in
diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt
index 2672b937..d57cc2ae 100644
--- a/src/debug/CMakeLists.txt
+++ b/src/debug/CMakeLists.txt
@@ -12,3 +12,13 @@ add_library(Debug
${DSPDBG_C} evaluate.c history.c symbols.c vars.c
profile.c profilecpu.c profiledsp.c
natfeats.c console.c 68kDisass.c)
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/traceflags.h
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/traceflags.awk < ${CMAKE_CURRENT_SOURCE_DIR}/traceflags.in > ${CMAKE_CURRENT_SOURCE_DIR}/traceflags.h
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/traceflags.in
+)
+
+add_custom_target(hatari_traceflags ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/traceflags.h)
+add_dependencies(Floppy hatari_traceflags)
+add_dependencies(Debug hatari_traceflags)
diff --git a/src/debug/debugcpu.c b/src/debug/debugcpu.c
index 0549788b..a295d1d3 100644
--- a/src/debug/debugcpu.c
+++ b/src/debug/debugcpu.c
@@ -885,7 +885,7 @@ void DebugCpu_Check(void)
{
Profile_CpuUpdate();
}
- if (LOG_TRACE_LEVEL((TRACE_CPU_DISASM|TRACE_CPU_SYMBOLS)))
+ if (LOG_TRACE_LEVEL((TRACE_CPU_DISASM|TRACE_SYMBOLS_CPU)))
{
DebugCpu_ShowAddressInfo(M68000_GetPC(), TraceFile);
}
@@ -933,7 +933,7 @@ void DebugCpu_SetDebugging(void)
nCpuActiveCBs = BreakCond_CpuBreakPointCount();
if (nCpuActiveCBs || nCpuSteps || bCpuProfiling || History_TrackCpu()
- || LOG_TRACE_LEVEL((TRACE_CPU_DISASM|TRACE_CPU_SYMBOLS|TRACE_CPU_REGS))
+ || LOG_TRACE_LEVEL((TRACE_CPU_DISASM|TRACE_SYMBOLS_CPU|TRACE_CPU_REGS))
|| ConOutDevice != CONOUT_DEVICE_NONE)
{
M68000_SetDebugger(true);
diff --git a/src/debug/debugdsp.c b/src/debug/debugdsp.c
index 01461115..550323af 100644
--- a/src/debug/debugdsp.c
+++ b/src/debug/debugdsp.c
@@ -516,7 +516,7 @@ void DebugDsp_Check(void)
{
Profile_DspUpdate();
}
- if (LOG_TRACE_LEVEL((TRACE_DSP_DISASM|TRACE_DSP_SYMBOLS)))
+ if (LOG_TRACE_LEVEL((TRACE_DSP_DISASM|TRACE_SYMBOLS_DSP)))
{
DebugDsp_ShowAddressInfo(DSP_GetPC(), TraceFile);
}
@@ -556,7 +556,7 @@ void DebugDsp_SetDebugging(void)
nDspActiveCBs = BreakCond_DspBreakPointCount();
if (nDspActiveCBs || nDspSteps || bDspProfiling || History_TrackDsp()
- || LOG_TRACE_LEVEL((TRACE_DSP_DISASM|TRACE_DSP_SYMBOLS)))
+ || LOG_TRACE_LEVEL((TRACE_DSP_DISASM|TRACE_SYMBOLS_DSP)))
{
DSP_SetDebugging(true);
nDspInstructions = 0;
diff --git a/src/debug/log.c b/src/debug/log.c
index 5fefccae..96b386e4 100644
--- a/src/debug/log.c
+++ b/src/debug/log.c
@@ -137,8 +137,8 @@ static flagname_t TraceFlags[] = {
{ TRACE_SCSIDRV , "scsidrv" },
- { TRACE_CPU_SYMBOLS , "symbols_cpu" },
- { TRACE_DSP_SYMBOLS , "symbols_dsp" },
+ { TRACE_SYMBOLS_CPU , "symbols_cpu" },
+ { TRACE_SYMBOLS_DSP , "symbols_dsp" },
{ TRACE_OS_VDI , "vdi" },
diff --git a/src/debug/log.h b/src/debug/log.h
index 1adcc94d..209d0302 100644
--- a/src/debug/log.h
+++ b/src/debug/log.h
@@ -102,89 +102,10 @@ extern char *Log_MatchTrace(const char *text, int state);
*/
#include "config.h"
-/* Up to 64 levels when using Uint64 for HatariTraceFlags */
-#define TRACE_VIDEO_SYNC (1<<0)
-#define TRACE_VIDEO_RES (1<<1)
-#define TRACE_VIDEO_COLOR (1<<2)
-#define TRACE_VIDEO_BORDER_V (1<<3)
-#define TRACE_VIDEO_BORDER_H (1<<4)
-#define TRACE_VIDEO_ADDR (1<<5)
-#define TRACE_VIDEO_VBL (1<<6)
-#define TRACE_VIDEO_HBL (1<<7)
-#define TRACE_VIDEO_STE (1<<8)
-
-#define TRACE_MFP_EXCEPTION (1<<9)
-#define TRACE_MFP_START (1<<10)
-#define TRACE_MFP_READ (1<<11)
-#define TRACE_MFP_WRITE (1<<12)
-
-#define TRACE_PSG_READ (1<<13)
-#define TRACE_PSG_WRITE (1<<14)
-
-#define TRACE_CPU_PAIRING (1<<15)
-#define TRACE_CPU_DISASM (1<<16)
-#define TRACE_CPU_EXCEPTION (1<<17)
-#define TRACE_CPU_REGS (1<<18)
-
-#define TRACE_INT (1<<19)
-
-#define TRACE_FDC (1<<20)
-
-#define TRACE_ACIA (1<<21)
-
-#define TRACE_IKBD_CMDS (1<<22)
-#define TRACE_IKBD_ACIA (1<<23)
-#define TRACE_IKBD_EXEC (1<<24)
-
-#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<<54)
-
-#define TRACE_VME (1ll<<55)
-
-#define TRACE_SCC (1ll<<56)
+/* Trace flag masks header is generated "traceflags.in" with:
+ * awk '{if ($1) {printf("#define %-25s (1ll<<%d)\n",$1,i); i++} else print}' < traceflags.in > traceflags.h
+ */
+#include "traceflags.h"
#define TRACE_NONE (0)
#define TRACE_ALL (~0)
diff --git a/src/debug/traceflags.awk b/src/debug/traceflags.awk
new file mode 100755
index 00000000..0c3c8f84
--- /dev/null
+++ b/src/debug/traceflags.awk
@@ -0,0 +1,9 @@
+#!/usr/bin/awk -f
+{
+ if ($1) {
+ printf("#define %-25s (1ll<<%d)\n", $1, i);
+ i++;
+ } else {
+ print
+ }
+}
diff --git a/src/debug/traceflags.in b/src/debug/traceflags.in
new file mode 100644
index 00000000..816cfba3
--- /dev/null
+++ b/src/debug/traceflags.in
@@ -0,0 +1,83 @@
+TRACE_ACIA
+
+TRACE_BLITTER
+
+TRACE_CPU_DISASM
+TRACE_CPU_EXCEPTION
+TRACE_CPU_PAIRING
+TRACE_CPU_REGS
+
+TRACE_CROSSBAR
+
+TRACE_DMASND
+
+TRACE_DSP_DISASM
+TRACE_DSP_DISASM_MEM
+TRACE_DSP_DISASM_REG
+TRACE_DSP_HOST_COMMAND
+TRACE_DSP_HOST_INTERFACE
+TRACE_DSP_HOST_SSI
+TRACE_DSP_INTERRUPT
+TRACE_DSP_STATE
+
+TRACE_FDC
+
+TRACE_IDE
+
+TRACE_IKBD_ACIA
+TRACE_IKBD_CMDS
+TRACE_IKBD_EXEC
+
+TRACE_INT
+
+TRACE_IOMEM_RD
+TRACE_IOMEM_WR
+
+TRACE_KEYMAP
+
+TRACE_MFP_EXCEPTION
+TRACE_MFP_READ
+TRACE_MFP_START
+TRACE_MFP_WRITE
+
+TRACE_MIDI
+
+TRACE_NATFEATS
+
+TRACE_NVRAM
+
+TRACE_OS_BASE
+
+TRACE_OS_AES
+TRACE_OS_BIOS
+TRACE_OS_GEMDOS
+TRACE_OS_VDI
+TRACE_OS_XBIOS
+
+TRACE_PSG_READ
+TRACE_PSG_WRITE
+
+TRACE_MEM
+
+TRACE_SCC
+
+TRACE_SCSI_CMD
+
+TRACE_SCSIDRV
+
+TRACE_SYMBOLS_CPU
+TRACE_SYMBOLS_DSP
+
+TRACE_VIDEL
+
+TRACE_VIDEO_ADDR
+TRACE_VIDEO_BORDER_V
+TRACE_VIDEO_BORDER_H
+TRACE_VIDEO_COLOR
+TRACE_VIDEO_HBL
+TRACE_VIDEO_RES
+TRACE_VIDEO_STE
+TRACE_VIDEO_SYNC
+TRACE_VIDEO_VBL
+
+TRACE_VME
--
2.20.1
--------------E7B5D6710D64CBC04EE9B161--