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