Descent3/ddebug/lnxdebug.cpp

91 lines
2.3 KiB
C++
Raw Normal View History

/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* 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/>.
--- HISTORICAL COMMENTS FOLLOW ---
2024-04-16 18:56:40 +00:00
* $Logfile: /DescentIII/Main/linux/lnxdebug.cpp $
* $Revision: 1.1.1.1 $
* $Date: 2000/04/18 00:00:39 $
* $Author: icculus $
*
* Linux debugging routines
*
* $Log: lnxdebug.cpp,v $
* Revision 1.1.1.1 2000/04/18 00:00:39 icculus
* initial checkin
*
*
2024-04-16 03:43:29 +00:00
* 8 7/22/99 1:21p Jeff
* added 3rd debugging window
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 7 7/14/99 9:09p Jeff
* added comment header
2024-04-16 18:56:40 +00:00
*
* $NoKeywords: $
*/
2024-04-16 03:43:29 +00:00
#include <cstdio>
2024-04-16 03:43:29 +00:00
#include "debug.h"
#include "mono.h"
///////////////////////////////////////////////////////////////////////////////
2024-04-16 18:56:40 +00:00
bool Debug_break = false;
2024-04-16 03:43:29 +00:00
static char *Debug_DumpInfo();
2024-04-16 03:43:29 +00:00
// if we are running under a debugger, then pass true
bool Debug_Init(bool debugger) {
2024-04-16 03:43:29 +00:00
#ifndef RELEASE
2024-04-16 18:56:40 +00:00
Debug_break = debugger;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
if (Debug_break)
2024-05-24 15:46:07 +00:00
mprintf(0, "Debug Break enabled.\n");
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
#endif // ifndef RELEASE
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
return true;
2024-04-16 03:43:29 +00:00
}
2024-04-16 18:56:40 +00:00
// 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();
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
fprintf(stderr, "\r\n%s(%s)\r\n\n%s\r\n\n%s\r\n", title, topstring, dumptext, bottomstring);
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
debug_break();
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
return answer;
2024-04-16 03:43:29 +00:00
}
2024-04-16 18:56:40 +00:00
// displays an message box
2024-04-16 03:43:29 +00:00
// Returns the same values as the Win32 MessageBox() function
2024-04-16 18:56:40 +00:00
int Debug_MessageBox(int type, const char *title, const char *str) {
return Debug_ErrorBox(type, str, "Descent 3 Message", "");
2024-04-16 03:43:29 +00:00
}
///////////////////////////////////////////////////////////////////////////////
char *Debug_DumpInfo() {
2024-04-16 18:56:40 +00:00
static char e[] = "System Error";
return e;
}