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