Skip to content

Commit 2eaf1dc

Browse files
authored
[CMAKE][ZH] Fix compile errors and add cmake options for DEBUG_LOGGING, DEBUG_CRASHING, DEBUG_STACKTRACE, DEBUG_PROFILE (#667)
1 parent b0528cf commit 2eaf1dc

File tree

74 files changed

+338
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+338
-242
lines changed

Core/Libraries/Source/Compression/CompressionManager.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern "C" {
3737
//#pragma message("************************************** WARNING, optimization disabled for debugging purposes")
3838
#endif
3939

40+
// TheSuperHackers @todo Recover debug logging in this file?
4041
#define DEBUG_LOG(x) {}
4142

4243
const char *CompressionManager::getCompressionNameByType( CompressionType compType )
@@ -328,10 +329,6 @@ Int CompressionManager::decompressData( void *srcVoid, Int srcLen, void *destVoi
328329

329330
if (compType >= COMPRESSION_ZLIB1 && compType <= COMPRESSION_ZLIB9)
330331
{
331-
#ifdef DEBUG_LOGGING
332-
Int level = compType - COMPRESSION_ZLIB1 + 1; // 1-9
333-
#endif
334-
335332
unsigned long outLen = destLen;
336333
Int err = z_uncompress(dest, &outLen, src+8, srcLen-8);
337334
if (err == Z_OK || err == Z_STREAM_END)
@@ -340,7 +337,8 @@ Int CompressionManager::decompressData( void *srcVoid, Int srcLen, void *destVoi
340337
}
341338
else
342339
{
343-
DEBUG_LOG(("ZLib decompression error (src is level %d, %d bytes long) %d\n", level, srcLen, err));
340+
DEBUG_LOG(("ZLib decompression error (src is level %d, %d bytes long) %d\n",
341+
compType - COMPRESSION_ZLIB1 + 1 /* 1-9 */, srcLen, err));
344342
return 0;
345343
}
346344
}

Generals/Code/GameEngine/Include/Common/Debug.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class AsciiString;
6666
// by default, turn on ALLOW_DEBUG_UTILS if _DEBUG is turned on.
6767
#if (defined(_DEBUG) || defined(_INTERNAL)) && !defined(ALLOW_DEBUG_UTILS) && !defined(DISABLE_ALLOW_DEBUG_UTILS)
6868
#define ALLOW_DEBUG_UTILS 1
69+
#elif defined(DEBUG_LOGGING) || defined(DEBUG_CRASHING) || defined(DEBUG_STACKTRACE) || defined(DEBUG_PROFILE)
70+
// TheSuperHackers @tweak also turn on when any of the above options is already set.
71+
#define ALLOW_DEBUG_UTILS 1
6972
#endif
7073

7174
// these are predicated on ALLOW_DEBUG_UTILS, not _DEBUG, and allow you to selectively disable
@@ -76,10 +79,11 @@ class AsciiString;
7679
#if defined(ALLOW_DEBUG_UTILS) && !defined(DEBUG_CRASHING) && !defined(DISABLE_DEBUG_CRASHING)
7780
#define DEBUG_CRASHING 1
7881
#endif
79-
80-
// BGC - added the DEBUG_LOGGING term...doesn't make sense to do stack debugging without a debug log to print to.
81-
#if defined(ALLOW_DEBUG_UTILS) && !defined(DEBUG_STACKTRACE) && !defined(DISABLE_DEBUG_STACKTRACE) && defined(DEBUG_LOGGING)
82+
#if defined(ALLOW_DEBUG_UTILS) && !defined(DEBUG_STACKTRACE) && !defined(DISABLE_DEBUG_STACKTRACE)
8283
#define DEBUG_STACKTRACE 1
84+
#ifndef DEBUG_LOGGING
85+
#define DEBUG_LOGGING 1 // TheSuperHackers @compile Stack trace requires logging.
86+
#endif
8387
#endif
8488
#if defined(ALLOW_DEBUG_UTILS) && !defined(DEBUG_PROFILE) && !defined(DISABLE_DEBUG_PROFILE)
8589
#define DEBUG_PROFILE 1

Generals/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,6 @@ class GlobalData : public SubsystemInterface
469469
Real m_debugProjectileTileWidth; ///< How wide should these tiles be?
470470
Int m_debugProjectileTileDuration; ///< How long should these tiles stay around, in frames?
471471
RGBColor m_debugProjectileTileColor; ///< What color should these tiles be?
472-
Bool m_debugIgnoreAsserts; ///< Ignore all asserts.
473-
Bool m_debugIgnoreStackTrace; ///< No stacktraces for asserts.
474472
Bool m_showCollisionExtents; ///< Used to display collision extents
475473
Bool m_saveStats;
476474
Bool m_saveAllStats;
@@ -484,6 +482,14 @@ class GlobalData : public SubsystemInterface
484482
Int m_packetLoss; ///< Percent of packets to drop
485483
#endif
486484

485+
#ifdef DEBUG_CRASHING
486+
Bool m_debugIgnoreAsserts; ///< Ignore all asserts.
487+
#endif
488+
489+
#ifdef DEBUG_STACKTRACE
490+
Bool m_debugIgnoreStackTrace; ///< No stacktraces for asserts.
491+
#endif
492+
487493
Bool m_isBreakableMovie; ///< if we enter a breakable movie, set this flag
488494
Bool m_breakTheMovie; ///< The user has hit escape!
489495

Generals/Code/GameEngine/Include/Common/INI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class INI
399399
const char *m_sepsQuote; ///< token to represent a quoted ascii string
400400
const char *m_blockEndToken; ///< token to represent end of data block
401401
Bool m_endOfFile; ///< TRUE when we've hit EOF
402-
#if defined(_DEBUG) || defined(_INTERNAL)
402+
#ifdef DEBUG_CRASHING
403403
char m_curBlockStart[ INI_MAX_CHARS_PER_LINE ]; ///< first line of cur block
404404
#endif
405405
};

Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface
629629

630630
// this is intended for use ONLY by AIFollowPathState.
631631
inline void friend_setCurrentGoalPathIndex( Int index ) { m_nextGoalPathIndex = index; }
632-
#if defined(_DEBUG) || defined(_INTERNAL)
632+
#ifdef DEBUG_LOGGING
633633
inline const Coord3D *friend_getRequestedDestination() const { return &m_requestedDestination; }
634634
inline const Coord3D *friend_getRequestedDestination2() const { return &m_requestedDestination2; }
635635
#endif

Generals/Code/GameEngine/Include/GameNetwork/udp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ class UDP
124124
Int AllowBroadcasts(Bool status);
125125
};
126126

127+
#ifdef DEBUG_LOGGING
127128
AsciiString GetWSAErrorString( Int error );
129+
#endif
128130

129131
#endif

Generals/Code/GameEngine/Source/Common/CommandLine.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "Common/version.h"
3333
#include "GameClient/TerrainVisual.h" // for TERRAIN_LOD_MIN definition
3434
#include "GameClient/GameText.h"
35+
#include "GameNetwork/NetworkDefs.h"
3536

3637
Bool TheDebugIgnoreSyncErrors = FALSE;
3738
extern Int DX8Wrapper_PreserveFPU;
@@ -103,9 +104,7 @@ static void ConvertShortMapPathToLongMapPath(AsciiString &mapName)
103104
//=============================================================================
104105
Int parseNoLogOrCrash(char *args[], int)
105106
{
106-
#ifdef ALLOW_DEBUG_UTILS
107107
DEBUG_CRASH(("-NoLogOrCrash not supported in this build\n"));
108-
#endif
109108
return 1;
110109
}
111110

@@ -325,7 +324,9 @@ Int parseNoDraw(char *args[], int argc)
325324
//=============================================================================
326325
Int parseLogToConsole(char *args[], int)
327326
{
327+
#ifdef ALLOW_DEBUG_UTILS
328328
DebugSetFlags(DebugGetFlags() | DEBUG_FLAG_LOG_TO_CONSOLE);
329+
#endif
329330
return 1;
330331
}
331332

@@ -950,7 +951,7 @@ Int parseBenchmark(char *args[], int num)
950951
}
951952
#endif
952953

