[all-commits] [llvm/llvm-project] a37cae: [lldb/DataFormatters] Delete GetStringPrinterEscap...

Vedant Kumar via All-commits all-commits at lists.llvm.org
Mon May 4 14:07:25 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a37caebc2d2d93573075633493e104e8664cf9e9
      https://github.com/llvm/llvm-project/commit/a37caebc2d2d93573075633493e104e8664cf9e9
  Author: Vedant Kumar <vsk at apple.com>
  Date:   2020-05-04 (Mon, 04 May 2020)

  Changed paths:
    M lldb/include/lldb/DataFormatters/StringPrinter.h
    M lldb/include/lldb/Target/Language.h
    M lldb/source/DataFormatters/StringPrinter.cpp
    M lldb/source/Plugins/Language/ObjC/NSString.cpp
    M lldb/source/Target/Language.cpp
    M lldb/unittests/DataFormatter/CMakeLists.txt
    A lldb/unittests/DataFormatter/StringPrinterTests.cpp

  Log Message:
  -----------
  [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

Summary:
Languages can have different ways of formatting special characters.
E.g. when debugging C++ code a string might look like "\b", but when
debugging Swift code the same string would look like "\u{8}".

To make this work, plugins override GetStringPrinterEscapingHelper.
However, because there's a large amount of subtly divergent work done in
each override, we end up with large amounts of duplicated code. And all
the memory smashers fixed in one copy of the logic (see D73860) don't
get fixed in the others.

IMO the GetStringPrinterEscapingHelper is overly general and hard to
use. I propose deleting it and replacing it with an EscapeStyle enum,
which can be set as needed by each plugin.

A fix for some swift-lldb memory smashers falls out fairly naturally
from this deletion (https://github.com/apple/llvm-project/pull/1046). As
the swift logic becomes really tiny, I propose moving it upstream as
part of this change. I've added unit tests to cover it.

rdar://61419673

Reviewers: JDevlieghere, davide

Subscribers: mgorny, lldb-commits

Tags: #lldb

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




More information about the All-commits mailing list