Skip to content

Commit 68aa823

Browse files
committed
Address review feedback
1 parent 7e85db6 commit 68aa823

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
@@ -1174,6 +1174,7 @@ target_include_directories(corei_gameengine_private INTERFACE
11741174

11751175
target_link_libraries(corei_gameengine_private INTERFACE
11761176
corei_always
1177+
$<$<AND:$<BOOL:${IS_VS6_BUILD}>,$<BOOL:${RTS_CRASHDUMP_ENABLE}>>:shlwapi.lib>
11771178
)
11781179

11791180
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
@@ -500,14 +500,17 @@ enum { MAX_SPECIAL_USED = 256 };
500500
#endif
501501

502502
#ifdef RTS_ENABLE_CRASHDUMP
503-
class AllocationRangeIterator {
503+
class AllocationRangeIterator
504+
{
504505
typedef const MemoryPoolAllocatedRange value_type;
505506
typedef const MemoryPoolAllocatedRange* pointer;
506507
typedef const MemoryPoolAllocatedRange& reference;
508+
507509
public:
508510

509511
AllocationRangeIterator(const MemoryPoolFactory* factory);
510-
AllocationRangeIterator(MemoryPool& pool, MemoryPoolBlob& blob) {
512+
AllocationRangeIterator(MemoryPool& pool, MemoryPoolBlob& blob)
513+
{
511514
m_currentPool = &pool;
512515
m_currentBlobInPool = &blob;
513516
m_factory = NULL;
@@ -539,8 +542,15 @@ class AllocationRangeIterator {
539542
// Postfix increment
540543
AllocationRangeIterator operator++(int) { AllocationRangeIterator tmp = *this; ++(*this); return tmp; }
541544

542-
friend bool operator== (const AllocationRangeIterator& a, const AllocationRangeIterator& b) { return a.m_currentBlobInPool == b.m_currentBlobInPool; };
543-
friend bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b) { return a.m_currentBlobInPool != b.m_currentBlobInPool; };
545+
friend const bool operator== (const AllocationRangeIterator& a, const AllocationRangeIterator& b)
546+
{
547+
return a.m_currentBlobInPool == b.m_currentBlobInPool;
548+
};
549+
550+
friend const bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b)
551+
{
552+
return a.m_currentBlobInPool != b.m_currentBlobInPool;
553+
};
544554

545555
private:
546556
const MemoryPoolFactory* m_factory;
@@ -645,11 +655,13 @@ class MemoryPoolFactory
645655

646656
#endif
647657
#ifdef RTS_ENABLE_CRASHDUMP
648-
AllocationRangeIterator cbegin() const {
658+
AllocationRangeIterator cbegin() const
659+
{
649660
return AllocationRangeIterator(this);
650661
}
651662

652-
AllocationRangeIterator cend() const {
663+
AllocationRangeIterator cend() const
664+
{
653665
return AllocationRangeIterator(NULL, NULL);
654666
}
655667

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)