[all-commits] [llvm/llvm-project] 939ca4: [lldb] Fix string summary of an empty NSPathStore2

Raphael Isemann via All-commits all-commits at lists.llvm.org
Thu Mar 19 04:20:58 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 939ca455e72e822450013eff37c9ea7746850350
      https://github.com/llvm/llvm-project/commit/939ca455e72e822450013eff37c9ea7746850350
  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/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:
  -----------
  [lldb] Fix string summary of an empty NSPathStore2

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