Skip to content
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

21053: Adds additional debugging capabilities related to AMALGAM_FAST_MEMORY_INTEGRITY and catching asserts #199

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions src/Amalgam/PlatformSpecific.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,19 @@ inline void Platform_Assert(bool expr, const char *file, int line)
std::cerr << "Runtime Exception: Debug Assertion Failed at line " << line << " of " << file << "\n";

//platform dependent assertion function
#ifdef _DEBUG

#ifdef OS_WINDOWS
_ASSERT(expr);
#else
raise(SIGTRAP);
#endif
exit(-1);

#ifdef OS_WINDOWS
_ASSERT(expr);
#else
if(Platform_IsDebuggerPresent())
{
//wait for user input
std::string temp;
std::getline(std::cin, temp);
}
exit(-1);
raise(SIGTRAP);
#endif

if(Platform_IsDebuggerPresent())
{
//wait for user input in case the _ASSERT above was optimized out
std::string temp;
std::getline(std::cin, temp);
}

exit(-1);
}
}
19 changes: 19 additions & 0 deletions src/Amalgam/evaluablenode/EvaluableNodeManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ class EvaluableNodeStackStateSaver
stack = _stack;
originalStackSize = stack->size();

#ifdef AMALGAM_FAST_MEMORY_INTEGRITY
if(initial_element != nullptr && initial_element->IsNodeDeallocated())
{
assert(false);
}
#endif

stack->push_back(initial_element);
}

Expand All @@ -214,6 +221,12 @@ class EvaluableNodeStackStateSaver

__forceinline void PushEvaluableNode(EvaluableNode *n)
{
#ifdef AMALGAM_FAST_MEMORY_INTEGRITY
if(n != nullptr && n->IsNodeDeallocated())
{
assert(false);
}
#endif
stack->push_back(n);
}

Expand All @@ -231,6 +244,12 @@ class EvaluableNodeStackStateSaver
//replaces the position of the stack with new_value
__forceinline void SetStackLocation(size_t location, EvaluableNode *new_value)
{
#ifdef AMALGAM_FAST_MEMORY_INTEGRITY
if(new_value != nullptr && new_value->IsNodeDeallocated())
{
assert(false);
}
#endif
(*stack)[location] = new_value;
}

Expand Down
Loading