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 4 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);
}
}
3 changes: 1 addition & 2 deletions src/Amalgam/evaluablenode/EvaluableNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,8 +1565,7 @@ void EvaluableNode::DestructValue()
void EvaluableNode::Invalidate()
{
#ifdef AMALGAM_FAST_MEMORY_INTEGRITY
if(IsNodeDeallocated())
assert(false);
assert(!IsNodeDeallocated());
#endif

if(!HasExtendedValue())
Expand Down
17 changes: 7 additions & 10 deletions src/Amalgam/evaluablenode/EvaluableNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,35 +239,35 @@ class EvaluableNode
}

//Returns true if the node is some form of associative array
static constexpr bool IsAssociativeArray(EvaluableNode *n)
static __forceinline bool IsAssociativeArray(EvaluableNode *n)
{
if(n == nullptr)
return false;
return n->IsAssociativeArray();
}

//returns true if the type is immediate
constexpr bool IsImmediate()
__forceinline bool IsImmediate()
{
return IsEvaluableNodeTypeImmediate(GetType());
}

//Returns true if the node is some form of ordered array
constexpr bool IsOrderedArray()
__forceinline bool IsOrderedArray()
{
return DoesEvaluableNodeTypeUseOrderedData(GetType());
}

//Returns true if the node is some form of ordered array
static constexpr bool IsOrderedArray(EvaluableNode *n)
static __forceinline bool IsOrderedArray(EvaluableNode *n)
{
if(n == nullptr)
return false;
return n->IsOrderedArray();
}

//returns true if the EvaluableNode is of a query type
static constexpr bool IsQuery(EvaluableNode *n)
static __forceinline bool IsQuery(EvaluableNode *n)
{
return (n != nullptr && IsEvaluableNodeTypeQuery(n->GetType()));
}
Expand Down Expand Up @@ -419,13 +419,10 @@ class EvaluableNode
static size_t GetEstimatedNodeSizeInBytes(EvaluableNode *n);

//gets current type
constexpr EvaluableNodeType &GetType()
__forceinline EvaluableNodeType &GetType()
{
#ifdef AMALGAM_FAST_MEMORY_INTEGRITY
if(type == ENT_DEALLOCATED)
{
assert(false);
}
assert(type != ENT_DEALLOCATED);
#endif
return type;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Amalgam/evaluablenode/EvaluableNodeManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ class EvaluableNodeStackStateSaver
stack = _stack;
originalStackSize = stack->size();

#ifdef AMALGAM_FAST_MEMORY_INTEGRITY
assert(initial_element == nullptr || !initial_element->IsNodeDeallocated());
#endif

stack->push_back(initial_element);
}

Expand All @@ -214,6 +218,9 @@ class EvaluableNodeStackStateSaver

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

Expand All @@ -231,6 +238,9 @@ 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
assert(new_value == nullptr || !new_value->IsNodeDeallocated());
#endif
(*stack)[location] = new_value;
}

Expand Down
Loading