Skip to content

Commit bcb86fe

Browse files
committed
Include enum name in enum values, move AllocationRangeIterator implementations to cpp
1 parent 7cc9b3c commit bcb86fe

File tree

9 files changed

+120
-90
lines changed

9 files changed

+120
-90
lines changed

Core/GameEngine/Include/Common/GameMemory.h

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -509,57 +509,31 @@ class AllocationRangeIterator
509509

510510
public:
511511

512+
AllocationRangeIterator();
512513
AllocationRangeIterator(const MemoryPoolFactory* factory);
513-
AllocationRangeIterator(MemoryPool& pool, MemoryPoolBlob& blob)
514-
{
515-
m_currentPool = &pool;
516-
m_currentBlobInPool = &blob;
517-
m_factory = NULL;
518-
m_range = MemoryPoolAllocatedRange();
519-
};
520-
521-
AllocationRangeIterator(MemoryPool* pool, MemoryPoolBlob* blob)
522-
{
523-
m_currentPool = pool;
524-
m_currentBlobInPool = blob;
525-
m_factory = NULL;
526-
m_range = MemoryPoolAllocatedRange();
527-
};
528-
529-
AllocationRangeIterator()
530-
{
531-
m_currentPool = NULL;
532-
m_currentBlobInPool = NULL;
533-
m_factory = NULL;
534-
m_range = MemoryPoolAllocatedRange();
535-
};
514+
AllocationRangeIterator(MemoryPool& pool, MemoryPoolBlob& blob);
515+
AllocationRangeIterator(MemoryPool* pool, MemoryPoolBlob* blob);
536516

537-
reference operator*() { UpdateRange(); return m_range; }
538-
pointer operator->() { UpdateRange(); return &m_range; }
517+
reference operator*() { return m_range; }
518+
pointer operator->() { return &m_range; }
539519

540520
// Prefix increment
541-
AllocationRangeIterator& operator++() { MoveToNextBlob(); return *this; }
521+
AllocationRangeIterator& operator++();
542522

543523
// Postfix increment
544-
AllocationRangeIterator operator++(int) { AllocationRangeIterator tmp = *this; ++(*this); return tmp; }
524+
AllocationRangeIterator operator++(int);
545525

546-
friend const bool operator== (const AllocationRangeIterator& a, const AllocationRangeIterator& b)
547-
{
548-
return a.m_currentBlobInPool == b.m_currentBlobInPool;
549-
};
550-
551-
friend const bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b)
552-
{
553-
return a.m_currentBlobInPool != b.m_currentBlobInPool;
554-
};
526+
friend const bool operator== (const AllocationRangeIterator& a, const AllocationRangeIterator& b);
527+
friend const bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b);
555528

556529
private:
530+
531+
void updateRange();
532+
void moveToNextBlob();
557533
const MemoryPoolFactory* m_factory;
558534
MemoryPool* m_currentPool;
559535
MemoryPoolBlob* m_currentBlobInPool;
560536
MemoryPoolAllocatedRange m_range;
561-
void UpdateRange();
562-
void MoveToNextBlob();
563537
};
564538
#endif
565539

Core/GameEngine/Include/Common/MiniDumper.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,29 @@
2424
enum DumpType CPP_11(: Char)
2525
{
2626
// Smallest dump type with call stacks and some supporting variables
27-
DUMP_TYPE_MINIMAL = 'M',
28-
// Large dump including all memory regions allocated by the GameMemory implementaion
29-
DUMP_TYPE_GAMEMEMORY = 'X',
27+
DumpType_Minimal = 'M',
28+
// Large dump including all memory regions allocated by the GameMemory implementation
29+
DumpType_Gamememory = 'X',
3030
// Largest dump size including complete memory contents of the process
31-
DUMP_TYPE_FULL = 'F',
31+
DumpType_Full = 'F',
3232
};
3333

