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

José Lira Junior via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 7 06:40:17 PST 2023


junior-jl wrote:

In the last commit:

- Added the conditions `prefix.empty()` and `suffix.empty()` to the 'no color' path.
- Added missing arguments to `PutCStringColorHighlighted` call in `SymbolContext` (line 177).

I had to copy the same statements from line 99 here. Is it better if I declared `llvm::StringRef ansi_prefix` and `llvm::StringRef ansi_suffix` outside the conditions even if they are not used?

```cpp
      llvm::StringRef ansi_prefix;
      llvm::StringRef ansi_suffix;
      if (target_sp) {
        ansi_prefix = target_sp->GetDebugger().GetRegexMatchAnsiPrefix();
        ansi_suffix = target_sp->GetDebugger().GetRegexMatchAnsiSuffix();
      }
      s->PutCStringColorHighlighted(symbol->GetName().GetStringRef(), pattern,
                                    ansi_prefix, ansi_suffix);
```

Also, since these changes were approved, we opted to finalize this PR like it is now. Since we are creating another PR to do the same thing for function search, we are planning on refactoring this with an optional struct and `llvm::Regex` type as suggested. This change would also make this `if (pattern.empty() || prefix.empty() || suffix.empty())` prettier, I guess. Is that good?

I would also like to understand better the relation between SymbolContext and the target (or another way of getting Debugger properties).

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


More information about the lldb-commits mailing list