Debian Codegraph @

ddebug/debug.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/lib/debug.h $
21 * $Revision: 23 $
22 * $Date: 4/19/00 5:20p $
23 * $Author: Matt $
24 *
25 * Debug functions
26 *
27 * $Log: /DescentIII/Main/lib/debug.h $
28 *
29 * 23 4/19/00 5:20p Matt
30 * From Duane for 1.4
31 * Mac debug_break changes
32 *
33 * 22 10/21/99 9:27p Jeff
34 * B.A. Macintosh code merge
35 *
36 * 21 7/28/99 3:25p Kevin
37 * Macintosh!
38 *
39 * 20 4/17/99 7:50p Jeff
40 * kill keyboard thread before int3 in linux (else it locks up)...temp
41 * hack until I replace ddio key
42 *
43 * 19 4/12/99 7:14p Samir
44 * added multiple pages per mono window.
45 *
46 * 18 1/13/99 6:47a Jeff
47 * fixed debug_break() for linux
48 *
49 * 17 1/09/99 1:11a Jeff
50 * put in #ifdef around some windows specific code
51 *
52 * 16 1/05/99 4:28p Kevin
53 * Moved exception handling code to windebug.cpp
54 *
55 * 15 10/18/98 8:52p Matt
56 * Revamped debug/error system.
57 *
58 * 14 10/13/98 12:03p Kevin
59 * Changed use of preprocessors for debug, etc.
60 *
61 * 13 10/12/98 10:20a Samir
62 * added parameter to debug init.
63 *
64 * 12 6/23/98 2:40p Matt
65 * Added Yes/No/Cancel type to OutrageMessageBox() and
66 * Debug_MesssageBox(), and changed return value from a bool to an
67 * integer.
68 *
69 * 11 5/12/98 11:45a Samir
70 * added logfile.
71 *
72 * 10 4/08/98 7:19p Samir
73 * Added runtime debugging option.
74 *
75 * 9 4/07/98 9:20p Samir
76 * Changes to debug stuff.
77 *
78 * 8 4/03/98 5:15p Samir
79 * Implemented simple debug message filtering.
80 *
81 * 7 3/20/98 2:43p Samir
82 * Some better Int3 support.
83 *
84 * 6 3/10/98 5:16p Samir
85 * Got debug callbacks working when you hit an Int3.
86 *
87 * 5 1/29/98 12:24p Samir
88 * Added logfile support.
89 *
90 * 4 1/28/98 11:17a Samir
91 * Added debugbreak stuff.
92 *
93 * 3 10/13/97 2:41p Samir
94 * Debug breaks now are macros to work depending on the operating system.
95 *
96 * 2 9/04/97 12:00p Matt
97 * Changed Debug_MessageBox() to return bool instead of int, since it was
98 * already being used that way.
99 *
100 * 1 6/10/97 4:54p Samir
101 * Took headers from gameos.h and isolated them.
102 *
103 * $NoKeywords: $
104 */
105 #ifndef DEBUG_H
106 #define DEBUG_H
107
108 // ---------------------------------------------------------------------------
109 // Debug system is a member of the 'platform' library.
110 // ---------------------------------------------------------------------------
111 // ---------------------------------------------------------------------------
112 // Constants
113 // ---------------------------------------------------------------------------
114 #ifndef IDOK
115 #define IDOK 1
116 #endif
117 #ifndef IDCANCEL
118 #define IDCANCEL 2
119 #endif
120 #ifndef IDABORT
121 #define IDABORT 3
122 #endif
123 #ifndef IDRETRY
124 #define IDRETRY 4
125 #endif
126 #ifndef IDIGNORE
127 #define IDIGNORE 5
128 #endif
129 #ifndef IDYES
130 #define IDYES 6
131 #endif
132 #ifndef IDNO
133 #define IDNO 7
134 #endif
135 // #define DEBUG_LEVEL 0 //DAJ
136 #if defined(WIN32) || defined(POSIX)
137 constexpr const int OSMBOX_OK = 1;
138 constexpr const int OSMBOX_YESNO = 2;
139 constexpr const int OSMBOX_YESNOCANCEL = 3;
140 constexpr const int OSMBOX_ABORTRETRYIGNORE = 4;
141 constexpr const int OSMBOX_OKCANCEL = 5;
142 #else
143 #define OSMBOX_OK 1
144 #define OSMBOX_YESNO 2
145 #define OSMBOX_YESNOCANCEL 3
146 #define OSMBOX_ABORTRETRYIGNORE 4
147 #define OSMBOX_OKCANCEL 5
148 #endif
149 // ---------------------------------------------------------------------------
150 // Functions
151 // ---------------------------------------------------------------------------
152 extern bool Debug_break;
153
154 // if we are running under a debugger, then pass true
155 bool Debug_Init(bool debugger);
156 // Does a messagebox with a stack dump
157 // Messagebox shows topstring, then stack dump, then bottomstring
158 // Return types are the same as the Windows return values
159 int Debug_ErrorBox(int type, const char *topstring, const char *title, const char *bottomstring);
160 // displays a message box
161 // Returns the same values as the Win32 MessageBox() function
162 int Debug_MessageBox(int type, const char *title, const char *str);
163
164 // these functions deal with debug spew support
165 bool Debug_Logfile(const char *filename);
166 void Debug_LogWrite(const char *str);
167 void Debug_ConsolePrintf(int n, const char *format, ...);
168 void Debug_ConsolePrintfAt(int n, int row, int col, const char *format, ...);
169
170 // DEBUGGING MACROS
171 // Break into the debugger, if this feature was enabled in Debug_init()
172 #if !defined(RELEASE)
173 #include "debugbreak.h"
174 #if defined(WIN32)
175 #elif defined(POSIX)
176 void ddio_InternalKeyClose();
177 #else
178 #define debug_break()
179 #endif
180 #else
181 #define debug_break()
182 #endif
183
184 #if defined(WIN32)
185
186 #include <windows.h>
187
188 long WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data);
189 #endif
190 #endif