3434
class MiniDumper
3535
{
3636
enum MiniDumperExitCode CPP_11(: Int)
3737
{
38-
DUMPER_EXIT_SUCCESS = 0x0,
39-
DUMPER_EXIT_FAILURE_WAIT = 0x37DA1040,
40-
DUMPER_EXIT_FAILURE_PARAM = 0x4EA527BB,
41-
DUMPER_EXIT_FORCED_TERMINATE = 0x158B1154,
38+
MiniDumperExitCode_Success = 0x0,
39+
MiniDumperExitCode_FailureWait = 0x37DA1040,
40+
MiniDumperExitCode_FailureParam = 0x4EA527BB,
41+
MiniDumperExitCode_ForcedTerminate = 0x158B1154,
4242
};
4343

4444
enum DumpObjectsState CPP_11(: Int)
4545
{
4646
DumpObjectsState_Begin,
47-
DumpObjectsState_Memory_Pools,
48-
DumpObjectsState_Memory_Pool_Allocations,
49-
DumpObjectsState_DMA_Allocations,
47+
DumpObjectsState_MemoryPools,
48+
DumpObjectsState_MemoryPoolAllocations,
49+
DumpObjectsState_DMAAllocations,
5050
DumpObjectsState_Completed
5151
};
5252

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,8 @@ static void TriggerMiniDump()
737737
if (TheMiniDumper && TheMiniDumper->IsInitialized())
738738
{
739739
// Do dumps both with and without extended info
740-
TheMiniDumper->TriggerMiniDump(DUMP_TYPE_MINIMAL);
741-
TheMiniDumper->TriggerMiniDump(DUMP_TYPE_GAMEMEMORY);
740+
TheMiniDumper->TriggerMiniDump(DumpType_Minimal);
741+
TheMiniDumper->TriggerMiniDump(DumpType_Gamememory);
742742
}
743743

744744
MiniDumper::shutdownMiniDumper();

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

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,7 @@ void DynamicMemoryAllocator::fillAllocationRangeForRawBlock(const MemoryPoolSing
26062606
allocationRange.allocationAddr = reinterpret_cast<const char*>(block);
26072607
allocationRange.allocationSize = block->calcRawBlockSize(block->debugGetLogicalSize());
26082608
}
2609+
26092610
#endif
26102611

26112612
//-----------------------------------------------------------------------------
@@ -3273,21 +3274,70 @@ MemoryPool* MemoryPoolFactory::getFirstMemoryPool() const
32733274
return m_firstPoolInFactory;
32743275
}
32753276

3277+
//-----------------------------------------------------------------------------
3278+
// METHODS for AllocationRangeIterator
3279+
//-----------------------------------------------------------------------------
3280+
3281+
AllocationRangeIterator::AllocationRangeIterator()
3282+
{
3283+
m_currentPool = NULL;
3284+
m_currentBlobInPool = NULL;
3285+
m_factory = NULL;
3286+
m_range = MemoryPoolAllocatedRange();
3287+
}
3288+
32763289
AllocationRangeIterator::AllocationRangeIterator(const MemoryPoolFactory* factory)
32773290
{
32783291
m_factory = factory;
3279-
m_currentPool = factory->m_firstPoolInFactory;
3280-
m_currentBlobInPool = m_currentPool->m_firstBlob;
3292+
if (factory)
3293+
{
3294+
m_currentPool = factory->m_firstPoolInFactory;
3295+
m_currentBlobInPool = m_currentPool ? m_currentPool->m_firstBlob : NULL;
3296+
}
3297+
else
3298+
{
3299+
m_currentPool = NULL;
3300+
m_currentBlobInPool = NULL;
3301+
}
3302+
32813303
m_range = MemoryPoolAllocatedRange();
32823304
}
32833305

