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

via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 30 04:20:03 PDT 2023


taalhaataahir0102 wrote:

Hi David! I've done the following:
1. Used regex search in the `printRed` format function instead of sub string search.
2. Used ANSI function which you mentioned above https://github.com/llvm/llvm-project/blob/cbbb545c4618969850d88bb008ab7f1c2918d5c3/lldb/include/lldb/Utility/AnsiTerminal.h#L83
3. In the above function, to cater with the bool variable, which takes weather the Use-Color settings are switched on or not, I've passed the CommandInterpreter object to the `PrintRed` function (as it was available to me in the dump functon) and fetching the Use-colors settings option (true or false) through it using:
`interpreter->GetDebugger().GetUseColor()`
And passing this bool to the ANSI function.
4.  Updated the Test-cases by writing a few more test cases which covers some commonly used regex symbols for searching. Now all previous test cases are working fine including `tests/Shell/Commands/command-target-modules-lookup` and in my test cases, I've passed the `use-color = true` option in run commands:
`# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s ma' | FileCheck %s --check-prefix CHECK1`
Next:
Will figure out a way to remove duplicate PriintRed functions in different files.

Can you please confirm if passing the pointer to `CommandInterpreter` object in `PrintRed` function to get the use-color options a good idea? Are the test cases good enough and also does the future plan sounds Okay?

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


More information about the lldb-commits mailing list