Skip to content

Commit 1429cfc

Browse files
committed
Hopefully final ci fixes
1 parent 82ef228 commit 1429cfc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/demangle/demangle_with_cxxabi.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "utils/microfmt.hpp"
12
#ifdef CPPTRACE_DEMANGLE_WITH_CXXABI
23

34
#include "demangle/demangle.hpp"
@@ -18,6 +19,11 @@ namespace detail {
1819
if(!(starts_with(name, "_Z") || starts_with(name, "__Z"))) {
1920
return name;
2021
}
22+
// Apple clang demangles __Z just fine but gcc doesn't, so just offset the leading underscore
23+
std::size_t offset = 0;
24+
if(starts_with(name, "__Z")) {
25+
offset = 1;
26+
}
2127
// Mangled names don't have spaces, we might add a space and some extra info somewhere but we still want it to
2228
// be demanglable. Look for a space, if there is one swap it with a null terminator briefly.
2329
auto end = name.find(' ');
@@ -33,7 +39,7 @@ namespace detail {
3339
// it appears safe to pass nullptr for status however the docs don't explicitly say it's safe so I don't
3440
// want to rely on it
3541
int status;
36-
char* const demangled = abi::__cxa_demangle(to_demangle.get().c_str(), nullptr, nullptr, &status);
42+
char* const demangled = abi::__cxa_demangle(to_demangle.get().c_str() + offset, nullptr, nullptr, &status);
3743
// demangled will always be nullptr on non-zero status, and if __cxa_demangle ever fails for any reason
3844
// we'll just quietly return the mangled name
3945
if(demangled) {

test/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cc_test(
77
],
88
srcs = [
99
"unit/main.cpp",
10+
"unit/tracing/common.hpp",
1011
"unit/tracing/raw_trace.cpp",
1112
"unit/tracing/object_trace.cpp",
1213
"unit/tracing/stacktrace.cpp",

0 commit comments

Comments
 (0)