build: Move all demangler uses into the trace library

This commit is contained in:
WerWolv
2025-07-30 20:57:53 +02:00
parent ec9461741c
commit 6fcc3e8cb3
12 changed files with 28 additions and 59 deletions

View File

@@ -49,8 +49,6 @@ add_imhex_plugin(
source/content/window_decoration.cpp
source/content/data_information_sections.cpp
source/content/helpers/demangle.cpp
source/content/data_processor_nodes/basic_nodes.cpp
source/content/data_processor_nodes/control_nodes.cpp
source/content/data_processor_nodes/decode_nodes.cpp
@@ -130,7 +128,6 @@ add_imhex_plugin(
${JTHREAD_LIBRARIES}
plcli
libpl-gen
LLVMDemangle
)
if (WIN32)

View File

@@ -1,9 +0,0 @@
#pragma once
#include <string>
namespace hex::plugin::builtin {
std::string demangle(const std::string &mangled);
}

View File

@@ -3,8 +3,7 @@
#include <hex/ui/popup.hpp>
#include <hex/api/localization_manager.hpp>
#include <llvm/Demangle/Demangle.h>
#include <hex/trace/stacktrace.hpp>
#include <string>
@@ -20,7 +19,7 @@ namespace hex::plugin::builtin {
void drawContent() override {
ImGuiExt::TextFormattedWrapped("hex.builtin.popup.crash_recover.message"_lang);
ImGuiExt::TextFormattedWrapped(hex::format("Error: {}: {}", llvm::demangle(this->m_errorType), this->m_errorMessage));
ImGuiExt::TextFormattedWrapped(hex::format("Error: {}: {}", trace::demangle(this->m_errorType), this->m_errorMessage));
if (ImGui::Button("hex.ui.common.okay"_lang)) {
this->close();

View File

@@ -1,6 +1,5 @@
#include <content/command_line_interface.hpp>
#include <content/providers/file_provider.hpp>
#include <content/helpers/demangle.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/imhex_api.hpp>
@@ -18,13 +17,13 @@
#include <hex/helpers/debugging.hpp>
#include <hex/subcommands/subcommands.hpp>
#include <hex/trace/stacktrace.hpp>
#include <romfs/romfs.hpp>
#include <wolv/utils/string.hpp>
#include <wolv/math_eval/math_evaluator.hpp>
#include <pl/cli/cli.hpp>
#include <llvm/Demangle/Demangle.h>
namespace hex::plugin::builtin {
using namespace hex::literals;
@@ -383,7 +382,7 @@ namespace hex::plugin::builtin {
std::exit(EXIT_FAILURE);
}
log::println("{}", hex::plugin::builtin::demangle(args[0]));
log::println("{}", trace::demangle(args[0]));
std::exit(EXIT_SUCCESS);
}

View File

@@ -1,17 +0,0 @@
#include <content/helpers/demangle.hpp>
#include <llvm/Demangle/Demangle.h>
namespace hex::plugin::builtin {
std::string demangle(const std::string &mangled) {
std::string result = llvm::demangle(mangled);
if (result.empty() || result == mangled)
result = llvm::demangle("_" + mangled);
if (result.empty() || result == ("_" + mangled))
result = mangled;
return result;
}
}

View File

@@ -3,11 +3,11 @@
#include <hex/providers/provider.hpp>
#include <hex/helpers/http_requests.hpp>
#include <hex/trace/stacktrace.hpp>
#include <pl/core/token.hpp>
#include <pl/core/evaluator.hpp>
#include <content/helpers/demangle.hpp>
#include <pl/patterns/pattern.hpp>
namespace hex::plugin::builtin {
@@ -75,7 +75,7 @@ namespace hex::plugin::builtin {
ContentRegistry::PatternLanguage::addFunction(nsHexDec, "demangle", FunctionParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
const auto mangledString = params[0].toString(false);
return hex::plugin::builtin::demangle(mangledString);
return trace::demangle(mangledString);
});
}

View File

@@ -1,10 +1,9 @@
#include <hex/helpers/utils.hpp>
#include <hex/api/localization_manager.hpp>
#include <content/helpers/demangle.hpp>
#include <hex/trace/stacktrace.hpp>
#include <hex/ui/imgui_imhex_extensions.h>
#include <imgui.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <TextEditor.h>
@@ -31,7 +30,7 @@ namespace hex::plugin::builtin {
static float prevWindowWidth;
if (ImGui::InputTextWithHint("hex.builtin.tools.demangler.mangled"_lang, "Itanium, MSVC, Dlang & Rust", mangledName)) {
demangledName = hex::plugin::builtin::demangle(mangledName);
demangledName = trace::demangle(mangledName);
if (demangledName == mangledName) {
demangledName = "???";

View File

@@ -3,6 +3,7 @@
#include <hex/api/imhex_api.hpp>
#include <hex/api/achievement_manager.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/trace/stacktrace.hpp>
#include <hex/providers/buffered_reader.hpp>
@@ -13,7 +14,6 @@
#include <string>
#include <utility>
#include <content/helpers/demangle.hpp>
#include <boost/regex.hpp>
namespace hex::plugin::builtin {
@@ -71,7 +71,7 @@ namespace hex::plugin::builtin {
ImGui::TableNextColumn();
ImGuiExt::TextFormatted("[ 0x{:08X} - 0x{:08X} ]", region.getStartAddress(), region.getEndAddress());
auto demangledValue = hex::plugin::builtin::demangle(value);
auto demangledValue = trace::demangle(value);
if (value != demangledValue) {
ImGui::TableNextRow();
@@ -663,7 +663,7 @@ namespace hex::plugin::builtin {
if (ImGui::MenuItemEx("hex.builtin.view.find.context.copy"_lang, ICON_VS_COPY))
ImGui::SetClipboardText(value.c_str());
if (ImGui::MenuItemEx("hex.builtin.view.find.context.copy_demangle"_lang, ICON_VS_FILES))
ImGui::SetClipboardText(hex::plugin::builtin::demangle(value).c_str());
ImGui::SetClipboardText(trace::demangle(value).c_str());
if (ImGui::BeginMenuEx("hex.builtin.view.find.context.replace"_lang, ICON_VS_REPLACE)) {
if (ImGui::BeginTabBar("##replace_tabs")) {
if (ImGui::BeginTabItem("hex.builtin.view.find.context.replace.hex"_lang)) {