This commit is contained in:
Amber Brault 2024-12-07 22:21:15 -05:00
parent 016ce43787
commit 5949cd8aef
7 changed files with 53 additions and 72 deletions

View File

@ -33,7 +33,8 @@ void Symbol::Rename(const std::string& symbol_name)
this->function_name = GetStrippedFunctionName(symbol_name);
// Try demangling the symbol name, saving it in the symbol if valid.
auto demangle_result = CWDemangler::demangle(symbol_name, DemangleOptions::DemangleOptions());
DemangleOptions options = DemangleOptions::DemangleOptions();
auto demangle_result = CWDemangler::demangle(symbol_name, options);
if (demangle_result)
{
this->demangled_name = demangle_result.value();

View File

@ -9,50 +9,28 @@
#include "common/StringUtil.h"
static const std::map<std::string, std::string> operators = {
{"nw", "operator new"},
{"nwa", "operator new[]"},
{"dl", "operator delete"},
{"dla", "operator delete[]"},
{"pl", "operator+"},
{"mi", "operator-"},
{"ml", "operator*"},
{"dv", "operator/"},
{"md", "operator%"},
{"er", "operator^"},
{"ad", "operator&"},
{"or", "operator|"},
{"co", "operator~"},
{"nt", "operator!"},
{"as", "operator="},
{"lt", "operator<"},
{"gt", "operator>"},
{"apl", "operator+="},
{"ami", "operator-="},
{"amu", "operator*="},
{"adv", "operator/="},
{"amd", "operator%="},
{"aer", "operator^="},
{"aad", "operator&="},
{"aor", "operator|="},
{"ls", "operator<<"},
{"rs", "operator>>"},
{"ars", "operator>>="},
{"als", "operator<<="},
{"eq", "operator=="},
{"ne", "operator!="},
{"le", "operator<="},
{"ge", "operator>="},
{"aa", "operator&&"},
{"oo", "operator||"},
{"pp", "operator++"},
{"mm", "operator--"},
{"cm", "operator,"},
{"rm", "operator->*"},
{"rf", "operator->"},
{"cl", "operator()"},
{"vc", "operator[]"},
{"vt", "__vtable"}
};
{"nw", "operator new"}, {"nwa", "operator new[]"},
{"dl", "operator delete"}, {"dla", "operator delete[]"},
{"pl", "operator+"}, {"mi", "operator-"},
{"ml", "operator*"}, {"dv", "operator/"},
{"md", "operator%"}, {"er", "operator^"},
{"ad", "operator&"}, {"or", "operator|"},
{"co", "operator~"}, {"nt", "operator!"},
{"as", "operator="}, {"lt", "operator<"},
{"gt", "operator>"}, {"apl", "operator+="},
{"ami", "operator-="}, {"amu", "operator*="},
{"adv", "operator/="}, {"amd", "operator%="},
{"aer", "operator^="}, {"aad", "operator&="},
{"aor", "operator|="}, {"ls", "operator<<"},
{"rs", "operator>>"}, {"ars", "operator>>="},
{"als", "operator<<="}, {"eq", "operator=="},
{"ne", "operator!="}, {"le", "operator<="},
{"ge", "operator>="}, {"aa", "operator&&"},
{"oo", "operator||"}, {"pp", "operator++"},
{"mm", "operator--"}, {"cm", "operator,"},
{"rm", "operator->*"}, {"rf", "operator->"},
{"cl", "operator()"}, {"vc", "operator[]"},
{"vt", "__vtable"}};
std::tuple<std::string, std::string, std::string> CWDemangler::parse_qualifiers(std::string str)
{
@ -241,7 +219,7 @@ CWDemangler::demangle_qualified_name(std::string str, DemangleOptions options)
int count = 0;
if (!(std::istringstream(str.substr(1,1)) >> count))
if (!(std::istringstream(str.substr(1, 1)) >> count))
return {};
str = str.substr(2);
@ -547,7 +525,9 @@ CWDemangler::demangle_function_args(std::string str, DemangleOptions options)
return {{result, str}};
}
std::optional<std::string> CWDemangler::demangle_special_function(std::string str, std::string class_name, DemangleOptions options)
std::optional<std::string> CWDemangler::demangle_special_function(std::string str,
std::string class_name,
DemangleOptions options)
{
if (str.starts_with("op"))
{
@ -808,8 +788,7 @@ std::optional<std::string> CWDemangler::demangle(std::string str, DemangleOption
/// Finds the first double underscore in the string, excluding any that are part of a
/// template argument list or operator name.
std::optional<size_t> CWDemangler::find_split(std::string s, bool special,
DemangleOptions options)
std::optional<size_t> CWDemangler::find_split(std::string s, bool special, DemangleOptions options)
{
size_t start = 0;

View File

@ -22,10 +22,10 @@ struct DemangleOptions
mw_extensions = false;
}
DemangleOptions(bool omit_empty_parameters, bool mw_extensions)
DemangleOptions(bool omit_empty_params, bool mw_exts)
{
this->omit_empty_parameters = omit_empty_parameters;
this->mw_extensions = mw_extensions;
this->omit_empty_parameters = omit_empty_params;
this->mw_extensions = mw_exts;
}
};
@ -58,7 +58,6 @@ private:
return true;
}
static std::tuple<std::string, std::string, std::string> parse_qualifiers(std::string str);
static std::optional<std::tuple<int, std::string>> parse_digits(std::string str);
static std::optional<size_t> find_split(std::string s, bool special, DemangleOptions options);

View File

@ -433,6 +433,7 @@
<ClInclude Include="Core\PowerPC\CachedInterpreter\CachedInterpreterEmitter.h" />
<ClInclude Include="Core\PowerPC\ConditionRegister.h" />
<ClInclude Include="Core\PowerPC\CPUCoreBase.h" />
<ClInclude Include="Core\PowerPC\CWDemangler.h" />
<ClInclude Include="Core\PowerPC\Expression.h" />
<ClInclude Include="Core\PowerPC\GDBStub.h" />
<ClInclude Include="Core\PowerPC\Gekko.h" />
@ -1095,6 +1096,7 @@
<ClCompile Include="Core\PowerPC\CachedInterpreter\CachedInterpreterBlockCache.cpp" />
<ClCompile Include="Core\PowerPC\CachedInterpreter\CachedInterpreterEmitter.cpp" />
<ClCompile Include="Core\PowerPC\ConditionRegister.cpp" />
<ClCompile Include="Core\PowerPC\CWDemangler.cpp" />
<ClCompile Include="Core\PowerPC\Expression.cpp" />
<ClCompile Include="Core\PowerPC\GDBStub.cpp" />
<ClCompile Include="Core\PowerPC\Interpreter\Interpreter_Branch.cpp" />

View File

@ -71,22 +71,19 @@
<ItemGroup>
<Text Include="$(BuildInfoTemplate)" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Core\PowerPC\CWDemangler.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Core\PowerPC\CWDemangler.cpp" />
</ItemGroup>
<UsingTask TaskName="GetProductVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<UsingTask TaskName="GetProductVersion"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Path ParameterType="System.String" Required="true" />
<ProductVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.Diagnostics" />
<Using Namespace="System.Diagnostics"/>
<Code Type="Fragment" Language="cs"><![CDATA[
ProductVersion = FileVersionInfo.GetVersionInfo(Path).ProductVersion;
]]></Code>
]]>
</Code>
</Task>
</UsingTask>
<Target Name="WriteBuildInfo" AfterTargets="Build" Inputs="$(BuildInfoTemplate)" Outputs="$(BuildInfoOutput)">
@ -94,6 +91,10 @@
<Output PropertyName="VCToolsProductVersion" TaskParameter="ProductVersion" />
</GetProductVersion>
<Message Text="VCToolsProductVersion $(VCToolsProductVersion)" Importance="High" />
<WriteLinesToFile File="$(BuildInfoOutput)" Lines="$([System.IO.File]::ReadAllText($(BuildInfoTemplate)).Replace('${VC_TOOLS_VERSION}', $(VCToolsProductVersion)))" Overwrite="true" />
<WriteLinesToFile
File="$(BuildInfoOutput)"
Lines="$([System.IO.File]::ReadAllText($(BuildInfoTemplate)).Replace('${VC_TOOLS_VERSION}', $(VCToolsProductVersion)))"
Overwrite="true"
/>
</Target>
</Project>

