mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Unify Debug_Init() for all platforms
This commit is contained in:
parent
585a3804c4
commit
21576c86a5
@ -1,8 +1,10 @@
|
||||
set(HEADERS
|
||||
debug.h
|
||||
debugbreak.h
|
||||
mono.h)
|
||||
mono.h
|
||||
)
|
||||
set(CPPS
|
||||
debug.cpp
|
||||
$<$<PLATFORM_ID:Darwin,Linux,OpenBSD>:
|
||||
lnxdebug.cpp
|
||||
lnxmono.cpp
|
||||
@ -22,8 +24,9 @@ target_include_directories(ddebug PUBLIC
|
||||
PRIVATE ${PROJECT_BINARY_DIR}/lib # For d3_version.h
|
||||
)
|
||||
target_link_libraries(ddebug PRIVATE
|
||||
mem
|
||||
logger
|
||||
$<$<PLATFORM_ID:Windows>:
|
||||
mem
|
||||
misc
|
||||
>
|
||||
)
|
||||
|
31
ddebug/debug.cpp
Normal file
31
ddebug/debug.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Descent 3
|
||||
* Copyright (C) 2024 Descent Developers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "log.h"
|
||||
|
||||
bool Debug_break = false;
|
||||
|
||||
bool Debug_Init(bool debugger) {
|
||||
#ifndef RELEASE
|
||||
Debug_break = debugger;
|
||||
LOG_DEBUG_IF(Debug_break) << "Debug Break enabled.";
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
@ -41,50 +41,26 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "debug.h"
|
||||
#include "mono.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Debug_break = false;
|
||||
|
||||
static char *Debug_DumpInfo();
|
||||
|
||||
// if we are running under a debugger, then pass true
|
||||
bool Debug_Init(bool debugger) {
|
||||
#ifndef RELEASE
|
||||
Debug_break = debugger;
|
||||
|
||||
if (Debug_break)
|
||||
mprintf(0, "Debug Break enabled.\n");
|
||||
|
||||
#endif // ifndef RELEASE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Does a messagebox with a stack dump
|
||||
// Messagebox shows topstring, then stack dump, then bottomstring
|
||||
// Return types are the same as the Windows return values
|
||||
int Debug_ErrorBox(int type, const char *topstring, const char *title, const char *bottomstring) {
|
||||
int answer = 0;
|
||||
char *dumptext = Debug_DumpInfo();
|
||||
|
||||
fprintf(stderr, "\r\n%s(%s)\r\n\n%s\r\n\n%s\r\n", title, topstring, dumptext, bottomstring);
|
||||
fprintf(stderr, "\n%s(%s)\n\n%s\n\n%s\n", title, topstring, "System Error", bottomstring);
|
||||
|
||||
debug_break();
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
// displays an message box
|
||||
// displays a message box
|
||||
// Returns the same values as the Win32 MessageBox() function
|
||||
int Debug_MessageBox(int type, const char *title, const char *str) {
|
||||
return Debug_ErrorBox(type, str, "Descent 3 Message", "");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char *Debug_DumpInfo() {
|
||||
static char e[] = "System Error";
|
||||
return e;
|
||||
}
|
||||
|
@ -199,26 +199,6 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Debug_break = false;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Debug_Init(bool debugger) {
|
||||
// initialization of debugging consoles.
|
||||
|
||||
#ifndef RELEASE
|
||||
|
||||
Debug_break = debugger;
|
||||
|
||||
if (Debug_break) {
|
||||
mprintf(0, "Debug Break enabled.\n");
|
||||
}
|
||||
|
||||
#endif // ifndef RELEASE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Message Box functions */
|
||||
|
||||
// Does a messagebox with a stack dump
|
||||
|
Loading…
Reference in New Issue
Block a user