Skip to content

Commit

Permalink
Merge pull request #48220 from BrettDong/mingw
Browse files Browse the repository at this point in the history
Fix C++ symbol demangling on cross-compile MinGW
  • Loading branch information
ZhilkinSerg authored Mar 25, 2021
2 parents 944ef4c + 0ff6bf7 commit 082dcf3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,18 @@ static const char *demangle( const char *symbol )
if( status == 0 ) {
return demangled;
}
#if defined(_WIN32)
// https://stackoverflow.com/questions/54333608/boost-stacktrace-not-demangling-names-when-cross-compiled
// libbacktrace may strip leading underscore character in the symbol name returned
// so if demangling failed, try again with an underscore prepended
std::string prepend_underscore( "_" );
prepend_underscore = prepend_underscore + symbol;
demangled = abi::__cxa_demangle( prepend_underscore.c_str(), nullptr, nullptr, &status );
if( status == 0 ) {
return demangled;
}
#endif // defined(_WIN32)
#endif // compiler macros
return symbol;
}

Expand Down

0 comments on commit 082dcf3

Please sign in to comment.