Skip to content

Commit 2c7d10c

Browse files
committed
[lldb] Set result error state in 'frame variable'
Ensure that errors in `frame variable` are reflected in result object. The statistics for `frame variable` show invocations as being successful, even when executing one of the error paths. This change replaces `result.GetErrorStream()` with `result.AppendError()`, which also sets the status to `eReturnStatusFailed`. Differential Revision: https://reviews.llvm.org/D116788
1 parent 6ee589e commit 2c7d10c

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

lldb/source/Commands/CommandObjectFrame.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -558,18 +558,16 @@ may even involve JITing and running code in the target program.)");
558558
}
559559
}
560560
} else if (num_matches == 0) {
561-
result.GetErrorStream().Printf("error: no variables matched "
562-
"the regular expression '%s'.\n",
563-
entry.c_str());
561+
result.AppendErrorWithFormat(
562+
"no variables matched the regular expression '%s'.",
563+
entry.c_str());
564564
}
565565
} else {
566566
if (llvm::Error err = regex.GetError())
567-
result.GetErrorStream().Printf(
568-
"error: %s\n", llvm::toString(std::move(err)).c_str());
567+
result.AppendError(llvm::toString(std::move(err)));
569568
else
570-
result.GetErrorStream().Printf(
571-
"error: unknown regex error when compiling '%s'\n",
572-
entry.c_str());
569+
result.AppendErrorWithFormat(
570+
"unknown regex error when compiling '%s'", entry.c_str());
573571
}
574572
} else // No regex, either exact variable names or variable
575573
// expressions.
@@ -605,14 +603,13 @@ may even involve JITing and running code in the target program.)");
605603
valobj_sp->GetParent() ? entry.c_str() : nullptr);
606604
valobj_sp->Dump(output_stream, options);
607605
} else {
608-
const char *error_cstr = error.AsCString(nullptr);
609-
if (error_cstr)
610-
result.GetErrorStream().Printf("error: %s\n", error_cstr);
606+
if (auto error_cstr = error.AsCString(nullptr))
607+
result.AppendError(error_cstr);
611608
else
612-
result.GetErrorStream().Printf("error: unable to find any "
613-
"variable expression path that "
614-
"matches '%s'.\n",
615-
entry.c_str());
609+
result.AppendErrorWithFormat(
610+
"unable to find any variable expression path that matches "
611+
"'%s'.",
612+
entry.c_str());
616613
}
617614
}
618615
}
@@ -680,7 +677,8 @@ may even involve JITing and running code in the target program.)");
680677
}
681678
}
682679
}
683-
result.SetStatus(eReturnStatusSuccessFinishResult);
680+
if (result.GetStatus() != eReturnStatusFailed)
681+
result.SetStatus(eReturnStatusSuccessFinishResult);
684682
}
685683

686684
if (m_option_variable.show_recognized_args) {

0 commit comments

Comments
 (0)