Add support for gnu debuglink

This commit is contained in:
Jeremy 2023-09-21 19:23:10 -04:00
parent 1689487978
commit 99230cb8fe
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4
2 changed files with 11 additions and 3 deletions

View File

@ -7,6 +7,8 @@
#if defined(_WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h>
#define CPPTRACE_MAX_PATH MAX_PATH
namespace cpptrace { namespace cpptrace {
namespace detail { namespace detail {
inline std::string program_name() { inline std::string program_name() {
@ -35,6 +37,8 @@ namespace detail {
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#include <sys/syslimits.h> #include <sys/syslimits.h>
#define CPPTRACE_MAX_PATH PATH_MAX
namespace cpptrace { namespace cpptrace {
namespace detail { namespace detail {
inline const char* program_name() { inline const char* program_name() {
@ -63,6 +67,8 @@ namespace detail {
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#define CPPTRACE_MAX_PATH PATH_MAX
namespace cpptrace { namespace cpptrace {
namespace detail { namespace detail {
inline const char* program_name() { inline const char* program_name() {

View File

@ -548,11 +548,14 @@ namespace libdwarf {
} }
#endif #endif
// Giving libdwarf a buffer for a true output path is needed for its automatic resolution of debuglink and
// dSYM files. We don't utilize the dSYM logic here, we just care about debuglink.
std::unique_ptr<char[]> buffer(new char[CPPTRACE_MAX_PATH]);
Dwarf_Ptr errarg = 0; Dwarf_Ptr errarg = 0;
auto ret = dwarf_init_path( auto ret = dwarf_init_path(
obj_path.c_str(), obj_path.c_str(),
nullptr, buffer.get(),
0, CPPTRACE_MAX_PATH,
DW_GROUPNUMBER_ANY, DW_GROUPNUMBER_ANY,
err_handler, err_handler,
errarg, errarg,
@ -563,7 +566,6 @@ namespace libdwarf {
// fail, no debug info // fail, no debug info
} else if(ret != DW_DLV_OK) { } else if(ret != DW_DLV_OK) {
fprintf(stderr, "Error\n"); fprintf(stderr, "Error\n");
} else {
} }
} }