Fix compile error and the backtrace (sorta, still sucks) for Linux

This commit is contained in:
Magnus Norddahl 2025-04-21 00:01:42 +02:00
commit 1471eea6e5
3 changed files with 24 additions and 2 deletions

View file

@ -1461,6 +1461,10 @@ if( APPLE )
# Dymanic libraries like libvulkan.dylib or libMoltenVK.dylib will be loaded by dlopen()
# if placed in the directory with the main executable
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rpath @executable_path" )
elseif(UNIX)
# backtrace wants -rdynamic to print friendly names.
# We should consider switching to libbacktrace as it reads DWARF debug info instead of staying with the API from 1865...
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic" )
endif()
if( WIN32 )

View file

@ -66,6 +66,7 @@
#include "c_commandbuffer.h"
#include "vm.h"
#include "common/widgets/errorwindow.h"
#include <algorithm>
#define LEFTMARGIN 8
#define RIGHTMARGIN 8
@ -425,7 +426,7 @@ void GetLog(std::function<bool(const void* data, uint32_t size, uint32_t& writte
size_t len = line.Len();
while (pos < len)
{
uint32_t size = (uint32_t)std::min(len - pos, 0x0fffffffULL);
uint32_t size = (uint32_t)std::min(len - pos, (size_t)0x0fffffffULL);
uint32_t written = 0;
if (!writeData(&line[pos], size, written))
return;

View file

@ -913,10 +913,23 @@ public:
char *new_function = abi::__cxa_demangle(function, nullptr, nullptr, &status);
if (new_function) // Was correctly decoded
{
// Remove the function arguments
for (int i = 0; new_function[i] != 0; i++)
{
if (new_function[i] == '(')
{
new_function[i] = 0;
break;
}
}
function = new_function;
}
s.Format("Called from %s at %s\n", function, filename);
if (strlen(function) != 0)
s.Format("Called from %s at %s\n", function, filename);
else
s.Format("Called from %s\n", strings[0]);
if (new_function)
{
@ -975,6 +988,10 @@ FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames, int max
if (includeNativeFrames)
nativeSymbols.reset(new NativeSymbolResolver());
#if !defined(WIN32)
framesToSkip += 2;
#endif
int total = 0;
FString s;
for (int i = framesToSkip + 1; i < numframes; i++)