diff options
| author | Dan Engelbrecht <[email protected]> | 2025-09-26 16:45:54 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-09-26 16:45:54 +0200 |
| commit | d22b84461e4f1a9dd77c8f93488a6914a2436090 (patch) | |
| tree | aeb4ed5312c500cb649dea427e30638070303ede /src/zencore/zencore.cpp | |
| parent | fix for C4244 truncation warning (#515) (diff) | |
| download | zen-d22b84461e4f1a9dd77c8f93488a6914a2436090.tar.xz zen-d22b84461e4f1a9dd77c8f93488a6914a2436090.zip | |
Make sure we call the previous terminate handle if present when we intercept terminate calls (#514)
Improvement: Make sure we call the previous terminate handle if present when we intercept terminate calls
Improvement: Avoid allocating memory for call stack in terminate handle and assert callback
Diffstat (limited to 'src/zencore/zencore.cpp')
| -rw-r--r-- | src/zencore/zencore.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/zencore/zencore.cpp b/src/zencore/zencore.cpp index 5a6232318..8ca1ad8c0 100644 --- a/src/zencore/zencore.cpp +++ b/src/zencore/zencore.cpp @@ -116,10 +116,10 @@ AssertImpl::~AssertImpl() void AssertImpl::ExecAssert(const char* Filename, int LineNumber, const char* FunctionName, const char* Msg) { - void* Frames[8]; - uint32_t FrameCount = GetCallstack(2, 8, Frames); - - CallstackFrames* Callstack = CreateCallstack(FrameCount, Frames); + constexpr int SkipFrameCount = 2; + constexpr int FrameCount = 8; + uint8_t CallstackBuffer[CallstackRawMemorySize(SkipFrameCount, FrameCount)]; + CallstackFrames* Callstack = GetCallstackRaw(&CallstackBuffer[0], SkipFrameCount, FrameCount); AssertImpl* AssertImpl = CurrentAssertImpl; while (AssertImpl) @@ -137,7 +137,7 @@ AssertImpl::ExecAssert(const char* Filename, int LineNumber, const char* Functio ThrowAssertException(Filename, LineNumber, FunctionName, Msg, Callstack); } void -AssertImpl::OnAssert(const char* Filename, int LineNumber, const char* FunctionName, const char* Msg, CallstackFrames* Callstack) +AssertImpl::OnAssert(const char* Filename, int LineNumber, const char* FunctionName, const char* Msg, const CallstackFrames* Callstack) { ZEN_UNUSED(FunctionName); @@ -152,11 +152,11 @@ AssertImpl::OnAssert(const char* Filename, int LineNumber, const char* FunctionN } void -AssertImpl::ThrowAssertException(const char* Filename, - int LineNumber, - const char* FunctionName, - const char* Msg, - CallstackFrames* Callstack) +AssertImpl::ThrowAssertException(const char* Filename, + int LineNumber, + const char* FunctionName, + const char* Msg, + const CallstackFrames* Callstack) { ZEN_UNUSED(FunctionName); fmt::basic_memory_buffer<char, 2048> Message; @@ -164,7 +164,7 @@ AssertImpl::ThrowAssertException(const char* Filename, fmt::format_to(Appender, "{}({}): {}", Filename, LineNumber, Msg); Message.push_back('\0'); - throw AssertException(Message.data(), Callstack); + throw AssertException(Message.data(), CloneCallstack(Callstack)); } void refcount_forcelink(); @@ -308,7 +308,7 @@ TEST_CASE("Assert.Custom") struct MyAssertImpl : AssertImpl { virtual void ZEN_FORCENOINLINE ZEN_DEBUG_SECTION - OnAssert(const char* Filename, int LineNumber, const char* FunctionName, const char* Msg, CallstackFrames* Callstack) + OnAssert(const char* Filename, int LineNumber, const char* FunctionName, const char* Msg, const CallstackFrames* Callstack) { ZEN_UNUSED(Callstack); AssertFileName = Filename; |