Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Oct 25, 2024
1 parent fd71b74 commit a3c663b
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions src/bx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,43 @@ namespace bx

static bool defaultAssertHandler(const Location& _location, const char* _format, va_list _argList)
{
char temp[8192];
int32_t pos = 0;
char temp[8192];
int32_t total = 0;

pos += snprintf(&temp[pos], max(0, sizeof(temp)-pos), "%s(%d): "
StaticMemoryBlockWriter smb(temp, BX_COUNTOF(temp) );

ErrorIgnore err;

total += write(&smb, &err, "\n--- ASSERT ---\n\n");

total += write(&smb, &err, "%s(%d): "
, _location.filePath
, _location.line
);
pos += vsnprintf(&temp[pos], max(0, sizeof(temp)-pos), _format, _argList);
pos += snprintf(&temp[pos], max(0, sizeof(temp)-pos), "\n");
debugOutput(temp);
total += write(&smb, _format, _argList, &err);
total += write(&smb, "\n\n", &err);

uintptr_t stack[32];
const uint32_t num = getCallStack(2 /* skip self */, BX_COUNTOF(stack), stack);
total += writeCallstack(&smb, stack, num, &err);

total += write(&smb, &err,
"\nBuild info:\n"
"\tCompiler: " BX_COMPILER_NAME
", CPU: " BX_CPU_NAME
", Arch: " BX_ARCH_NAME
", OS: " BX_PLATFORM_NAME
", CRT: " BX_CRT_NAME
", C++: " BX_CPP_NAME

", Date: " __DATE__
", Time: " __TIME__
"\n"
);

total += write(&smb, &err, "\n--- END ---\n\n");

debugOutputCallstack(2);
write(getDebugOut(), temp, total, ErrorIgnore{});

return true;
}
Expand Down

0 comments on commit a3c663b

Please sign in to comment.