diff options
| author | Zachary Turner <zturner@google.com> | 2018-08-01 18:33:04 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2018-08-01 18:33:04 +0000 |
| commit | 3a758e22df733620b0380a4296ed0f9315eb6182 (patch) | |
| tree | 0c5302ad0230709d824a5d7e3091322e826c7a82 /llvm/lib/Demangle | |
| parent | 44ebbc216a00dd16ca716e9c0a1871c7badcf85a (diff) | |
| download | bcm5719-llvm-3a758e22df733620b0380a4296ed0f9315eb6182.tar.gz bcm5719-llvm-3a758e22df733620b0380a4296ed0f9315eb6182.zip | |
[llvm-undname Add an option to dump back references.
This is useful for understanding how our demangler processes
back references and for investigating issues related to
back references. But it's a feature only useful for debugging
the demangling process itself, so I'm marking it hidden.
llvm-svn: 338609
Diffstat (limited to 'llvm/lib/Demangle')
| -rw-r--r-- | llvm/lib/Demangle/MicrosoftDemangle.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index 04575818422..9cf7c4bb127 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -878,6 +878,8 @@ public: // True if an error occurred. bool Error = false; + void dumpBackReferences(); + private: Type *demangleVariableEncoding(StringView &MangledName); Type *demangleFunctionEncoding(StringView &MangledName); @@ -2046,12 +2048,43 @@ void Demangler::output(const Symbol *S, OutputStream &OS) { Type::outputPost(OS, *S->SymbolType); } +void Demangler::dumpBackReferences() { + printf("%d function parameter backreferences\n", + (int)FunctionParamBackRefCount); + + // Create an output stream so we can render each type. + OutputStream OS = OutputStream::create(nullptr, 0, 1024); + for (size_t I = 0; I < FunctionParamBackRefCount; ++I) { + OS.setCurrentPosition(0); + + Type *T = FunctionParamBackRefs[I]; + Type::outputPre(OS, *T); + Type::outputPost(OS, *T); + + printf(" [%d] - %*s\n", (int)I, (int)OS.getCurrentPosition(), + OS.getBuffer()); + } + std::free(OS.getBuffer()); + + if (FunctionParamBackRefCount > 0) + printf("\n"); + printf("%d name backreferences\n", (int)BackRefCount); + for (size_t I = 0; I < BackRefCount; ++I) { + printf(" [%d] - %*s\n", (int)I, (int)BackReferences[I].size(), + BackReferences[I].begin()); + } + if (BackRefCount > 0) + printf("\n"); +} + char *llvm::microsoftDemangle(const char *MangledName, char *Buf, size_t *N, - int *Status) { + int *Status, MSDemangleFlags Flags) { Demangler D; StringView Name{MangledName}; Symbol *S = D.parse(Name); + if (Flags & MSDF_DumpBackrefs) + D.dumpBackReferences(); OutputStream OS = OutputStream::create(Buf, N, 1024); if (D.Error) { OS << MangledName; |

