[Lldb-commits] [lldb] [lldb] Add support for updating string during debug process (PR #67782)

Pavel Kosov via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 5 01:00:28 PDT 2023


kpdev wrote:

> What is it about this change that is defeating the ValueObject printer from compressing this output onto one line? It looks like the contents that get printed are the same, so there's something about switching from a Summary provider to a child provider that's causing problems. We should fix that as people are really picky about variable printing being as space efficient as possible.

> To clear up terminology... Strings had data formatters before AND after this change. The difference is that you've switched from a "Summary Provider" data formatter to a "Synthetic Child Provider" data formatter.
> 
> It looks like you've made the printing of std::strings less space efficient. That shouldn't be necessary, and isn't desirable. We should figure out why that's happening and fix that before this change is going to not cause complaints.

As there is mentioned in a comment for `FormatManager::ShouldPrintAsOneLiner` ( https://github.com/llvm/llvm-project/blob/main/lldb/source/DataFormatters/FormatManager.cpp#L498 ):

```
    // if we decided to define synthetic children for a type, we probably care
    // enough to show them, but avoid nesting children in children
```

So, there is a condition for that:

```
      // but if we only have them to provide a value, keep going
      if (!synth_sp->MightHaveChildren() &&
          synth_sp->DoesProvideSyntheticValue())
        is_synth_val = true;
      else
        return false;
```

This patch adds StringSynthetic and this synthetic `MightHaveChildren()` is `true`, therefore `ShouldPrintAsOneLiner` returns `false`. And the printer will use `"()"` or `"{\n ... \n}"` according to whether we return `true` or `false` from this function. If we would like to avoid unnecessary output we probably may ask SyntheticFrontend directly if it would like to print expanded info or not, what do you think about it?

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


More information about the lldb-commits mailing list