[all-commits] [llvm/llvm-project] 7b2442: Reland [lldb] Fix string summary of an empty NSPat...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Thu Mar 19 10:50:55 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 7b2442584e40f97693c38c0d79b83f770d557039
      https://github.com/llvm/llvm-project/commit/7b2442584e40f97693c38c0d79b83f770d557039
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2020-03-19 (Thu, 19 Mar 2020)

  Changed paths:
    M lldb/include/lldb/DataFormatters/StringPrinter.h
    M lldb/source/DataFormatters/StringPrinter.cpp
    M lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
    M lldb/source/Plugins/Language/ObjC/NSString.cpp
    M lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/TestDataFormatterNSString.py
    M lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m

  Log Message:
  -----------
  Reland [lldb] Fix string summary of an empty NSPathStore2

(This is D68010 but I also set the new parameter in LibStdcpp.cpp to fix
the Debian tests).

Summary:
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).

Reviewers: aprantl, JDevlieghere, shafik

Reviewed By: aprantl

Subscribers: christof, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68010




More information about the All-commits mailing list