-
Notifications
You must be signed in to change notification settings - Fork 0
Feature crashdump #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a241b80
5e543ba
7399cce
7cc9b3c
bcb86fe
c0f1045
810371e
7ce2363
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -223,6 +223,9 @@ class MemoryPool; | |||||||||||||||||||||||||
| class MemoryPoolFactory; | ||||||||||||||||||||||||||
| class DynamicMemoryAllocator; | ||||||||||||||||||||||||||
| class BlockCheckpointInfo; | ||||||||||||||||||||||||||
| #ifdef RTS_ENABLE_CRASHDUMP | ||||||||||||||||||||||||||
| class AllocationRangeIterator; | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // TYPE DEFINES /////////////////////////////////////////////////////////////// | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -279,6 +282,14 @@ class Checkpointable | |||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #ifdef RTS_ENABLE_CRASHDUMP | ||||||||||||||||||||||||||
| struct MemoryPoolAllocatedRange | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| const char* allocationAddr; | ||||||||||||||||||||||||||
| size_t allocationSize; | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| A MemoryPool provides a way to efficiently allocate objects of the same (or similar) | ||||||||||||||||||||||||||
|
|
@@ -384,6 +395,9 @@ class MemoryPool | |||||||||||||||||||||||||
| /// return true iff this block was allocated by this pool. | ||||||||||||||||||||||||||
| Bool debugIsBlockInPool(void *pBlock); | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
| #ifdef RTS_ENABLE_CRASHDUMP | ||||||||||||||||||||||||||
| friend class AllocationRangeIterator; | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||
|
|
@@ -474,13 +488,81 @@ class DynamicMemoryAllocator | |||||||||||||||||||||||||
| Bool debugIsPoolInDma(MemoryPool *pool); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #endif // MEMORYPOOL_DEBUG | ||||||||||||||||||||||||||
| #ifdef RTS_ENABLE_CRASHDUMP | ||||||||||||||||||||||||||
| MemoryPoolSingleBlock* getFirstRawBlock() const; | ||||||||||||||||||||||||||
| MemoryPoolSingleBlock* getNextRawBlock(MemoryPoolSingleBlock* block) const; | ||||||||||||||||||||||||||
| void fillAllocationRangeForRawBlock(const MemoryPoolSingleBlock*, MemoryPoolAllocatedRange& allocationRange) const; | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| #ifdef MEMORYPOOL_DEBUG | ||||||||||||||||||||||||||
| enum { MAX_SPECIAL_USED = 256 }; | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #ifdef RTS_ENABLE_CRASHDUMP | ||||||||||||||||||||||||||
| class AllocationRangeIterator | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| typedef const MemoryPoolAllocatedRange value_type; | ||||||||||||||||||||||||||
| typedef const MemoryPoolAllocatedRange* pointer; | ||||||||||||||||||||||||||
| typedef const MemoryPoolAllocatedRange& reference; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| AllocationRangeIterator(const MemoryPoolFactory* factory); | ||||||||||||||||||||||||||
| AllocationRangeIterator(MemoryPool& pool, MemoryPoolBlob& blob) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| m_currentPool = &pool; | ||||||||||||||||||||||||||
| m_currentBlobInPool = &blob; | ||||||||||||||||||||||||||
| m_factory = NULL; | ||||||||||||||||||||||||||
| m_range = MemoryPoolAllocatedRange(); | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| AllocationRangeIterator(MemoryPool* pool, MemoryPoolBlob* blob) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| m_currentPool = pool; | ||||||||||||||||||||||||||
| m_currentBlobInPool = blob; | ||||||||||||||||||||||||||
| m_factory = NULL; | ||||||||||||||||||||||||||
| m_range = MemoryPoolAllocatedRange(); | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| AllocationRangeIterator() | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| m_currentPool = NULL; | ||||||||||||||||||||||||||
| m_currentBlobInPool = NULL; | ||||||||||||||||||||||||||
| m_factory = NULL; | ||||||||||||||||||||||||||
| m_range = MemoryPoolAllocatedRange(); | ||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| }; | |
| } |
Outdated
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison operators have unnecessary semicolons after the closing braces on lines 549 and 554. Friend function definitions should not have trailing semicolons. Remove them.
| }; | |
| friend const bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b) | |
| { | |
| return a.m_currentBlobInPool != b.m_currentBlobInPool; | |
| }; | |
| } | |
| friend const bool operator!= (const AllocationRangeIterator& a, const AllocationRangeIterator& b) | |
| { | |
| return a.m_currentBlobInPool != b.m_currentBlobInPool; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,124 @@ | ||||||
| /* | ||||||
| ** Command & Conquer Generals Zero Hour(tm) | ||||||
| ** Copyright 2025 TheSuperHackers | ||||||
| ** | ||||||
| ** This program is free software: you can redistribute it and/or modify | ||||||
| ** it under the terms of the GNU General Public License as published by | ||||||
| ** the Free Software Foundation, either version 3 of the License, or | ||||||
| ** (at your option) any later version. | ||||||
| ** | ||||||
| ** This program is distributed in the hope that it will be useful, | ||||||
| ** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
| ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
| ** GNU General Public License for more details. | ||||||
| ** | ||||||
| ** You should have received a copy of the GNU General Public License | ||||||
| ** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||
| */ | ||||||
|
|
||||||
| #pragma once | ||||||
|
|
||||||
| #ifdef RTS_ENABLE_CRASHDUMP | ||||||
| #include "DbgHelpLoader.h" | ||||||
|
|
||||||
| enum DumpType CPP_11(: Char) | ||||||
| { | ||||||
| // Smallest dump type with call stacks and some supporting variables | ||||||
| DUMP_TYPE_MINIMAL = 'M', | ||||||
| // Large dump including all memory regions allocated by the GameMemory implementaion | ||||||
|
||||||
| // Large dump including all memory regions allocated by the GameMemory implementaion | |
| // Large dump including all memory regions allocated by the GameMemory implementation |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,9 @@ | |
| #if defined(DEBUG_STACKTRACE) || defined(IG_DEBUG_STACKTRACE) | ||
| #include "Common/StackDump.h" | ||
| #endif | ||
| #ifdef RTS_ENABLE_CRASHDUMP | ||
| #include "Common/MiniDumper.h" | ||
| #endif | ||
|
|
||
| // Horrible reference, but we really, really need to know if we are windowed. | ||
| extern bool DX8Wrapper_IsWindowed; | ||
|
|
@@ -727,6 +730,22 @@ double SimpleProfiler::getAverageTime() | |
| } | ||
| } | ||
|
|
||
|
|
||
| static void TriggerMiniDump() | ||
| { | ||
| #ifdef RTS_ENABLE_CRASHDUMP | ||
| if (TheMiniDumper && TheMiniDumper->IsInitialized()) | ||
| { | ||
| // Do dumps both with and without extended info | ||
| TheMiniDumper->TriggerMiniDump(DUMP_TYPE_MINIMAL); | ||
| TheMiniDumper->TriggerMiniDump(DUMP_TYPE_GAMEMEMORY); | ||
| } | ||
|
|
||
| MiniDumper::shutdownMiniDumper(); | ||
| #endif | ||
| } | ||
|
Comment on lines
734
to
746
|
||
|
|
||
|
|
||
| void ReleaseCrash(const char *reason) | ||
| { | ||
| /// do additional reporting on the crash, if possible | ||
|
|
@@ -737,6 +756,8 @@ void ReleaseCrash(const char *reason) | |
| } | ||
| } | ||
|
|
||
| TriggerMiniDump(); | ||
|
|
||
| char prevbuf[ _MAX_PATH ]; | ||
| char curbuf[ _MAX_PATH ]; | ||
|
|
||
|
|
@@ -813,6 +834,8 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m) | |
| return; | ||
| } | ||
|
|
||
| TriggerMiniDump(); | ||
|
|
||
| UnicodeString prompt = TheGameText->fetch(p); | ||
| UnicodeString mesg = TheGameText->fetch(m); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructors at lines 513-519 and 521-527 have unnecessary semicolons after the closing brace. In C++, constructor definitions should not have a trailing semicolon. Remove the semicolons on lines 519 and 527.