[Lldb-commits] [PATCH] D116217: [lldb] Fix PR52702 by fixing Mangled::operator!
PoYao Chang via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 23 04:32:52 PST 2021
rZhBoYao created this revision.
rZhBoYao added reviewers: clayborg, wallace, JDevlieghere.
rZhBoYao added a project: LLDB.
rZhBoYao requested review of this revision.
Herald added a subscriber: lldb-commits.
Mangled::operator! claimes to be true if the object has an empty mangled and unmangled name, false otherwise, but it was actually true if the object has an empty mangled name. Luckily, this operator doesn't have a lot of users.
The broken logical not operator causes PR52702 <https://llvm.org/PR52702> as https://reviews.llvm.org/D106837 used Mangled::operator! in Symbol::SynthesizeNameIfNeeded. For example, consider the symbol "puts" in a hello world C program:
// Inside Symbol::SynthesizeNameIfNeeded
(lldb) p m_mangled
(lldb_private::Mangled) $0 = (m_mangled = None, m_demangled = "puts")
(lldb) p !m_mangled
(bool) $1 = true # should be false!!
This leads to Symbol::SynthesizeNameIfNeeded overwriting m_demangled part of Mangled (in this case "puts").
In conclusion, this patch turns
`callq 0x401030 ; symbol stub for: ___lldb_unnamed_symbol36`
back into
`callq 0x401030 ; symbol stub for: puts` .
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D116217
Files:
lldb/source/Core/Mangled.cpp
Index: lldb/source/Core/Mangled.cpp
===================================================================
--- lldb/source/Core/Mangled.cpp
+++ lldb/source/Core/Mangled.cpp
@@ -86,7 +86,7 @@
// Mangled mangled(...);
// if (!file_spec)
// { ...
-bool Mangled::operator!() const { return !m_mangled; }
+bool Mangled::operator!() const { return !m_mangled && !m_demangled; }
// Clear the mangled and demangled values.
void Mangled::Clear() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116217.396005.patch
Type: text/x-patch
Size: 446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211223/7543bdf1/attachment.bin>
More information about the lldb-commits
mailing list