| 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/linux/lnxdebug.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2000/04/18 00:00:39 $ |
| 23 | * $Author: icculus $ |
| 24 | * |
| 25 | * Linux debugging routines |
| 26 | * |
| 27 | * $Log: lnxdebug.cpp,v $ |
| 28 | * Revision 1.1.1.1 2000/04/18 00:00:39 icculus |
| 29 | * initial checkin |
| 30 | * |
| 31 | * |
| 32 | * 8 7/22/99 1:21p Jeff |
| 33 | * added 3rd debugging window |
| 34 | * |
| 35 | * 7 7/14/99 9:09p Jeff |
| 36 | * added comment header |
| 37 | * |
| 38 | * $NoKeywords: $ |
| 39 | */ |
| 40 | |
| 41 | #include <cstdio> |
| 42 | |
| 43 | #include "debug.h"cxx . . $ `<file>/ddebug/debug.h`/ |
| 44 | #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/ |
| 45 | |
| 46 | /////////////////////////////////////////////////////////////////////////////// |
| 47 | |
| 48 | bool Debug_breakcxx . . $ Debug_break. = false; |
| 49 | |
| 50 | static char *Debug_DumpInfocxx . . $ Debug_DumpInfo(41208ce6ca65dd58).(); |
| 51 | |
| 52 | // if we are running under a debugger, then pass true |
| 53 | bool Debug_Initcxx . . $ Debug_Init(efaadfb7dc14930a).(bool debugger) { |
| 54 | #ifndef RELEASE |
| 55 | Debug_breakcxx . . $ Debug_break. = debugger; |
| 56 | |
| 57 | if (Debug_breakcxx . . $ Debug_break.) |
| 58 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Debug Break enabled.\n"); |
| 59 | |
| 60 | #endif // ifndef RELEASE |
| 61 | |
| 62 | return true; |
| 63 | } |
| 64 | |
| 65 | // Does a messagebox with a stack dump |
| 66 | // Messagebox shows topstring, then stack dump, then bottomstring |
| 67 | // Return types are the same as the Windows return values |
| 68 | int Debug_ErrorBoxcxx . . $ Debug_ErrorBox(d78f249273f0ce78).(int type, const char *topstring, const char *title, const char *bottomstring) { |
| 69 | int answer = 0; |
| 70 | char *dumptext = Debug_DumpInfocxx . . $ Debug_DumpInfo(41208ce6ca65dd58).(); |
| 71 | |
| 72 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\r\n%s(%s)\r\n\n%s\r\n\n%s\r\n", title, topstring, dumptext, bottomstring); |
| 73 | |
| 74 | debug_break(); |
| 75 | |
| 76 | return answer; |
| 77 | } |
| 78 | |
| 79 | // displays an message box |
| 80 | // Returns the same values as the Win32 MessageBox() function |
| 81 | int Debug_MessageBoxcxx . . $ Debug_MessageBox(9ee5302023219b2d).(int type, const char *title, const char *str) { |
| 82 | return Debug_ErrorBoxcxx . . $ Debug_ErrorBox(d78f249273f0ce78).(type, str, "Descent 3 Message", ""); |
| 83 | } |
| 84 | |
| 85 | /////////////////////////////////////////////////////////////////////////////// |
| 86 | |
| 87 | char *Debug_DumpInfocxx . . $ Debug_DumpInfo(41208ce6ca65dd58).() { |
| 88 | static char e[] = "System Error"; |
| 89 | return e; |
| 90 | } |