[Lldb-commits] [PATCH] D68010: [lldb] Fix string summary of an empty NSPathStore2

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 25 01:02:14 PDT 2019


teemperor created this revision.
teemperor added reviewers: aprantl, JDevlieghere, shafik.
Herald added subscribers: lldb-commits, abidh, christof.
Herald added a project: LLDB.

Printing a summary for an empty NSPathStore2 string currently prints random bytes behind the empty string pointer from memory (rdar://55575888).

It seems the reason for this is that the SourceSize parameter in the `ReadStringAndDumpToStreamOptions` - which is supposed to contain the string
length - actually uses the length 0 as a magic value for saying "read as much as possible from the buffer" which is clearly wrong for empty strings.

This patch adds another flag that indicates if we have know the string length or not and makes this behaviour dependent on that (which seemingly
was the original purpose of this magic value). As this code is shared between all string reading, this patch also adds tests for printing empty strings
to all string type tests that seem to use this code path.

Note that I'm aware that some of the surrounding code that I touch here is spaghetti which should be refactored. However, I would prefer if we could
backport this patch without also having to backport a series of refactoring patches, so let's just add sauce to that pasta for now and I'll do the refactoring
once this has landed.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68010

Files:
  lldb/include/lldb/DataFormatters/StringPrinter.h
  lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
  lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
  lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
  lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
  lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py
  lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp
  lldb/source/DataFormatters/StringPrinter.cpp
  lldb/source/Plugins/Language/ObjC/NSString.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68010.221684.patch
Type: text/x-patch
Size: 17899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190925/4957e625/attachment-0001.bin>


More information about the lldb-commits mailing list