mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Fix Demangle when used standalone (#2256)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -11,19 +11,22 @@
|
||||
|
||||
#include <dbghelp.h>
|
||||
|
||||
#include "wpi/SmallString.h"
|
||||
#include "wpi/mutex.h"
|
||||
|
||||
#pragma comment(lib, "Dbghelp.lib")
|
||||
|
||||
namespace wpi {
|
||||
|
||||
std::string Demangle(char const* mangledSymbol) {
|
||||
std::string Demangle(const Twine& mangledSymbol) {
|
||||
static wpi::mutex m;
|
||||
std::scoped_lock lock(m);
|
||||
SmallString<128> buf;
|
||||
char buffer[256];
|
||||
DWORD sz = UnDecorateSymbolName(mangledSymbol, buffer, sizeof(buffer),
|
||||
UNDNAME_COMPLETE);
|
||||
if (sz == 0) return mangledSymbol;
|
||||
DWORD sz =
|
||||
UnDecorateSymbolName(mangledSymbol.toNullTerminatedStringRef(buf).data(),
|
||||
buffer, sizeof(buffer), UNDNAME_COMPLETE);
|
||||
if (sz == 0) return mangledSymbol.str();
|
||||
return std::string(buffer, sz);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user