@@ -150,10 +150,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
150
150
maybe_add_hint (output);
151
151
result.GetOutputStream () << output;
152
152
} else {
153
- if (llvm::Error error =
154
- valobj.Dump (result.GetOutputStream (), dump_options))
153
+ llvm::Error error =
154
+ valobj.Dump (result.GetOutputStream (), dump_options);
155
+ if (error) {
155
156
result.AppendError (toString (std::move (error)));
157
+ return ;
158
+ }
156
159
}
160
+ result.SetStatus (eReturnStatusSuccessFinishResult);
157
161
};
158
162
159
163
// First, try `expr` as the name of a frame variable.
@@ -174,7 +178,6 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
174
178
}
175
179
176
180
dump_val_object (*valobj_sp);
177
- result.SetStatus (eReturnStatusSuccessFinishResult);
178
181
return ;
179
182
}
180
183
}
@@ -222,7 +225,6 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
222
225
if (auto var_sp = state->GetVariable (expr))
223
226
if (auto valobj_sp = var_sp->GetValueObject ()) {
224
227
dump_val_object (*valobj_sp);
225
- result.SetStatus (eReturnStatusSuccessFinishResult);
226
228
return ;
227
229
}
228
230
@@ -243,34 +245,36 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
243
245
error_stream << " " << fixed_expression << " \n " ;
244
246
}
245
247
246
- if (expr_result == eExpressionCompleted) {
247
- if (verbosity != eDWIMPrintVerbosityNone) {
248
- StringRef flags;
249
- if (args.HasArgs ())
250
- flags = args.GetArgStringWithDelimiter ();
251
- result.AppendMessageWithFormatv (" note: ran `expression {0}{1}`" , flags,
252
- expr);
253
- }
254
-
255
- if (valobj_sp->GetError ().GetError () != UserExpression::kNoResult )
256
- dump_val_object (*valobj_sp);
257
-
258
- if (suppress_result)
259
- if (auto result_var_sp =
260
- target.GetPersistentVariable (valobj_sp->GetName ())) {
261
- auto language = valobj_sp->GetPreferredDisplayLanguage ();
262
- if (auto *persistent_state =
263
- target.GetPersistentExpressionStateForLanguage (language))
264
- persistent_state->RemovePersistentVariable (result_var_sp);
265
- }
266
-
267
- result.SetStatus (eReturnStatusSuccessFinishResult);
268
- } else {
248
+ // If the expression failed, return an error.
249
+ if (expr_result != eExpressionCompleted) {
269
250
if (valobj_sp)
270
251
result.SetError (valobj_sp->GetError ());
271
252
else
272
253
result.AppendErrorWithFormatv (
273
254
" unknown error evaluating expression `{0}`" , expr);
255
+ return ;
256
+ }
257
+
258
+ if (verbosity != eDWIMPrintVerbosityNone) {
259
+ StringRef flags;
260
+ if (args.HasArgs ())
261
+ flags = args.GetArgStringWithDelimiter ();
262
+ result.AppendMessageWithFormatv (" note: ran `expression {0}{1}`" , flags,
263
+ expr);
274
264
}
265
+
266
+ if (valobj_sp->GetError ().GetError () != UserExpression::kNoResult )
267
+ dump_val_object (*valobj_sp);
268
+ else
269
+ result.SetStatus (eReturnStatusSuccessFinishResult);
270
+
271
+ if (suppress_result)
272
+ if (auto result_var_sp =
273
+ target.GetPersistentVariable (valobj_sp->GetName ())) {
274
+ auto language = valobj_sp->GetPreferredDisplayLanguage ();
275
+ if (auto *persistent_state =
276
+ target.GetPersistentExpressionStateForLanguage (language))
277
+ persistent_state->RemovePersistentVariable (result_var_sp);
278
+ }
275
279
}
276
280
}
0 commit comments