[llvm] 48ce523 - [Symbolize] Demangle Rust symbols

Tomasz Miąsko via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 16 04:35:25 PDT 2021


Author: Tomasz Miąsko
Date: 2021-10-16T13:32:17+02:00
New Revision: 48ce523a26b7a5a3dc4cff616c93ed951244746b

URL: https://github.com/llvm/llvm-project/commit/48ce523a26b7a5a3dc4cff616c93ed951244746b
DIFF: https://github.com/llvm/llvm-project/commit/48ce523a26b7a5a3dc4cff616c93ed951244746b.diff

LOG: [Symbolize] Demangle Rust symbols

Add support for demangling Rust v0 symbols to LLVM symbolizer by reusing
nonMicrosoftDemangle which supports both Itanium and Rust mangling.

Reviewed By: dblaikie, jhenderson

Part of https://reviews.llvm.org/D110664

Added: 
    

Modified: 
    llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
    llvm/test/DebugInfo/symbolize-demangling.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index fb4875f797d7b..6da0b69077861 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -652,18 +652,9 @@ StringRef demanglePE32ExternCFunc(StringRef SymbolName) {
 std::string
 LLVMSymbolizer::DemangleName(const std::string &Name,
                              const SymbolizableModule *DbiModuleDescriptor) {
-  // We can spoil names of symbols with C linkage, so use an heuristic
-  // approach to check if the name should be demangled.
-  if (Name.substr(0, 2) == "_Z") {
-    int status = 0;
-    char *DemangledName =
-        itaniumDemangle(Name.c_str(), nullptr, nullptr, &status);
-    if (status != 0)
-      return Name;
-    std::string Result = DemangledName;
-    free(DemangledName);
+  std::string Result;
+  if (nonMicrosoftDemangle(Name.c_str(), Result))
     return Result;
-  }
 
   if (!Name.empty() && Name.front() == '?') {
     // Only do MSVC C++ demangling on symbols starting with '?'.
@@ -674,7 +665,7 @@ LLVMSymbolizer::DemangleName(const std::string &Name,
                         MSDF_NoMemberType | MSDF_NoReturnType));
     if (status != 0)
       return Name;
-    std::string Result = DemangledName;
+    Result = DemangledName;
     free(DemangledName);
     return Result;
   }

diff  --git a/llvm/test/DebugInfo/symbolize-demangling.s b/llvm/test/DebugInfo/symbolize-demangling.s
index acd769a286ff4..ff29b9969af42 100644
--- a/llvm/test/DebugInfo/symbolize-demangling.s
+++ b/llvm/test/DebugInfo/symbolize-demangling.s
@@ -2,23 +2,29 @@
 
 # RUN: llvm-mc --filetype=obj --triple=x86_64-pc-linux %s -o %t.o -g
 
-# RUN: llvm-symbolizer --obj=%t.o 0 1 2 | FileCheck %s
+# RUN: llvm-symbolizer --obj=%t.o 0 1 2 3 | FileCheck %s
 
 # CHECK:       f()
-# CHECK-NEXT:  symbolize-demangling.s:20
+# CHECK-NEXT:  symbolize-demangling.s:24
 # CHECK-EMPTY:
 # CHECK-NEXT:  {{^g$}}
-# CHECK-NEXT:  symbolize-demangling.s:22
+# CHECK-NEXT:  symbolize-demangling.s:26
 # CHECK-EMPTY:
 # CHECK-NEXT:  {{^baz$}}
-# CHECK-NEXT:  symbolize-demangling.s:24
+# CHECK-NEXT:  symbolize-demangling.s:28
+# CHECK-EMPTY:
+# CHECK-NEXT:  {{^x::y$}}
+# CHECK-NEXT:  symbolize-demangling.s:30
 
 .type _Z1fv, at function
 .type g, at function
 .type baz, at function
+.type _RNvC1x1y, at function
 _Z1fv:
   nop
 g:
   nop
 baz:
   nop
+_RNvC1x1y:
+  nop


        


More information about the llvm-commits mailing list