[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 2 08:43:13 PDT 2023
================
@@ -1506,13 +1514,50 @@ static bool LookupAddressInModule(CommandInterpreter &interpreter, Stream &strm,
ExecutionContextScope *exe_scope =
interpreter.GetExecutionContext().GetBestExecutionContextScope();
- DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+ DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
return true;
}
return false;
}
+//===========================================================================================
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name, CommandInterpreter *interpreter= nullptr) {
+ if (!name) {
+ strm.PutCString(text);
+ return;
+ }
+
+ bool use_color = interpreter->GetDebugger().GetUseColor();
+
+ std::string str_text(text);
----------------
DavidSpickett wrote:
You can avoid some string copies by:
1. Passing the StringRef to this function, instead of converting it to std::string and then getting a char* from that.
2. Then using StringRef's `.begin` and `.end` in the `next` iterator. If it doesn't like the type you can build the begin/end from `.bytes_begin` and `.bytes_end` instead. Those give you char* instead.
Basically StringRef is a "view" onto a string, so as long as we know where it ends we can iterate over that instead of a new copy of it.
https://github.com/llvm/llvm-project/pull/69422
More information about the lldb-commits
mailing list