aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Lee <davelee.com@gmail.com>2023-03-15 13:59:46 -0700
committerDave Lee <davelee.com@gmail.com>2023-03-15 14:00:00 -0700
commit9e6a65f52ca6263795d81bde220fb4c80b7b05ec (patch)
tree1ba60e68af8d9771e776b22c0271d1fad85d93f1
parent484c622760e2a46aa1b52c7a791ee59543364225 (diff)
downloadllvm-9e6a65f52ca6263795d81bde220fb4c80b7b05ec.zip
llvm-9e6a65f52ca6263795d81bde220fb4c80b7b05ec.tar.gz
llvm-9e6a65f52ca6263795d81bde220fb4c80b7b05ec.tar.bz2
Revert "[lldb] Change dwim-print to default to disabled persistent results"
This reverts commit 8bad4ae679df6fc7dbd016dccbd3da34206e836b.
-rw-r--r--lldb/source/Commands/CommandObjectDWIMPrint.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp9
-rw-r--r--lldb/source/Commands/CommandObjectExpression.h2
-rw-r--r--lldb/test/API/commands/dwim-print/TestDWIMPrint.py31
4 files changed, 23 insertions, 23 deletions
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 419a27a..d8bc7a1 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -71,10 +71,6 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
return false;
}
- // If the user has not specified, default to disabling persistent results.
- if (m_expr_options.suppress_persistent_result == eLazyBoolCalculate)
- m_expr_options.suppress_persistent_result = eLazyBoolYes;
-
auto verbosity = GetDebugger().GetDWIMPrintVerbosity();
Target *target_ptr = m_exe_ctx.GetTargetPtr();
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index 2658677..63b9236 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -151,7 +151,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue(
bool persist_result =
OptionArgParser::ToBoolean(option_arg, true, &success);
if (success)
- suppress_persistent_result = !persist_result ? eLazyBoolYes : eLazyBoolNo;
+ suppress_persistent_result = !persist_result;
else
error.SetErrorStringWithFormat(
"could not convert \"%s\" to a boolean value.",
@@ -187,7 +187,7 @@ void CommandObjectExpression::CommandOptions::OptionParsingStarting(
auto_apply_fixits = eLazyBoolCalculate;
top_level = false;
allow_jit = true;
- suppress_persistent_result = eLazyBoolCalculate;
+ suppress_persistent_result = false;
}
llvm::ArrayRef<OptionDefinition>
@@ -202,9 +202,8 @@ CommandObjectExpression::CommandOptions::GetEvaluateExpressionOptions(
options.SetCoerceToId(display_opts.use_objc);
// Explicitly disabling persistent results takes precedence over the
// m_verbosity/use_objc logic.
- if (suppress_persistent_result != eLazyBoolCalculate)
- options.SetSuppressPersistentResult(suppress_persistent_result ==
- eLazyBoolYes);
+ if (suppress_persistent_result)
+ options.SetSuppressPersistentResult(true);
else if (m_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact)
options.SetSuppressPersistentResult(display_opts.use_objc);
options.SetUnwindOnError(unwind_on_error);
diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h
index d6a4bb1..e381a4a 100644
--- a/lldb/source/Commands/CommandObjectExpression.h
+++ b/lldb/source/Commands/CommandObjectExpression.h
@@ -53,7 +53,7 @@ public:
lldb::LanguageType language;
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity;
LazyBool auto_apply_fixits;
- LazyBool suppress_persistent_result;
+ bool suppress_persistent_result;
};
CommandObjectExpression(CommandInterpreter &interpreter);
diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index 22d18f9..705e2ef 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -16,16 +16,18 @@ class TestCase(TestBase):
self.ci.HandleCommand(cmd, result)
return result.GetOutput().rstrip()
- VAR_IDENT = re.compile(r"(?:\$\d+|\w+) = ")
+ VAR_IDENT_RAW = r"(?:\$\d+|\w+) = "
+ VAR_IDENT = re.compile(VAR_IDENT_RAW)
- def _strip_result_var(self, string: str) -> str:
+ def _mask_persistent_var(self, string: str) -> str:
"""
- Strip (persistent) result variables (ex '$0 = ', or 'someVar = ', etc).
-
- This allows for using the output of `expression`/`frame variable`, to
- compare it to `dwim-print` output, which disables result variables.
+ Replace persistent result variables (ex '$0', '$1', etc) with a regex
+ that matches any persistent result (r'\$\d+'). The returned string can
+ be matched against other `expression` results.
"""
- return self.VAR_IDENT.subn("", string, 1)[0]
+ before, after = self.VAR_IDENT.split(string, maxsplit=1)
+ # Support either a frame variable (\w+) or a persistent result (\$\d+).
+ return re.escape(before) + self.VAR_IDENT_RAW + re.escape(after)
def _expect_cmd(
self,
@@ -44,16 +46,19 @@ class TestCase(TestBase):
if actual_cmd == "frame variable":
resolved_cmd = resolved_cmd.replace(" -- ", " ", 1)
- resolved_cmd_output = self._run_cmd(resolved_cmd)
- dwim_cmd_output = self._strip_result_var(resolved_cmd_output)
+ expected_output = self._run_cmd(resolved_cmd)
# Verify dwim-print chose the expected command.
self.runCmd("settings set dwim-print-verbosity full")
+ substrs = [f"note: ran `{resolved_cmd}`"]
+ patterns = []
+
+ if self.VAR_IDENT.search(expected_output):
+ patterns.append(self._mask_persistent_var(expected_output))
+ else:
+ substrs.append(expected_output)
- self.expect(dwim_cmd, substrs=[
- f"note: ran `{resolved_cmd}`",
- dwim_cmd_output,
- ])
+ self.expect(dwim_cmd, substrs=substrs, patterns=patterns)
def test_variables(self):
"""Test dwim-print with variables."""