repr 0.1
Reconstructable string representations and more
Loading...
Searching...
No Matches
undecorate.h
Go to the documentation of this file.
1#pragma once
2
3#include <librepr/feature.h>
5
6#if USING(LIBREPR_PLATFORM_WINDOWS)
7#pragma comment(lib, "dbghelp.lib")
8
9#define WIN32_LEAN_AND_MEAN
10#define NOMINMAX
11#include <Windows.h>
12#include <DbgHelp.h>
13
14#include <array>
15#include <mutex>
16#include <typeinfo>
17
19
20#include "denoise.h"
21#include "undname.h"
22
23namespace librepr::detail {
24namespace msvc {
27 inline constexpr bool has_rawname = requires(const std::type_info& ty) { ty.raw_name(); };
28} // namespace msvc
29
30// TODO: Make this better ig
31[[nodiscard]] inline int syminit_() {
34 assert(did_initialize && "Failed to initialize the symbol handler!");
35 return true;
36}
37
38inline std::size_t undecorate_name(const char* symdata, DemangleBuffer& buf) {
39 { [[maybe_unused]] static int sym = syminit_(); }
40 static std::mutex mtx { };
41 if(!symdata) [[unlikely]] { return 0; }
42 if constexpr (msvc::has_rawname) {
43 if (*symdata == '.') [[likely]] {
44 constexpr static auto flags =
46 msvc::unDName((symdata + 1), buf, UndStrategy::Type(flags));
47 auto denoised = denoise_name({ buf.data() });
48 std::memcpy(buf.data(), denoised.data(), denoised.size());
49 return denoised.size();
50 }
51 }
53 "Got '{}', expected '?'", *symdata);
57}
58} // namespace librepr::detail
59#endif
#define LIBREPR_SOFT_ASSERT(...)
Only checks assertion when REPR_HARD_CHECKS is ON.
Definition assert.h:78
#define REPR_DEMANGLE_MAX
Definition default.h:46
T lock(T... args)
T memcpy(T... args)
UndHandle unDName(const char *name, UndStrategy::Type flags)
Returns a managed handle to the demangled buffer.
Definition undname.h:80
Definition assert.h:89
LIBREPR_HINT_INLINE std::string denoise_name(std::string_view name)
Formats undecorated symbols to match itanium's symbols.
Definition denoise.h:240
std::array< char, REPR_DEMANGLE_MAX > DemangleBuffer
Wrapped buffer for demangling.
Definition undname.h:18
std::string code_for()
Definition repr:39
@ TypeOnly
Definition undname.h:44
@ Decode32Bit
Definition undname.h:42
decltype(Complete) Type
Definition undname.h:50