|
|
1.1 root 1: /*
2: Hatari - log.h
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6: */
7: #ifndef HATARI_LOG_H
8: #define HATARI_LOG_H
9:
10: #include <stdbool.h>
11: #include <SDL_types.h>
12:
13:
14: /* Logging
15: * -------
16: * Is always enabled as it's information that can be useful
17: * to the Hatari users
18: */
19: typedef enum
20: {
21: /* these present user with a dialog and log the issue */
22: LOG_FATAL, /* Hatari can't continue unless user resolves issue */
23: LOG_ERROR, /* something user did directly failed (e.g. save) */
24: /* these just log the issue */
25: LOG_WARN, /* something failed, but it's less serious */
26: LOG_INFO, /* user action success (e.g. TOS file load) */
27: LOG_TODO, /* functionality not yet being emulated */
28: LOG_DEBUG, /* information about internal Hatari working */
29: LOG_NONE /* invalid LOG level */
30: } LOGTYPE;
31:
32: #ifndef __GNUC__
33: /* assuming attributes work only for GCC */
34: #define __attribute__(foo)
35: #endif
36:
37: extern int Log_Init(void);
38: extern int Log_SetAlertLevel(int level);
39: extern void Log_UnInit(void);
40: extern void Log_Printf(LOGTYPE nType, const char *psFormat, ...)
41: __attribute__ ((format (printf, 2, 3)));
42: extern void Log_AlertDlg(LOGTYPE nType, const char *psFormat, ...)
43: __attribute__ ((format (printf, 2, 3)));
44: extern LOGTYPE Log_ParseOptions(const char *OptionStr);
45: extern const char* Log_SetTraceOptions(const char *OptionsStr);
46: extern char *Log_MatchTrace(const char *text, int state);
47:
48: #ifndef __GNUC__
49: #undef __attribute__
50: #endif
51:
52:
53:
54: /* Tracing
55: * -------
56: * Tracing outputs information about what happens in the emulated
57: * system and slows down the emulation. As it's intended mainly
58: * just for the Hatari developers, tracing support is compiled in
59: * by default.
60: *
61: * Tracing can be enabled by defining ENABLE_TRACING
62: * in the top level config.h
63: */
64: #include "config.h"
65:
1.1.1.2 root 66: /* Up to 64 levels when using Uint32 for HatariTraceFlags */
1.1 root 67:
68: #define TRACE_MFP_EXCEPTION (1<<9)
69: #define TRACE_MFP_START (1<<10)
70: #define TRACE_MFP_READ (1<<11)
71: #define TRACE_MFP_WRITE (1<<12)
72:
73: #define TRACE_PSG_READ (1<<13)
74: #define TRACE_PSG_WRITE (1<<14)
75:
76: #define TRACE_CPU_PAIRING (1<<15)
77: #define TRACE_CPU_DISASM (1<<16)
78: #define TRACE_CPU_EXCEPTION (1<<17)
79:
80: #define TRACE_INT (1<<18)
81:
82: #define TRACE_FDC (1<<19)
83:
84: #define TRACE_IKBD_CMDS (1<<20)
85: #define TRACE_IKBD_ACIA (1<<21)
86: #define TRACE_IKBD_EXEC (1<<22)
87:
1.1.1.2 root 88: #define TRACE_IOMEM_RD (1<<29)
89: #define TRACE_IOMEM_WR (1<<30)
1.1 root 90:
1.1.1.2 root 91: #define TRACE_DSP_HOST_INTERFACE (1ll<<34)
92: #define TRACE_DSP_HOST_COMMAND (1ll<<35)
93: #define TRACE_DSP_HOST_SSI (1ll<<36)
94: #define TRACE_DSP_DISASM (1ll<<37)
95: #define TRACE_DSP_DISASM_REG (1ll<<38)
96: #define TRACE_DSP_DISASM_MEM (1ll<<39)
97: #define TRACE_DSP_STATE (1ll<<40)
98: #define TRACE_DSP_INTERRUPT (1ll<<41)
1.1 root 99:
100: #define TRACE_NONE (0)
101: #define TRACE_ALL (~0)
102:
103: #define TRACE_PSG_ALL ( TRACE_PSG_READ | TRACE_PSG_WRITE )
104:
105: #define TRACE_CPU_ALL ( TRACE_CPU_PAIRING | TRACE_CPU_DISASM | TRACE_CPU_EXCEPTION )
106:
107: #define TRACE_IOMEM_ALL ( TRACE_IOMEM_RD | TRACE_IOMEM_WR )
108:
1.1.1.2 root 109: #define TRACE_DSP_ALL ( TRACE_DSP_HOST_INTERFACE | TRACE_DSP_HOST_COMMAND | TRACE_DSP_HOST_SSI | TRACE_DSP_DISASM \
110: | TRACE_DSP_DISASM_REG | TRACE_DSP_DISASM_MEM | TRACE_DSP_STATE | TRACE_DSP_INTERRUPT )
111:
1.1.1.3 root 112: /* Dummy for DSP */
113: #define ExceptionDebugMask 0
114: #define EXCEPT_DSP 0
1.1.1.2 root 115:
1.1 root 116:
117: extern FILE *TraceFile;
1.1.1.2 root 118: extern Uint64 LogTraceFlags;
1.1 root 119:
120: #if ENABLE_TRACING
121:
122: #ifndef _VCWIN_
123: #define LOG_TRACE(level, args...) \
124: if (unlikely(LogTraceFlags & level)) fprintf(TraceFile, args)
125: #endif
1.1.1.2 root 126: #define LOG_TRACE_LEVEL( level ) (unlikely(LogTraceFlags & level))
1.1 root 127:
128: #else /* ENABLE_TRACING */
129:
130: #ifndef _VCWIN_
131: #define LOG_TRACE(level, args...) {}
132: #endif
133: #define LOG_TRACE_LEVEL( level ) (0)
134:
135: #endif /* ENABLE_TRACING */
136:
137: /* Always defined in full to avoid compiler warnings about unused variables.
138: * In code it's used in such a way that it will be optimized away when tracing
139: * is disabled.
140: */
141: #ifndef _VCWIN_
142: #define LOG_TRACE_PRINT(args...) fprintf(TraceFile , args)
143: #endif
144:
145:
146: #endif /* HATARI_LOG_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.