Move demangling function to utility helper in DXBC

This commit is contained in:
baldurk
2024-05-20 14:51:22 +01:00
parent 54b425e92e
commit c475053489
3 changed files with 17 additions and 7 deletions
@@ -412,4 +412,7 @@ public:
virtual void GetLocals(const DXBC::DXBCContainer *dxbc, size_t instruction, uintptr_t offset,
rdcarray<SourceVariableMapping> &locals) const = 0;
};
rdcstr BasicDemangle(rdcstr possiblyMangledName);
};
@@ -42,6 +42,19 @@ RDOC_EXTERN_CONFIG(rdcarray<rdcstr>, DXBC_Debug_SearchDirPaths);
namespace DXBC
{
rdcstr BasicDemangle(rdcstr possiblyMangledName)
{
if(possiblyMangledName.size() > 2 && possiblyMangledName[0] == '\x1' &&
possiblyMangledName[1] == '?')
{
int idx = possiblyMangledName.indexOf('@');
if(idx > 2)
return possiblyMangledName.substr(2, idx - 2);
}
return possiblyMangledName;
}
struct RDEFCBufferVariable
{
uint32_t nameOffset;
@@ -340,13 +340,7 @@ void MakeShaderReflection(DXBC::DXBCContainer *dxbc, const ShaderEntryPoint &ent
refl->debugInfo.entrySourceName = refl->entryPoint = entryFunc;
// demangle DXIL source names for display
if(refl->debugInfo.entrySourceName.size() > 2 && refl->debugInfo.entrySourceName[0] == '\x1' &&
refl->debugInfo.entrySourceName[1] == '?')
{
int idx = refl->debugInfo.entrySourceName.indexOf('@');
if(idx > 2)
refl->debugInfo.entrySourceName = refl->debugInfo.entrySourceName.substr(2, idx - 2);
}
refl->debugInfo.entrySourceName = DXBC::BasicDemangle(refl->entryPoint);
// assume the debug info put the file with the entry point at the start. SDBG seems to do this
// by default, and SPDB has an extra sorting step that probably maybe possibly does this.