18
18
#include " lldb/Interpreter/OptionGroupValueObjectDisplay.h"
19
19
#include " lldb/Target/StackFrame.h"
20
20
#include " lldb/Utility/ConstString.h"
21
- #include " lldb/Utility/LLDBLog.h"
22
- #include " lldb/Utility/Log.h"
23
21
#include " lldb/ValueObject/ValueObject.h"
24
22
#include " lldb/lldb-defines.h"
25
23
#include " lldb/lldb-enumerations.h"
26
24
#include " lldb/lldb-forward.h"
27
25
#include " llvm/ADT/StringRef.h"
28
- #include " llvm/Support/Error.h"
29
26
30
27
#include < regex>
31
28
@@ -135,22 +132,27 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
135
132
};
136
133
137
134
// 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) {
139
136
if (is_po) {
140
137
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
+ }
143
142
llvm::StringRef output = temp_result_stream.GetString ();
144
143
maybe_add_hint (output);
145
144
result.GetOutputStream () << output;
146
145
} 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
+ }
149
152
}
150
153
m_interpreter.PrintWarningsIfNecessary (result.GetOutputStream (),
151
154
m_cmd_name);
152
155
result.SetStatus (eReturnStatusSuccessFinishResult);
153
- return Error::success ();
154
156
};
155
157
156
158
// First, try `expr` as a _limited_ frame variable expression path: only the
@@ -184,13 +186,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
184
186
expr);
185
187
}
186
188
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 ;
194
191
}
195
192
}
196
193
@@ -199,14 +196,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
199
196
if (auto *state = target.GetPersistentExpressionStateForLanguage (language))
200
197
if (auto var_sp = state->GetVariable (expr))
201
198
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 ;
210
201
}
211
202
212
203
// Third, and lastly, try `expr` as a source expression to evaluate.
@@ -257,12 +248,10 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
257
248
result.AppendNoteWithFormatv (" ran `expression {0}{1}`" , flags, expr);
258
249
}
259
250
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
264
254
result.SetStatus (eReturnStatusSuccessFinishNoResult);
265
- }
266
255
267
256
if (suppress_result)
268
257
if (auto result_var_sp =
0 commit comments