[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());
+
+  // 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());
----------------
DavidSpickett wrote:

If you need it, Stringstream is the thing to look for I think.

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


More information about the lldb-commits mailing list