|
|
1.1 root 1: /*
2: Hatari - log.h
3:
1.1.1.5 root 4: This file is distributed under the GNU General Public License, version 2
5: or at your option any later version. Read the file gpl.txt for details.
1.1 root 6: */
7: #ifndef HATARI_LOG_H
8: #define HATARI_LOG_H
9:
10: #include <stdbool.h>
11: #include <SDL_types.h>
12:
13:
1.1.1.6 root 14: /* Exception debugging
15: * -------------------
16: */
17:
18: /* CPU exception flags
19: * is catching needed also for: traps 0, 3-12, 15? (MonST catches them)
20: */
21: #define EXCEPT_BUS (1<<0)
22: #define EXCEPT_ADDRESS (1<<1)
23: #define EXCEPT_ILLEGAL (1<<2)
24: #define EXCEPT_ZERODIV (1<<3)
25: #define EXCEPT_CHK (1<<4)
26: #define EXCEPT_TRAPV (1<<5)
27: #define EXCEPT_PRIVILEGE (1<<6)
1.1.1.8 root 28: #define EXCEPT_TRACE (1<<7)
29: #define EXCEPT_NOHANDLER (1<<8)
1.1.1.6 root 30:
31: /* DSP exception flags */
1.1.1.8 root 32: #define EXCEPT_DSP (1<<9)
1.1.1.6 root 33:
34: /* whether to enable exception debugging on autostart */
1.1.1.8 root 35: #define EXCEPT_AUTOSTART (1<<10)
1.1.1.6 root 36:
37: /* general flags */
38: #define EXCEPT_NONE (0)
39: #define EXCEPT_ALL (~EXCEPT_AUTOSTART)
40:
41: /* defaults are same as with earlier -D option */
42: #define DEFAULT_EXCEPTIONS (EXCEPT_BUS|EXCEPT_ADDRESS|EXCEPT_DSP)
43:
44: extern int ExceptionDebugMask;
45: extern const char* Log_SetExceptionDebugMask(const char *OptionsStr);
46:
47:
1.1 root 48: /* Logging
49: * -------
50: * Is always enabled as it's information that can be useful
51: * to the Hatari users
52: */
53: typedef enum
54: {
55: /* these present user with a dialog and log the issue */
56: LOG_FATAL, /* Hatari can't continue unless user resolves issue */
57: LOG_ERROR, /* something user did directly failed (e.g. save) */
58: /* these just log the issue */
59: LOG_WARN, /* something failed, but it's less serious */
60: LOG_INFO, /* user action success (e.g. TOS file load) */
61: LOG_TODO, /* functionality not yet being emulated */
62: LOG_DEBUG, /* information about internal Hatari working */
63: LOG_NONE /* invalid LOG level */
64: } LOGTYPE;
65:
1.1.1.10! root 66: #define LOG_NAMES {"FATAL", "ERROR", "WARN ", "INFO ", "TODO ", "DEBUG"}
! 67:
! 68:
1.1 root 69: #ifndef __GNUC__
70: /* assuming attributes work only for GCC */
71: #define __attribute__(foo)
72: #endif
73:
1.1.1.7 root 74: extern void Log_Default(void);
1.1.1.10! root 75: extern void Log_SetLevels(void);
1.1 root 76: extern int Log_Init(void);
77: extern int Log_SetAlertLevel(int level);
78: extern void Log_UnInit(void);
79: extern void Log_Printf(LOGTYPE nType, const char *psFormat, ...)
80: __attribute__ ((format (printf, 2, 3)));
81: extern void Log_AlertDlg(LOGTYPE nType, const char *psFormat, ...)
82: __attribute__ ((format (printf, 2, 3)));
83: extern LOGTYPE Log_ParseOptions(const char *OptionStr);
84: extern const char* Log_SetTraceOptions(const char *OptionsStr);
85: extern char *Log_MatchTrace(const char *text, int state);
86:
87: #ifndef __GNUC__
88: #undef __attribute__
89: #endif
90:
91:
92:
93: /* Tracing
94: * -------
95: * Tracing outputs information about what happens in the emulated
96: * system and slows down the emulation. As it's intended mainly
97: * just for the Hatari developers, tracing support is compiled in
98: * by default.
99: *
100: * Tracing can be enabled by defining ENABLE_TRACING
101: * in the top level config.h
102: */
103: #include "config.h"
104:
1.1.1.2 root 105: /* Up to 64 levels when using Uint64 for HatariTraceFlags */
1.1 root 106: #define TRACE_VIDEO_SYNC (1<<0)
107: #define TRACE_VIDEO_RES (1<<1)
108: #define TRACE_VIDEO_COLOR (1<<2)
109: #define TRACE_VIDEO_BORDER_V (1<<3)
110: #define TRACE_VIDEO_BORDER_H (1<<4)
111: #define TRACE_VIDEO_ADDR (1<<5)
112: #define TRACE_VIDEO_VBL (1<<6)
113: #define TRACE_VIDEO_HBL (1<<7)
114: #define TRACE_VIDEO_STE (1<<8)
115:
116: #define TRACE_MFP_EXCEPTION (1<<9)
117: #define TRACE_MFP_START (1<<10)
118: #define TRACE_MFP_READ (1<<11)
119: #define TRACE_MFP_WRITE (1<<12)
120:
121: #define TRACE_PSG_READ (1<<13)
122: #define TRACE_PSG_WRITE (1<<14)
123:
124: #define TRACE_CPU_PAIRING (1<<15)
125: #define TRACE_CPU_DISASM (1<<16)
126: #define TRACE_CPU_EXCEPTION (1<<17)
1.1.1.9 root 127: #define TRACE_CPU_REGS (1<<18)
1.1 root 128:
1.1.1.9 root 129: #define TRACE_INT (1<<19)
1.1 root 130:
1.1.1.9 root 131: #define TRACE_FDC (1<<20)
1.1 root 132:
1.1.1.9 root 133: #define TRACE_ACIA (1<<21)
1.1 root 134:
1.1.1.9 root 135: #define TRACE_IKBD_CMDS (1<<22)
136: #define TRACE_IKBD_ACIA (1<<23)
137: #define TRACE_IKBD_EXEC (1<<24)
1.1.1.5 root 138:
1.1.1.9 root 139: #define TRACE_BLITTER (1<<25)
1.1.1.5 root 140:
1.1.1.9 root 141: #define TRACE_OS_BIOS (1<<26)
142: #define TRACE_OS_XBIOS (1<<27)
143: #define TRACE_OS_GEMDOS (1<<28)
144: #define TRACE_OS_VDI (1<<29)
145: #define TRACE_OS_AES (1<<30)
1.1.1.5 root 146:
1.1.1.9 root 147: #define TRACE_IOMEM_RD (1ll<<31)
148: #define TRACE_IOMEM_WR (1ll<<32)
1.1.1.5 root 149:
1.1.1.9 root 150: #define TRACE_DMASND (1ll<<33)
1.1.1.5 root 151:
1.1.1.9 root 152: #define TRACE_CROSSBAR (1ll<<34)
153: #define TRACE_VIDEL (1ll<<35)
1.1.1.5 root 154:
1.1.1.9 root 155: #define TRACE_DSP_HOST_INTERFACE (1ll<<36)
156: #define TRACE_DSP_HOST_COMMAND (1ll<<37)
157: #define TRACE_DSP_HOST_SSI (1ll<<38)
158: #define TRACE_DSP_DISASM (1ll<<39)
159: #define TRACE_DSP_DISASM_REG (1ll<<40)
160: #define TRACE_DSP_DISASM_MEM (1ll<<41)
161: #define TRACE_DSP_STATE (1ll<<42)
162: #define TRACE_DSP_INTERRUPT (1ll<<43)
1.1.1.5 root 163:
1.1.1.9 root 164: #define TRACE_DSP_SYMBOLS (1ll<<44)
165: #define TRACE_CPU_SYMBOLS (1ll<<45)
1.1.1.5 root 166:
1.1.1.9 root 167: #define TRACE_NVRAM (1ll<<46)
1.1.1.4 root 168:
1.1.1.9 root 169: #define TRACE_SCSI_CMD (1ll<<47)
1.1.1.6 root 170:
1.1.1.9 root 171: #define TRACE_NATFEATS (1ll<<48)
1.1.1.6 root 172:
1.1.1.9 root 173: #define TRACE_KEYMAP (1ll<<49)
1.1.1.7 root 174:
1.1.1.9 root 175: #define TRACE_MIDI (1ll<<50)
1.1.1.7 root 176:
1.1.1.9 root 177: #define TRACE_IDE (1ll<<51)
1.1.1.7 root 178:
1.1.1.9 root 179: #define TRACE_OS_BASE (1ll<<52)
1.1.1.7 root 180:
1.1.1.9 root 181: #define TRACE_SCSIDRV (1ll<<53)
1.1.1.8 root 182:
1.1.1.9 root 183: #define TRACE_MEM (1ll<<54)
184:
1.1 root 185: #define TRACE_NONE (0)
186: #define TRACE_ALL (~0)
187:
188:
189: #define TRACE_VIDEO_ALL ( TRACE_VIDEO_SYNC | TRACE_VIDEO_RES | TRACE_VIDEO_COLOR \
190: | TRACE_VIDEO_BORDER_V | TRACE_VIDEO_BORDER_H | TRACE_VIDEO_ADDR \
191: | TRACE_VIDEO_VBL | TRACE_VIDEO_HBL | TRACE_VIDEO_STE )
192:
193: #define TRACE_MFP_ALL ( TRACE_MFP_EXCEPTION | TRACE_MFP_START | TRACE_MFP_READ | TRACE_MFP_WRITE )
194:
195: #define TRACE_PSG_ALL ( TRACE_PSG_READ | TRACE_PSG_WRITE )
196:
197: #define TRACE_CPU_ALL ( TRACE_CPU_PAIRING | TRACE_CPU_DISASM | TRACE_CPU_EXCEPTION )
198:
1.1.1.2 root 199: #define TRACE_IKBD_ALL ( TRACE_IKBD_CMDS | TRACE_IKBD_ACIA | TRACE_IKBD_EXEC )
1.1 root 200:
1.1.1.7 root 201: #define TRACE_OS_ALL ( TRACE_OS_BASE | TRACE_OS_BIOS | TRACE_OS_XBIOS | TRACE_OS_GEMDOS | TRACE_OS_AES | TRACE_OS_VDI )
1.1 root 202:
203: #define TRACE_IOMEM_ALL ( TRACE_IOMEM_RD | TRACE_IOMEM_WR )
204:
1.1.1.2 root 205: #define TRACE_DSP_ALL ( TRACE_DSP_HOST_INTERFACE | TRACE_DSP_HOST_COMMAND | TRACE_DSP_HOST_SSI | TRACE_DSP_DISASM \
206: | TRACE_DSP_DISASM_REG | TRACE_DSP_DISASM_MEM | TRACE_DSP_STATE | TRACE_DSP_INTERRUPT )
1.1 root 207:
208: extern FILE *TraceFile;
1.1.1.2 root 209: extern Uint64 LogTraceFlags;
1.1 root 210:
211: #if ENABLE_TRACING
212:
1.1.1.8 root 213: #define LOG_TRACE(level, ...) \
214: if (unlikely(LogTraceFlags & (level))) { fprintf(TraceFile, __VA_ARGS__); fflush(TraceFile); }
215:
1.1.1.7 root 216: #define LOG_TRACE_LEVEL( level ) (unlikely(LogTraceFlags & (level)))
1.1 root 217:
218: #else /* ENABLE_TRACING */
219:
1.1.1.8 root 220: #define LOG_TRACE(level, ...) {}
221:
1.1 root 222: #define LOG_TRACE_LEVEL( level ) (0)
223:
224: #endif /* ENABLE_TRACING */
225:
226: /* Always defined in full to avoid compiler warnings about unused variables.
227: * In code it's used in such a way that it will be optimized away when tracing
228: * is disabled.
229: */
1.1.1.8 root 230: #define LOG_TRACE_PRINT(...) fprintf(TraceFile , __VA_ARGS__)
1.1 root 231:
232:
233: #endif /* HATARI_LOG_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.