3284-
void AllocationRangeIterator::UpdateRange()
3306+
AllocationRangeIterator::AllocationRangeIterator(MemoryPool& pool, MemoryPoolBlob& blob)
32853307
{
3308+
m_currentPool = &pool;
3309+
m_currentBlobInPool = &blob;
3310+
m_factory = NULL;
3311+
m_range = MemoryPoolAllocatedRange();
3312+
}
3313+
3314+
AllocationRangeIterator::AllocationRangeIterator(MemoryPool* pool, MemoryPoolBlob* blob)
3315+
{
3316+
m_currentPool = pool;
3317+
m_currentBlobInPool = blob;
3318+
m_factory = NULL;
3319+
m_range = MemoryPoolAllocatedRange();
3320+
}
3321+
3322+
void AllocationRangeIterator::updateRange()
3323+
{
3324+
if (m_currentBlobInPool == NULL)
3325+
{
3326+
m_range.allocationAddr = nullptr;
3327+
m_range.allocationSize = 0;
3328+
return;
3329+
}
3330+
32863331
m_currentBlobInPool->fillAllocatedRange(m_range);
32873332
}
32883333

3289-
void AllocationRangeIterator::MoveToNextBlob()
3334+
void AllocationRangeIterator::moveToNextBlob()
32903335
{
3336+
if (m_currentBlobInPool == NULL)
3337+
{
3338+
return;
3339+
}
3340+
32913341
// Advances to the next blob, advancing to the next MemoryPool if needed.
32923342
m_currentBlobInPool = m_currentBlobInPool->getNextInList();
32933343
if (m_currentBlobInPool != NULL)
@@ -3308,6 +3358,22 @@ void AllocationRangeIterator::MoveToNextBlob()
33083358
m_currentBlobInPool = NULL;
33093359
}
33103360
}
3361+
3362+
// Prefix increment
3363+
AllocationRangeIterator& AllocationRangeIterator::operator++() { moveToNextBlob(); updateRange(); return *this; }
3364+
3365+
// Postfix increment
3366+
AllocationRangeIterator AllocationRangeIterator::operator++(int) { AllocationRangeIterator tmp = *this; ++(*this); return tmp; }
3367+
3368+
const bool operator== (const AllocationRangeIterator& a, const AllocationRangeIterator& b)
3369+
{
3370+
return a.m_currentBlobInPool == b.m_currentBlobInPool;
3371+
}
3372+
3373+
const bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b)
3374+
{
3375+
return a.m_currentBlobInPool != b.m_currentBlobInPool;
3376+
}
33113377
#endif
33123378

33133379
//-----------------------------------------------------------------------------

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ MiniDumper::MiniDumper()
6363
{
6464
m_miniDumpInitialized = false;
6565
m_loadedDbgHelp = false;
66-
m_requestedDumpType = DUMP_TYPE_MINIMAL;
66+
m_requestedDumpType = DumpType_Minimal;
6767
m_dumpRequested = NULL;
6868
m_dumpComplete = NULL;
6969
m_quitting = NULL;
@@ -234,9 +234,9 @@ Bool MiniDumper::InitializeDumpDirectory(const AsciiString& userDirPath)
234234
}
235235

236236
// Clean up old files (we keep a maximum of 10 small, 2 extended and 2 full)
237-
KeepNewestFiles(m_dumpDir, DUMP_TYPE_GAMEMEMORY, MaxExtendedFileCount);
238-
KeepNewestFiles(m_dumpDir, DUMP_TYPE_FULL, MaxFullFileCount);
239-
KeepNewestFiles(m_dumpDir, DUMP_TYPE_MINIMAL, MaxMiniFileCount);
237+
KeepNewestFiles(m_dumpDir, DumpType_Gamememory, MaxExtendedFileCount);
238+
KeepNewestFiles(m_dumpDir, DumpType_Full, MaxFullFileCount);
239+
KeepNewestFiles(m_dumpDir, DumpType_Minimal, MaxMiniFileCount);
240240

