use cxxabi for demangling on linux/windows

This commit is contained in:
Michael Scire 2022-03-10 15:24:26 -08:00 committed by SciresM
parent ee5f99fdb4
commit 49cddd68e4
5 changed files with 15 additions and 5 deletions

View file

@ -82,7 +82,7 @@ export LIBS := -lstratosphere -lnx
else ifeq ($(ATMOSPHERE_BOARD),generic_windows)
export LIBS := -lstratosphere -lwinmm -lws2_32 -lbcrypt -lbfd -liberty -lintl -lz
else ifeq ($(ATMOSPHERE_BOARD),generic_linux)
export LIBS := -lstratosphere -pthread -lbfd -liberty -ldl
export LIBS := -lstratosphere -pthread -lbfd
else ifeq ($(ATMOSPHERE_BOARD),generic_macos)
export LIBS := -lstratosphere -pthread
else

View file

@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "impl/diag_get_all_backtrace.hpp"
#include "impl/diag_invoke_abort.hpp"
namespace ams::diag {
@ -179,6 +180,9 @@ namespace ams::diag {
std::scoped_lock lk(g_abort_mutex);
/* Set the abort impl return address. */
impl::SetAbortImplReturnAddress(reinterpret_cast<uintptr_t>(__builtin_return_address(0)));
/* Create abort info. */
std::va_list cvl;
va_copy(cvl, vl);

View file

@ -23,6 +23,10 @@ namespace ams::diag::impl {
}
void SetAbortImplReturnAddress(uintptr_t address) {
g_abort_impl_return_address = address;
}
size_t GetAllBacktrace(uintptr_t *out, size_t out_size, ::ams::diag::Backtrace &bt) {
size_t count = 0;
do {

View file

@ -18,7 +18,7 @@
namespace ams::diag::impl {
void SetAbortImplAddress(uintptr_t address);
void SetAbortImplReturnAddress(uintptr_t address);
size_t GetAllBacktrace(uintptr_t *out, size_t out_size, ::ams::diag::Backtrace &bt);

View file

@ -35,8 +35,7 @@
extern "C" char __init_array_start;
#endif
#define HAVE_DECL_BASENAME 1
#include <libiberty/demangle.h>
#include <cxxabi.h>
namespace ams::diag::impl {
@ -219,7 +218,10 @@ namespace ams::diag::impl {
/* Print the symbol. */
const char *name = bfd_asymbol_name(*symbol);
if (auto *demangled = bfd_demangle(m_handle, name, DMGL_ANSI | DMGL_PARAMS); demangled != nullptr) {
int cpp_name_status = 0;
if (char *demangled = abi::__cxa_demangle(name, nullptr, 0, std::addressof(cpp_name_status)); cpp_name_status == 0) {
AMS_ASSERT(demangled != nullptr);
util::TSNPrintf(dst, dst_size, "%s", demangled);
std::free(demangled);
} else {