View File

@ -454,8 +454,8 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
if (!caller_symbol->object_name.empty())
{
name = QString::fromStdString(fmt::format("< {} ({}, {:08x})", symbol_name,
caller_symbol->object_name, addr));
name = QString::fromStdString(
fmt::format("< {} ({}, {:08x})", symbol_name, caller_symbol->object_name, addr));
}
else
{

View File

@ -37,7 +37,8 @@ void DoDemangleQualifiedNameTest(std::string mangled, std::string baseName, std:
EXPECT_EQ(result, expected);
}
void DoDemangleArgTest(std::string mangled, std::string typePre, std::string typePost, std::string remainder)
void DoDemangleArgTest(std::string mangled, std::string typePre, std::string typePost,
std::string remainder)
{
DemangleOptions options = DemangleOptions();
@ -70,7 +71,8 @@ void DoDemangleTest(std::string mangled, std::string demangled)
EXPECT_EQ(result, expected);
}
void DoDemangleOptionsTest(bool omitEmptyParams, bool mwExtensions, std::string mangled, std::string demangled)
void DoDemangleOptionsTest(bool omitEmptyParams, bool mwExtensions, std::string mangled,
std::string demangled)
{
DemangleOptions options = DemangleOptions(omitEmptyParams, mwExtensions);
@ -84,8 +86,8 @@ TEST(CWDemangler, TestDemangleTemplateArgs)
{
DoDemangleTemplateArgsTest("single_ptr<10CModelData>", "single_ptr", "<CModelData>");
DoDemangleTemplateArgsTest("basic_string<w,Q24rstl14char_traits<w>,Q24rstl17rmemory_allocator>",
"basic_string",
"<wchar_t, rstl::char_traits<wchar_t>, rstl::rmemory_allocator>");
"basic_string",
"<wchar_t, rstl::char_traits<wchar_t>, rstl::rmemory_allocator>");
}
TEST(CWDemangler, TestDemangleName)
@ -438,6 +440,3 @@ TEST(CWDemangler, TestDemangleOptions)
DoDemangleOptionsTest(true, true, "fn<3,PV2>__FPC2",
"fn<3, volatile __vec2x32float__*>(const __vec2x32float__*)");
}