241241
return true;
242242
}
@@ -256,7 +256,7 @@ void MiniDumper::ShutdownDumpThread()
256256
break;
257257
case WAIT_TIMEOUT:
258258
DEBUG_LOG(("MiniDumper::ShutdownDumpThread: Waiting for dumping thread to exit timed out, killing thread", waitRet));
259-
::TerminateThread(m_dumpThread, DUMPER_EXIT_FORCED_TERMINATE);
259+
::TerminateThread(m_dumpThread, MiniDumperExitCode_ForcedTerminate);
260260
break;
261261
case WAIT_FAILED:
262262
DEBUG_LOG(("MiniDumper::ShutdownDumpThread: Waiting for minidump triggering failed: status=%u, error=%u", waitRet, ::GetLastError()));
@@ -323,13 +323,13 @@ DWORD MiniDumper::ThreadProcInternal()
323323
break;
324324
case WAIT_OBJECT_0 + 1:
325325
// Quit (m_quitting)
326-
return DUMPER_EXIT_SUCCESS;
326+
return MiniDumperExitCode_Success;
327327
case WAIT_FAILED:
328328
DEBUG_LOG(("MiniDumper::ThreadProcInternal: Waiting for events failed: status=%u, error=%u", event, ::GetLastError()));
329-
return DUMPER_EXIT_FAILURE_WAIT;
329+
return MiniDumperExitCode_FailureWait;
330330
default:
331331
DEBUG_LOG(("MiniDumper::ThreadProcInternal: Waiting for events failed: status=%u", event));
332-
return DUMPER_EXIT_FAILURE_WAIT;
332+
return MiniDumperExitCode_FailureWait;
333333
}
334334
}
335335
}
@@ -339,7 +339,7 @@ DWORD WINAPI MiniDumper::MiniDumpThreadProc(LPVOID lpParam)
339339
if (lpParam == NULL)
340340
{
341341
DEBUG_LOG(("MiniDumper::MiniDumpThreadProc: The provided parameter was NULL, exiting thread."));
342-
return DUMPER_EXIT_FAILURE_PARAM;
342+
return MiniDumperExitCode_FailureParam;
343343
}
344344

345345
MiniDumper* dumper = static_cast<MiniDumper *>(lpParam);
@@ -387,7 +387,7 @@ void MiniDumper::CreateMiniDump(DumpType dumpType)
387387