953-
#if defined(_DEBUG) || defined(_INTERNAL)
954+
#ifdef DEBUG_CRASHING
954955
Int parseIgnoreAsserts(char *args[], int num)
955956
{
956957
if (TheWritableGlobalData && num > 0)
@@ -961,7 +962,7 @@ Int parseIgnoreAsserts(char *args[], int num)
961962
}
962963
#endif
963964

964-
#if defined(_DEBUG) || defined(_INTERNAL)
965+
#ifdef DEBUG_STACKTRACE
965966
Int parseIgnoreStackTrace(char *args[], int num)
966967
{
967968
if (TheWritableGlobalData && num > 0)
@@ -1058,7 +1059,7 @@ Int parseMod(char *args[], Int num)
10581059
return 1;
10591060
}
10601061

1061-
#if defined(_DEBUG) || defined(_INTERNAL)
1062+
#ifdef DEBUG_LOGGING
10621063
Int parseSetDebugLevel(char *args[], int num)
10631064
{
10641065
if (num > 1)
@@ -1113,7 +1114,6 @@ static CommandLineParam params[] =
11131114
{ "-novideo", parseNoVideo },
11141115
{ "-noLogOrCrash", parseNoLogOrCrash },
11151116
{ "-FPUPreserve", parseFPUPreserve },
1116-
#if defined(_DEBUG) || defined(_INTERNAL)
11171117
{ "-benchmark", parseBenchmark },
11181118
{ "-saveStats", parseSaveStats },
11191119
{ "-localMOTD", parseLocalMOTD },
@@ -1161,16 +1161,11 @@ static CommandLineParam params[] =
11611161
{ "-netMinPlayers", parseNetMinPlayers },
11621162
{ "-DemoLoadScreen", parseDemoLoadScreen },
11631163
{ "-cameraDebug", parseCameraDebug },
1164-
{ "-ignoreAsserts", parseIgnoreAsserts },
1165-
{ "-ignoreStackTrace", parseIgnoreStackTrace },
11661164
{ "-logToCon", parseLogToConsole },
11671165
{ "-vTune", parseVTune },
11681166
{ "-selectTheUnselectable", parseSelectAll },
11691167
{ "-RunAhead", parseRunAhead },
11701168
{ "-noshroud", parseNoShroud },
1171-
{ "-setDebugLevel", parseSetDebugLevel },
1172-
{ "-clearDebugLevel", parseClearDebugLevel },
1173-
#endif
11741169
{ "-forceBenchmark", parseForceBenchmark },
11751170
{ "-buildmapcache", parseBuildMapCache },
11761171
{ "-noshadowvolumes", parseNoShadows },
@@ -1190,6 +1185,19 @@ static CommandLineParam params[] =
11901185
{ "-updateImages", parseUpdateImages },
11911186
{ "-showTeamDot", parseShowTeamDot },
11921187
#endif
1188+
1189+
#ifdef DEBUG_LOGGING
1190+
{ "-setDebugLevel", parseSetDebugLevel },
1191+
{ "-clearDebugLevel", parseClearDebugLevel },
1192+
#endif
1193+
1194+
#ifdef DEBUG_CRASHING
1195+
{ "-ignoreAsserts", parseIgnoreAsserts },
1196+
#endif
1197+
1198+
#ifdef DEBUG_STACKTRACE
1199+
{ "-ignoreStackTrace", parseIgnoreStackTrace },
1200+
#endif
11931201
};
11941202

