Skip to content

Commit 3c969d6

Browse files
committed
Add setting gating the new po, initially disabled by default
1 parent 9cd7c44 commit 3c969d6

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ class TargetProperties : public Properties {
215215

216216
bool GetSwiftAutoImportFrameworks() const;
217217

218+
bool GetSwiftUseNewPrintObject() const;
219+
218220
bool GetEnableAutoImportClangModules() const;
219221

220222
bool GetUseAllCompilerFlags() const;

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,9 @@ llvm::Error SwiftLanguageRuntime::GetObjectDescription(Stream &str,
10941094
if (object.IsUninitializedReference())
10951095
return llvm::createStringError("<uninitialized>");
10961096

1097-
if (printObjectViaPointer(str, object, GetProcess()))
1098-
return llvm::Error::success();
1097+
if (GetProcess().GetTarget().GetSwiftUseNewPrintObject())
1098+
if (printObjectViaPointer(str, object, GetProcess()))
1099+
return llvm::Error::success();
10991100

11001101
std::string expr_string;
11011102

lldb/source/Target/Target.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4705,6 +4705,18 @@ bool TargetProperties::GetSwiftAutoImportFrameworks() const {
47054705
idx, g_target_properties[idx].default_uint_value != 0);
47064706
}
47074707

4708+
bool TargetProperties::GetSwiftUseNewPrintObject() const {
4709+
const Property *exp_property =
4710+
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
4711+
OptionValueProperties *exp_values =
4712+
exp_property->GetValue()->GetAsProperties();
4713+
if (exp_values)
4714+
return exp_values
4715+
->GetPropertyAtIndexAs<bool>(ePropertySwiftUseNewPrintObject)
4716+
.value_or(false);
4717+
return false;
4718+
}
4719+
47084720
void TargetProperties::SetUseDIL(ExecutionContext *exe_ctx, bool b) {
47094721
const Property *exp_property =
47104722
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx);

lldb/source/Target/TargetProperties.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ let Definition = "target_experimental" in {
3737
def SwiftCacheTaskPointerLocation: Property<"swift-cache-task-pointer-location", "Boolean">,
3838
DefaultTrue,
3939
Desc<"Enables caching of task pointers inside the swift tasks plugin">;
40+
def SwiftUseNewPrintObject: Property<"swift-use-new-po", "Boolean">,
41+
DefaultFalse,
42+
Desc<"If true, use the new Swift po implementation.">;
4043
def UseDIL : Property<"use-DIL", "Boolean">,
4144
Global, DefaultTrue,
4245
Desc<"If true, use the DIL implementation for frame variable evaluation.">;

lldb/test/API/lang/swift/expression/error_reporting/TestSwiftExpressionErrorReporting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def test_missing_type(self):
6868
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
6969
self, 'break here', lldb.SBFileSpec('main.swift'))
7070

71+
self.runCmd("settings set target.experimental.swift-use-new-po true")
72+
7173
options = lldb.SBExpressionOptions()
7274
value = self.frame().EvaluateExpression("strct", options)
7375
def check(value):
@@ -84,7 +86,6 @@ def check(value):
8486
# This succeeds using stringForPrintObject(_:mangledTypeName:), which
8587
# doesn't require the type to be available.
8688
# Note: (?s)^(?!.*<pattern>) checks that the pattern is not found.
87-
# self.runCmd("log enable lldb formatters")
8889
self.expect(
8990
"dwim-print -O -- strct",
9091
patterns=["(?s)^(?!.*error: Missing type)", "properties : true"],
@@ -93,4 +94,3 @@ def check(value):
9394
process.Continue()
9495
self.expect('expression -O -- number', error=True,
9596
substrs=['self', 'not', 'found'])
96-

0 commit comments

Comments
 (0)