Skip to content

Commit 2896291

Browse files
committed
Address review feedback
1 parent 7187333 commit 2896291

File tree

9 files changed

+251
-154
lines changed

9 files changed

+251
-154
lines changed

Core/GameEngine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ target_include_directories(corei_gameengine_private INTERFACE
11731173

11741174
target_link_libraries(corei_gameengine_private INTERFACE
11751175
corei_always
1176+
$<$<AND:$<BOOL:${IS_VS6_BUILD}>,$<BOOL:${RTS_CRASHDUMP_ENABLE}>>:shlwapi.lib>
11761177
)
11771178

11781179
target_compile_definitions(corei_gameengine_private INTERFACE

Core/GameEngine/Include/Common/GameMemory.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,17 @@ enum { MAX_SPECIAL_USED = 256 };
503503
#endif
504504

505505
#ifdef RTS_ENABLE_CRASHDUMP
506-
class AllocationRangeIterator {
506+
class AllocationRangeIterator
507+
{
507508
typedef const MemoryPoolAllocatedRange value_type;
508509
typedef const MemoryPoolAllocatedRange* pointer;
509510
typedef const MemoryPoolAllocatedRange& reference;
511+
510512
public:
511513

512514
AllocationRangeIterator(const MemoryPoolFactory* factory);
513-
AllocationRangeIterator(MemoryPool& pool, MemoryPoolBlob& blob) {
515+
AllocationRangeIterator(MemoryPool& pool, MemoryPoolBlob& blob)
516+
{
514517
m_currentPool = &pool;
515518
m_currentBlobInPool = &blob;
516519
m_factory = NULL;
@@ -542,8 +545,15 @@ class AllocationRangeIterator {
542545
// Postfix increment
543546
AllocationRangeIterator operator++(int) { AllocationRangeIterator tmp = *this; ++(*this); return tmp; }
544547

545-
friend bool operator== (const AllocationRangeIterator& a, const AllocationRangeIterator& b) { return a.m_currentBlobInPool == b.m_currentBlobInPool; };
546-
friend bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b) { return a.m_currentBlobInPool != b.m_currentBlobInPool; };
548+
friend const bool operator== (const AllocationRangeIterator& a, const AllocationRangeIterator& b)
549+
{
550+
return a.m_currentBlobInPool == b.m_currentBlobInPool;
551+
};
552+
553+
friend const bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b)
554+
{
555+
return a.m_currentBlobInPool != b.m_currentBlobInPool;
556+
};
547557

548558
private:
549559
const MemoryPoolFactory* m_factory;
@@ -648,11 +658,13 @@ class MemoryPoolFactory
648658

649659
#endif
650660
#ifdef RTS_ENABLE_CRASHDUMP
651-
AllocationRangeIterator cbegin() const {
661+
AllocationRangeIterator cbegin() const
662+
{
652663
return AllocationRangeIterator(this);
653664
}
654665

655-
AllocationRangeIterator cend() const {
666+
AllocationRangeIterator cend() const
667+
{
656668
return AllocationRangeIterator(NULL, NULL);
657669
}
658670

Core/GameEngine/Include/Common/MiniDumper.h

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,42 @@
2222
#include <imagehlp.h>
2323
#include "Common/MiniDumper_compat.h"
2424

25+
enum DumpType CPP_11(: Int)
26+
{
27+
// Smallest dump type with call stacks and some supporting variables
28+
DUMP_TYPE_MINIMAL,
29+
// Large dump including all memory regions allocated by the GameMemory implementaion
30+
DUMP_TYPE_GAMEMEMORY,
31+
// Largest dump size including complete memory contents of the process
32+
DUMP_TYPE_FULL,
33+
};
34+
35+
enum MiniDumperExitCode CPP_11(: Int)
36+
{
37+
DUMPER_EXIT_SUCCESS = 0x0,
38+
DUMPER_EXIT_FAILURE_WAIT = 0x37DA1040,
39+
DUMPER_EXIT_FAILURE_PARAM = 0x4EA527BB,
40+
DUMPER_EXIT_FORCED_TERMINATE = 0x158B1154,
41+
};
42+
2543
class MiniDumper
2644
{
2745
public:
28-
MiniDumper()
29-
{
30-
m_miniDumpInitialized = false;
31-
m_extendedInfoRequested = false;
32-
m_dbgHlp = NULL;
33-
m_pMiniDumpWriteDump = NULL;
34-
m_dumpRequested = NULL;
35-
m_dumpComplete = NULL;
36-
m_quitting = NULL;
37-
m_dumpThread = NULL;
38-
m_dumpThreadId = 0;
39-
m_dumpObjectsState = 0;
40-
m_dumpObjectsSubState = 0;
41-
m_dmaRawBlockIndex = 0;
42-
memset(m_dumpDir, 0, ARRAY_SIZE(m_dumpDir));
43-
memset(m_dumpFile, 0, ARRAY_SIZE(m_dumpFile));
44-
memset(m_sysDbgHelpPath, 0, ARRAY_SIZE(m_sysDbgHelpPath));
45-
};
46-
47-
void Initialize(const AsciiString& userDirPath);
46+
MiniDumper();
4847
Bool IsInitialized() const;
49-
void TriggerMiniDump(Bool extendedInfo = false);
50-
void TriggerMiniDumpForException(struct _EXCEPTION_POINTERS* e_info, Bool extendedInfo = false);
51-
void ShutDown();
48+
void TriggerMiniDump(DumpType dumpType);
49+
void TriggerMiniDumpForException(struct _EXCEPTION_POINTERS* e_info, DumpType dumpType);
50+
static void initMiniDumper(const AsciiString& userDirPath);
51+
static void shutdownMiniDumper();
5252
static LONG WINAPI DumpingExceptionFilter(struct _EXCEPTION_POINTERS* e_info);
53+
5354
private:
54-
void CreateMiniDump(Bool extendedInfo);
55+
void Initialize(const AsciiString& userDirPath);
56+
void ShutDown();
57+
void CreateMiniDump(DumpType dumpType);
5558
BOOL DumpMemoryObjects(ULONG64& memoryBase, ULONG& memorySize);
5659
void CleanupResources();
60+
Bool IsDumpThreadStillRunning() const;
5761

5862
// Callbacks from dbghelp
5963
static BOOL CALLBACK MiniDumpCallback(PVOID CallbackParam, PMINIDUMP_CALLBACK_INPUT CallbackInput, PMINIDUMP_CALLBACK_OUTPUT CallbackOutput);
@@ -68,7 +72,8 @@ class MiniDumper
6872
static void KeepNewestFiles(const std::string& directory, const std::string& fileWildcard, const Int keepCount);
6973

7074
// Struct to hold file information
71-
struct FileInfo {
75+
struct FileInfo
76+
{
7277
std::string name;
7378
FILETIME lastWriteTime;
7479
};
@@ -77,12 +82,13 @@ class MiniDumper
7782

7883
private:
7984
Bool m_miniDumpInitialized;
80-
Bool m_extendedInfoRequested;
85+
DumpType m_requestedDumpType;
8186

8287
// Path buffers
8388
Char m_dumpDir[MAX_PATH];
8489
Char m_dumpFile[MAX_PATH];
8590
Char m_sysDbgHelpPath[MAX_PATH];
91+
WideChar m_executablePath[MAX_PATH];
8692

8793
// Module handles
8894
HMODULE m_dbgHlp;
@@ -101,8 +107,7 @@ class MiniDumper
101107
int m_dumpObjectsSubState;
102108
int m_dmaRawBlockIndex;
103109

104-
AllocationRangeIterator m_RangeIter;
105-
AllocationRangeIterator m_endRangeIter;
110+
AllocationRangeIterator m_rangeIter;
106111

107112
// Function pointer to MiniDumpWriteDump in dbghelp.dll
108113
typedef BOOL(WINAPI* MiniDumpWriteDump_t)(
@@ -117,4 +122,6 @@ class MiniDumper
117122

118123
MiniDumpWriteDump_t m_pMiniDumpWriteDump;
119124
};
125+
126+
extern MiniDumper* TheMiniDumper;
120127
#endif

Core/GameEngine/Source/Common/System/Debug.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@
7272
#endif
7373
#ifdef RTS_ENABLE_CRASHDUMP
7474
#include "Common/MiniDumper.h"
75-
76-
MiniDumper TheMiniDumper = MiniDumper();
7775
#endif
7876

7977
// Horrible reference, but we really, really need to know if we are windowed.
@@ -735,12 +733,12 @@ void ReleaseCrash(const char *reason)
735733
}
736734

737735
#ifdef RTS_ENABLE_CRASHDUMP
738-
if (TheMiniDumper.IsInitialized())
736+
if (TheMiniDumper && TheMiniDumper->IsInitialized())
739737
{
740738
// Do dumps both with and without extended info
741-
TheMiniDumper.TriggerMiniDump(false);
742-
TheMiniDumper.TriggerMiniDump(true);
743-
TheMiniDumper.ShutDown();
739+
TheMiniDumper->TriggerMiniDump(DUMP_TYPE_MINIMAL);
740+
TheMiniDumper->TriggerMiniDump(DUMP_TYPE_GAMEMEMORY);
741+
MiniDumper::shutdownMiniDumper();
744742
}
745743
#endif
746744

@@ -810,12 +808,12 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
810808
}
811809

812810
#ifdef RTS_ENABLE_CRASHDUMP
813-
if (TheMiniDumper.IsInitialized())
811+
if (TheMiniDumper && TheMiniDumper->IsInitialized())
814812
{
815813
// Do dumps both with and without extended info
816-
TheMiniDumper.TriggerMiniDump(false);
817-
TheMiniDumper.TriggerMiniDump(true);
818-
TheMiniDumper.ShutDown();
814+
TheMiniDumper->TriggerMiniDump(DUMP_TYPE_MINIMAL);
815+
TheMiniDumper->TriggerMiniDump(DUMP_TYPE_GAMEMEMORY);
816+
MiniDumper::shutdownMiniDumper();
819817
}
820818
#endif
821819

Core/GameEngine/Source/Common/System/GameMemory.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2603,7 +2603,6 @@ Int DynamicMemoryAllocator::getRawBlockCount() const
26032603
}
26042604
void DynamicMemoryAllocator::fillAllocationRangeForRawBlockN(const Int n, MemoryPoolAllocatedRange& allocationRange) const
26052605
{
2606-
26072606
MemoryPoolSingleBlock* block = m_rawBlocks;
26082607
for (int i = 0; i < n; ++i)
26092608
{

0 commit comments

Comments
 (0)