11951203
// parseCommandLine ===========================================================

Generals/Code/GameEngine/Source/Common/GameEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void GameEngine::init( int argc, char *argv[] )
262262
#elif defined _INTERNAL
263263
const char *buildType = "Internal";
264264
#else
265-
// const char *buildType = "Release";
265+
const char *buildType = "Release";
266266
#endif
267267
#endif // DEBUG_LOGGING
268268
DEBUG_LOG(("Generals version %s (%s)\n", TheVersion->getAsciiVersion().str(), buildType));

Generals/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,6 @@ GlobalData::GlobalData()
564564
m_debugCashValueMap = FALSE;
565565
m_maxDebugValue = 10000;
566566
m_debugCashValueMapTileDuration = LOGICFRAMES_PER_SECOND; // Changed By Sadullah Nader
567-
m_debugIgnoreAsserts = FALSE;
568-
m_debugIgnoreStackTrace = FALSE;
569567
m_vTune = false;
570568
m_checkForLeaks = TRUE;
571569
m_benchmarkTimer = -1;
@@ -585,6 +583,14 @@ GlobalData::GlobalData()
585583
m_MOTDPath = "MOTD.txt";
586584
#endif
587585

586+
#ifdef DEBUG_CRASHING
587+
m_debugIgnoreAsserts = FALSE;
588+
#endif
589+
590+
#ifdef DEBUG_STACKTRACE
591+
m_debugIgnoreStackTrace = FALSE;
592+
#endif
593+
588594
m_playStats = -1;
589595
m_incrementalAGPBuf = FALSE;
590596
m_mapName.clear();

Generals/Code/GameEngine/Source/Common/INI/INI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ INI::INI( void )
190190
m_blockEndToken = "END";
191191
m_endOfFile = FALSE;
192192
m_buffer[0] = 0;
193-
#if defined(_DEBUG) || defined(_INTERNAL)
193+
#ifdef DEBUG_CRASHING
194194
m_curBlockStart[0] = 0;
195195
#endif
196196

@@ -368,7 +368,7 @@ void INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer )
368368
INIBlockParse parse = findBlockParse(token);
369369
if (parse)
370370
{
371-
#if defined(_DEBUG) || defined(_INTERNAL)
371+
#ifdef DEBUG_CRASHING
372372
strcpy(m_curBlockStart, m_buffer);
373373
#endif
374374
try {
@@ -381,7 +381,7 @@ void INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer )
381381

382382
throw INIException(buff);
383383
}
384-
#if defined(_DEBUG) || defined(_INTERNAL)
384+
#ifdef DEBUG_CRASHING
385385
strcpy(m_curBlockStart, "NO_BLOCK");
386386
#endif
387387
}

0 commit comments

Comments
 (0)