diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp --- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -71,6 +71,10 @@ 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.h b/lldb/source/Commands/CommandObjectExpression.h --- a/lldb/source/Commands/CommandObjectExpression.h +++ b/lldb/source/Commands/CommandObjectExpression.h @@ -53,7 +53,7 @@ lldb::LanguageType language; LanguageRuntimeDescriptionDisplayVerbosity m_verbosity; LazyBool auto_apply_fixits; - bool suppress_persistent_result; + LazyBool suppress_persistent_result; }; CommandObjectExpression(CommandInterpreter &interpreter); diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -151,7 +151,7 @@ bool persist_result = OptionArgParser::ToBoolean(option_arg, true, &success); if (success) - suppress_persistent_result = !persist_result; + suppress_persistent_result = !persist_result ? eLazyBoolYes : eLazyBoolNo; else error.SetErrorStringWithFormat( "could not convert \"%s\" to a boolean value.", @@ -187,7 +187,7 @@ auto_apply_fixits = eLazyBoolCalculate; top_level = false; allow_jit = true; - suppress_persistent_result = false; + suppress_persistent_result = eLazyBoolCalculate; } llvm::ArrayRef @@ -202,8 +202,9 @@ options.SetCoerceToId(display_opts.use_objc); // Explicitly disabling persistent results takes precedence over the // m_verbosity/use_objc logic. - if (suppress_persistent_result) - options.SetSuppressPersistentResult(true); + if (suppress_persistent_result != eLazyBoolCalculate) + options.SetSuppressPersistentResult(suppress_persistent_result == + eLazyBoolYes); else if (m_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact) options.SetSuppressPersistentResult(display_opts.use_objc); options.SetUnwindOnError(unwind_on_error); diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py --- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py +++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py @@ -16,8 +16,7 @@ self.ci.HandleCommand(cmd, result) return result.GetOutput().rstrip() - VAR_IDENT_RAW = r"(?:\$\d+|\w+) = " - VAR_IDENT = re.compile(VAR_IDENT_RAW) + VAR_IDENT = re.compile(r"(?:\$\d+|\w+) = ") def _mask_persistent_var(self, string: str) -> str: """ @@ -26,8 +25,7 @@ be matched against other `expression` results. """ 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) + return before + after def _expect_cmd( self, @@ -51,14 +49,13 @@ # 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)) + substrs.append(self._mask_persistent_var(expected_output)) else: substrs.append(expected_output) - self.expect(dwim_cmd, substrs=substrs, patterns=patterns) + self.expect(dwim_cmd, substrs=substrs) def test_variables(self): """Test dwim-print with variables."""