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

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 23 07:31:29 PDT 2023


================
@@ -642,7 +680,11 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
                 if (pointer_sc.function != nullptr ||
                     pointer_sc.symbol != nullptr) {
                   s->PutCString(": ");
-                  pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
+                  if(name)
+                    pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
+                                             false, true, true, name);
+                  else
+                    pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
----------------
DavidSpickett wrote:

Here you can simplify this a lot.

If `if (name)` is true, then `name` is not nullptr. So:
```
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
                                             false, true, true, name);
```
Is fine. Ok so far.

In the `else`, `name` must be `nullptr`. `DumpStopContext`'s name parameter defaults to `nullptr` anyway, so by passing it here too, you wouldn't create any problems.

So the final code could be:



                  if(name)
                    pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
                                             false, true, true, name);
                  else
                    pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
 

Here you can simplify this a lot.

If `if (name)` is true, then `name` is not nullptr. So:
```
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
                                             false, true, true, name);
```
Is fine. Ok so far.

In the `else`, `name` must be `nullptr`. `DumpStopContext`'s name parameter defaults to `nullptr` anyway, so by passing it here too, you wouldn't create any problems.

So the final code could be:
```
                    pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
                                             false, true, true, name);
```
If name is nullptr, we pass a nullptr, if it isn't, we pass it on. `DumpStopContext` is happy with either.

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


More information about the lldb-commits mailing list