[PATCH] D139864: [AIX] Demangle the name prefix with '.' in AIX OS
Digger Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 11:08:54 PST 2022
DiggerLin created this revision.
DiggerLin added reviewers: jhenderson, hubert.reinterpretcast, xingxue, Esme.
Herald added a project: All.
DiggerLin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In AIX OS, function entry lable are begin with '.', it can not be decoded currently.
we support to decode the name in this patch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139864
Files:
llvm/test/tools/llvm-cxxfilt/delimiters.test
llvm/test/tools/llvm-cxxfilt/with-dot-prefix-aix.test
llvm/test/tools/llvm-cxxfilt/with-dot-prefix-non-aix.test
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
Index: llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
===================================================================
--- llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
+++ llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
@@ -66,13 +66,21 @@
static std::string demangle(const std::string &Mangled) {
const char *DecoratedStr = Mangled.c_str();
+ std::string DotPrefix;
+
+ // In XCOFF, Function entry lable begin with '.'.
+ if (Triple(sys::getProcessTriple()).isOSBinFormatXCOFF() && DecoratedStr[0] == '.') {
+ ++DecoratedStr;
+ DotPrefix = ".";
+ }
+
if (StripUnderscore)
if (DecoratedStr[0] == '_')
++DecoratedStr;
std::string Result;
if (nonMicrosoftDemangle(DecoratedStr, Result))
- return Result;
+ return DotPrefix + Result;
std::string Prefix;
char *Undecorated = nullptr;
@@ -85,7 +93,7 @@
Undecorated = itaniumDemangle(DecoratedStr + 6, nullptr, nullptr, nullptr);
}
- Result = Undecorated ? Prefix + Undecorated : Mangled;
+ Result = Undecorated ? DotPrefix + Prefix + Undecorated : Mangled;
free(Undecorated);
return Result;
}
Index: llvm/test/tools/llvm-cxxfilt/with-dot-prefix-non-aix.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-cxxfilt/with-dot-prefix-non-aix.test
@@ -0,0 +1,7 @@
+## Show the behaviour of demangling name with '.' prefix on Non-AIX os.
+REQUIRES: !system-aix
+
+RUN: llvm-cxxfilt ._ZL5func0v ._Z5func1i | FileCheck %s -check-prefix CHECK
+
+CHECK: ._ZL5func0v
+CHECK: ._Z5func1i
Index: llvm/test/tools/llvm-cxxfilt/with-dot-prefix-aix.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-cxxfilt/with-dot-prefix-aix.test
@@ -0,0 +1,8 @@
+## Show the behaviour of demangling name with '.' prefix on AIX OS.
+
+REQUIRES: system-aix
+
+RUN: llvm-cxxfilt ._ZL5func0v ._Z5func1i | FileCheck %s -check-prefix CHECK
+
+CHECK: .func0()
+CHECK: .func1(int)
Index: llvm/test/tools/llvm-cxxfilt/delimiters.test
===================================================================
--- llvm/test/tools/llvm-cxxfilt/delimiters.test
+++ llvm/test/tools/llvm-cxxfilt/delimiters.test
@@ -32,7 +32,7 @@
COM: Piping the echo output causes '⦙' to be converted to '?' in some
COM: builds/environments. Redirect echo output to and from %t to work
COM: around this. See D111072.
-RUN: '_Z3Foo$ ._Z3Foo' > %t
+RUN: '_Z3Foo$' > %t
RUN: llvm-cxxfilt -n < %t | FileCheck %s
CHECK: ,,Foo!
@@ -66,4 +66,4 @@
CHECK: Foo~,,
CHECK: Foo⦙Bar
CHECK: Foo,,Bar::Baz Foo,Bar:Baz
-CHECK: _Z3Foo$ ._Z3Foo
+CHECK: _Z3Foo$
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139864.482195.patch
Type: text/x-patch
Size: 2627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221212/f58f9882/attachment-0001.bin>
More information about the llvm-commits
mailing list