[Lldb-commits] [lldb] [lldb] colorize symbols in image lookup (PR #69422)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 29 05:27:21 PST 2023


=?utf-8?q?José?= L. Junior <josejunior at 10xengineers.ai>,taalhaataahir0102
 <23100293 at lums.edu.pk>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/69422 at github.com>


================
@@ -1618,12 +1621,15 @@ static uint32_t LookupSymbolInModule(CommandInterpreter &interpreter,
         if (symbol->ValueIsAddress()) {
           DumpAddress(
               interpreter.GetExecutionContext().GetBestExecutionContextScope(),
-              symbol->GetAddressRef(), verbose, all_ranges, strm);
+              symbol->GetAddressRef(), verbose, all_ranges, strm,
+              use_color ? name : nullptr);
----------------
DavidSpickett wrote:

Yeah, I'm not 100% it should be regex only but my logic was that non-regex search looks for identical names, so the highlighting doesn't help you understand the result any more than the plain text does:
```
(lldb) image lookup -s ma
(lldb) image lookup -s main
1 symbols match 'main' in /tmp/test.o:
        Address: test.o[0x000000000000074c] (test.o.PT_LOAD[0]..text + 316)
        Summary: test.o`main
```
The name will only ever show up if it matched exactly.

Only when you've got something that could match in different ways does the colour help me:
```
(lldb) image lookup -s ma --regex
3 symbols match the regular expression 'ma' in /tmp/test.o:
        Name: __libc_start_main@@GLIBC_2.17
        Value: 0x0000000000000000
        Address: test.o[0x000000000000074c] (test.o.PT_LOAD[0]..text + 316)
        Summary: test.o`main
        Address: test.o[0x00000000000005e0] (test.o.PT_LOAD[0]..plt + 48)
        Summary: test.o`symbol stub for: __libc_start_main
<...>
```
Because it tells me what it matched.

But I am bringing my bias in here, I understand what all the lines of output mean. Maybe if I didn't, I would appreciate knowing where my search term shows up?

On the other hand, highlighting the same thing 99 times might just be noise on top of an already large amount of output. So I'm being 1. biased and 2. conservative.

Perhaps you would find the highlighting useful in both modes, if so we can keep it.

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


More information about the lldb-commits mailing list