[PATCH] D110664: [Symbolize] Demangle Rust symbols

Tomasz Miąsko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 28 15:30:42 PDT 2021


tmiasko created this revision.
Herald added subscribers: JDevlieghere, hiraditya.
tmiasko requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Demangle symbols using Rust symbol mangling scheme.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110664

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


Index: llvm/test/DebugInfo/symbolize-demangling.s
===================================================================
--- llvm/test/DebugInfo/symbolize-demangling.s
+++ 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
Index: llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
===================================================================
--- llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -665,6 +665,15 @@
     return Result;
   }
 
+  if (Name.size() >= 2 && Name[0] == '_' && Name[1] == 'R') {
+    char *DemangledName = rustDemangle(Name.c_str(), nullptr, nullptr, nullptr);
+    if (DemangledName == nullptr)
+      return Name;
+    std::string Result = DemangledName;
+    free(DemangledName);
+    return Result;
+  }
+
   if (!Name.empty() && Name.front() == '?') {
     // Only do MSVC C++ demangling on symbols starting with '?'.
     int status = 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110664.375723.patch
Type: text/x-patch
Size: 1697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210928/53c4d70d/attachment.bin>


More information about the llvm-commits mailing list