388388
PMINIDUMP_CALLBACK_INFORMATION callbackInfoPtr = NULL;
389389
MINIDUMP_CALLBACK_INFORMATION callBackInfo = { 0 };
390-
if (dumpType == DUMP_TYPE_GAMEMEMORY)
390+
if (dumpType == DumpType_Gamememory)
391391
{
392392
callBackInfo.CallbackRoutine = MiniDumpCallback;
393393
callBackInfo.CallbackParam = this;
@@ -397,13 +397,13 @@ void MiniDumper::CreateMiniDump(DumpType dumpType)
397397
int dumpTypeFlags = MiniDumpNormal;
398398
switch (dumpType)
399399
{
400-
case DUMP_TYPE_FULL:
400+
case DumpType_Full:
401401
dumpTypeFlags |= MiniDumpWithFullMemory;
402402
FALLTHROUGH;
403-
case DUMP_TYPE_GAMEMEMORY:
403+
case DumpType_Gamememory:
404404
dumpTypeFlags |= MiniDumpWithDataSegs | MiniDumpWithHandleData | MiniDumpWithThreadInfo | MiniDumpWithFullMemoryInfo | MiniDumpWithPrivateReadWriteMemory;
405405
FALLTHROUGH;
406-
case DUMP_TYPE_MINIMAL:
406+
case DumpType_Minimal:
407407
dumpTypeFlags |= MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory;
408408
break;
409409
}
@@ -525,7 +525,7 @@ void MiniDumper::DumpMemoryObjects(ULONG64& memoryBase, ULONG& memorySize)
525525
switch (m_dumpObjectsState)
526526
{
527527
case DumpObjectsState_Begin:
528-
m_dumpObjectsState = DumpObjectsState_Memory_Pools;
528+
m_dumpObjectsState = DumpObjectsState_MemoryPools;
529529
if (TheMemoryPoolFactory)
530530
{
531531
m_currentPool = TheMemoryPoolFactory->getFirstMemoryPool();
@@ -535,13 +535,13 @@ void MiniDumper::DumpMemoryObjects(ULONG64& memoryBase, ULONG& memorySize)
535535
m_currentSingleBlock = m_currentAllocator->getFirstRawBlock();
536536
}
537537
break;
538-
case DumpObjectsState_Memory_Pools:
538+
case DumpObjectsState_MemoryPools:
539539
{
540540
// Dump all the MemoryPool instances in TheMemoryPoolFactory
541541
// This only dumps the metadata, not the actual MemoryPool contents (done in the next phase).
542542
if (m_currentPool == NULL)
543543
{
544-
m_dumpObjectsState = DumpObjectsState_Memory_Pool_Allocations;
544+
m_dumpObjectsState = DumpObjectsState_MemoryPoolAllocations;
545545
break;
546546
}
547547

@@ -550,13 +550,13 @@ void MiniDumper::DumpMemoryObjects(ULONG64& memoryBase, ULONG& memorySize)
550550
m_currentPool = m_currentPool->getNextPoolInList();
551551
break;
552552
}
553-
case DumpObjectsState_Memory_Pool_Allocations:
553+
case DumpObjectsState_MemoryPoolAllocations:
554554
{
555555
// Iterate through all the allocations of memory pools and containing blobs that has been done via the memory pool factory
556556
// and include all of the storage space allocated for objects
557557
if (!TheMemoryPoolFactory || m_rangeIter == TheMemoryPoolFactory->cend())
558558
{
559-
m_dumpObjectsState = DumpObjectsState_DMA_Allocations;
559+
m_dumpObjectsState = DumpObjectsState_DMAAllocations;
560560
break;
561561
}
562562

@@ -565,7 +565,7 @@ void MiniDumper::DumpMemoryObjects(ULONG64& memoryBase, ULONG& memorySize)
565565
++m_rangeIter;
566566
break;
567567
}
568-
case DumpObjectsState_DMA_Allocations:
568+
case DumpObjectsState_DMAAllocations:
569569
{
570570
// Iterate through all the direct allocations ("raw blocks") done by DMAs, as these are done outside of the
571571
// memory pool factory allocations dumped in the previous phase.
@@ -575,7 +575,7 @@ void MiniDumper::DumpMemoryObjects(ULONG64& memoryBase, ULONG& memorySize)
575575
break;
576576
}
577577

578-
MemoryPoolAllocatedRange rawBlockRange = { 0 };
578+
MemoryPoolAllocatedRange rawBlockRange;
579579
m_currentAllocator->fillAllocationRangeForRawBlock(m_currentSingleBlock, rawBlockRange);
580580
memoryBase = reinterpret_cast<ULONG64>(rawBlockRange.allocationAddr);
581581
memorySize = rawBlockRange.allocationSize;

Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,6 @@ class DbgHelpLoader
126126
private:
127127

128128
static void freeResources();
129-
#ifdef RTS_ENABLE_CRASHDUMP
130-
typedef BOOL(WINAPI* MiniDumpWriteDump_t)(
131-
HANDLE hProcess,
132-
DWORD ProcessId,
133-
HANDLE hFile,
134-
MINIDUMP_TYPE DumpType,
135-
PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
136-
PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
137-
PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
138-
#endif
139129

140130
typedef BOOL (WINAPI *SymInitialize_t) (
141131
HANDLE hProcess,

Generals/Code/Main/WinMain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,8 @@ static LONG WINAPI UnHandledExceptionFilter( struct _EXCEPTION_POINTERS* e_info
748748
if (TheMiniDumper && TheMiniDumper->IsInitialized())
749749
{
750750
// Do dumps both with and without extended info
751-
TheMiniDumper->TriggerMiniDumpForException(e_info, DUMP_TYPE_MINIMAL);
752-
TheMiniDumper->TriggerMiniDumpForException(e_info, DUMP_TYPE_GAMEMEMORY);
751+
TheMiniDumper->TriggerMiniDumpForException(e_info, DumpType_Minimal);
752+
TheMiniDumper->TriggerMiniDumpForException(e_info, DumpType_Gamememory);
753753
}
754754

755755
MiniDumper::shutdownMiniDumper();

0 commit comments

Comments
 (0)