1818#include " lldb/Interpreter/OptionGroupValueObjectDisplay.h"
1919#include " lldb/Target/StackFrame.h"
2020#include " lldb/Utility/ConstString.h"
21- #include " lldb/Utility/LLDBLog.h"
22- #include " lldb/Utility/Log.h"
2321#include " lldb/ValueObject/ValueObject.h"
2422#include " lldb/lldb-defines.h"
2523#include " lldb/lldb-enumerations.h"
2624#include " lldb/lldb-forward.h"
2725#include " llvm/ADT/StringRef.h"
28- #include " llvm/Support/Error.h"
2926
3027#include < regex>
3128
@@ -135,22 +132,27 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
135132 };
136133
137134 // Dump `valobj` according to whether `po` was requested or not.
138- auto dump_val_object = [&](ValueObject &valobj) -> Error {
135+ auto dump_val_object = [&](ValueObject &valobj) {
139136 if (is_po) {
140137 StreamString temp_result_stream;
141- if (Error err = valobj.Dump (temp_result_stream, dump_options))
142- return err;
138+ if (llvm::Error error = valobj.Dump (temp_result_stream, dump_options)) {
139+ result.AppendError (toString (std::move (error)));
140+ return ;
141+ }
143142 llvm::StringRef output = temp_result_stream.GetString ();
144143 maybe_add_hint (output);
145144 result.GetOutputStream () << output;
146145 } else {
147- if (Error err = valobj.Dump (result.GetOutputStream (), dump_options))
148- return err;
146+ llvm::Error error =
147+ valobj.Dump (result.GetOutputStream (), dump_options);
148+ if (error) {
149+ result.AppendError (toString (std::move (error)));
150+ return ;
151+ }
149152 }
150153 m_interpreter.PrintWarningsIfNecessary (result.GetOutputStream (),
151154 m_cmd_name);
152155 result.SetStatus (eReturnStatusSuccessFinishResult);
153- return Error::success ();
154156 };
155157
156158 // First, try `expr` as a _limited_ frame variable expression path: only the
@@ -184,13 +186,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
184186 expr);
185187 }
186188
187- Error err = dump_val_object (*valobj_sp);
188- if (!err)
189- return ;
190-
191- // Dump failed, continue on to expression evaluation.
192- LLDB_LOG_ERROR (GetLog (LLDBLog::Expressions), std::move (err),
193- " could not print frame variable '{1}': {0}" , expr);
189+ dump_val_object (*valobj_sp);
190+ return ;
194191 }
195192 }
196193
@@ -199,14 +196,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
199196 if (auto *state = target.GetPersistentExpressionStateForLanguage (language))
200197 if (auto var_sp = state->GetVariable (expr))
201198 if (auto valobj_sp = var_sp->GetValueObject ()) {
202- Error err = dump_val_object (*valobj_sp);
203- if (!err)
204- return ;
205-
206- // Dump failed, continue on to expression evaluation.
207- LLDB_LOG_ERROR (GetLog (LLDBLog::Expressions), std::move (err),
208- " could not print persistent variable '{1}': {0}" ,
209- expr);
199+ dump_val_object (*valobj_sp);
200+ return ;
210201 }
211202
212203 // Third, and lastly, try `expr` as a source expression to evaluate.
@@ -257,12 +248,10 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
257248 result.AppendNoteWithFormatv (" ran `expression {0}{1}`" , flags, expr);
258249 }
259250
260- if (valobj_sp->GetError ().GetError () != UserExpression::kNoResult ) {
261- if (Error err = dump_val_object (*valobj_sp))
262- result.SetError (std::move (err));
263- } else {
251+ if (valobj_sp->GetError ().GetError () != UserExpression::kNoResult )
252+ dump_val_object (*valobj_sp);
253+ else
264254 result.SetStatus (eReturnStatusSuccessFinishNoResult);
265- }
266255
267256 if (suppress_result)
268257 if (auto result_var_sp =
0 commit comments