[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

José Lira Junior via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 13 09:53:18 PST 2023


================
@@ -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());
+
+  // Checking if the name (i.e., searched symbol is passed as an argument to the
+  // function) In that case, we use the DumpName function to colorize the
+  // symbol.
+  if (auto mangled_name = m_mangled.GetMangledName()) {
+    s->Printf(", mangled=");
+    if (name)
+      Address::DumpName(s, mangled_name.GetStringRef(), name);
+    else
+      s->Printf("\"%s\"", mangled_name.AsCString());
+  } else {
+    ConstString demangled = GetMangled().GetDemangledName();
+    s->Printf(", name=");
+    if (name)
+      Address::DumpName(s, demangled.AsCString(), name);
+    else
+      s->Printf("\"%s\"", demangled.AsCString());
----------------
junior-jl wrote:

Corrected this as well. Also, since the beginning of `DumpName` has the following condition, I removed the redundant `if`:

```cpp
if (!pattern) {
    strm->PutCString(text.data());
    return;
  }
```

https://github.com/llvm/llvm-project/pull/69422


More information about the lldb-commits mailing list