[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 7 03:25:57 PST 2023
=?utf-8?q?José?= L. Junior <josejunior at 10xengineers.ai>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/69422 at github.com>
================
@@ -252,11 +263,24 @@ void Symbol::GetDescription(Stream *s, lldb::DescriptionLevel level,
s->Printf(", value = 0x%16.16" PRIx64,
m_addr_range.GetBaseAddress().GetOffset());
}
- ConstString demangled = GetMangled().GetDemangledName();
- if (demangled)
- s->Printf(", name=\"%s\"", demangled.AsCString());
- if (m_mangled.GetMangledName())
- s->Printf(", mangled=\"%s\"", m_mangled.GetMangledName().AsCString());
+
----------------
DavidSpickett wrote:
This change has lost the original meaning which was to print the mangled name if we have it, then also print the demangled name if we have it.
```
Address: test.cpp.o[0x000000000000071c] (test.cpp.o.PT_LOAD[0]..text + 268)
Summary: test.cpp.o`foo(int) at test.cpp:1:17
Module: file = "/tmp/test.cpp.o", arch = "aarch64"
CompileUnit: id = {0x00000000}, file = "/tmp/test.cpp", language = "c++"
Function: id = {0x00000089}, name = "foo(int)", mangled = "_Z3fooi", range = [0x0000aaaaaaaaa71c-0x0000aaaaaaaaa730)
FuncType: id = {0x00000089}, byte-size = 0, decl = test.cpp:1:6, compiler_type = "void (int)"
Blocks: id = {0x00000089}, range = [0xaaaaaaaaa71c-0xaaaaaaaaa730)
LineEntry: [0x0000aaaaaaaaa71c-0x0000aaaaaaaaa724): /tmp/test.cpp:1:17
Symbol: id = {0x00000053}, range = [0x0000aaaaaaaaa71c-0x0000aaaaaaaaa730), name="foo(int)", mangled="_Z3fooi"
Variable: id = {0x000000a7}, name = "i", type = "int", valid ranges = <block>, location = DW_OP_fbreg -4, decl = test.cpp:1:14
```
So it would be good to add a verbose test case to your test cases to prevent this happening in future.
This is the key line:
```
Symbol: id = {0x00000053}, range = [0x0000aaaaaaaaa71c-0x0000aaaaaaaaa730), name="foo(int)", mangled="_Z3fooi"
```
You can recreate output like this using a program like:
```
void foo(int i) {}
void foo(char i) {}
int main() {
foo(1);
foo('c');
return 0;
}
```
Since name mangling is used to implement function overloading by parameter type, in the flat namespace that the linker expects to see.
https://github.com/llvm/llvm-project/pull/69422
More information about the lldb-commits
mailing list