[Lldb-commits] [lldb] [lldb] Trim and show embedded zeros in `charN_t` arrays (PR #195514)
via lldb-commits
lldb-commits at lists.llvm.org
Wed May 6 04:05:38 PDT 2026
================
@@ -479,9 +494,10 @@ static bool ReadEncodedBufferAndDumpToStream(
target_sp->GetArchitecture().GetAddressByteSize()));
dump_options.SetSourceSize(sourceSize);
dump_options.SetIsTruncated(is_truncated);
- dump_options.SetNeedsZeroTermination(needs_zero_terminator);
- if (needs_zero_terminator)
- dump_options.SetBinaryZeroIsTerminator(true);
+ if (needs_zero_terminator) {
+ dump_options.SetZeroTermination(
+ StringPrinter::ZeroTermination::ZeroTerminate);
+ }
----------------
Nerixyz wrote:
`needs_zero_terminator` gets updated in the function if `elem_type == StringElementType::ASCII && !options.GetSourceSize()` or `!options.HasSourceSize()`.
There's a comment I forgot to update:
```cpp
// FIXME: The NSString formatter sets HasSourceSize(true) when the size is
// actually unknown, as well as SetZeroTermination(Ignore). IIUC the
// C++ formatter also sets SetZeroTermination(Ignore) when it doesn't
// mean to. I don't see how this makes sense: we should fix the formatters.
//
// Until then, the behavior that's expected for ASCII strings with unknown
// lengths is to read up to the max size and then null-terminate. Do that.
```
I'm not sure if that's still true. At least the C++ formatters don't use this path (anymore?). `NSSting` only sets `HasSourceSize(true)` if it actually has a size.
So maybe we could remove that branch?
https://github.com/llvm/llvm-project/pull/195514
More information about the lldb-commits
mailing list