[Lldb-commits] [lldb] [lldb] Expose structured command diagnostics via the SBAPI. (PR #112109)
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 14 10:02:48 PDT 2024
================
@@ -485,35 +485,8 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
- // Retrieve the diagnostics.
- std::vector<DiagnosticDetail> details;
- llvm::consumeError(llvm::handleErrors(
- result_valobj_sp->GetError().ToError(),
- [&](DiagnosticError &error) { details = error.GetDetails(); }));
- // Find the position of the expression in the command.
- std::optional<uint16_t> expr_pos;
- size_t nchar = m_original_command.find(expr);
- if (nchar != std::string::npos)
- expr_pos = nchar + GetDebugger().GetPrompt().size();
-
- if (!details.empty()) {
- bool show_inline =
- GetDebugger().GetShowInlineDiagnostics() && !expr.contains('\n');
- RenderDiagnosticDetails(error_stream, expr_pos, show_inline, details);
- } else {
- const char *error_cstr = result_valobj_sp->GetError().AsCString();
- llvm::StringRef error(error_cstr);
- if (!error.empty()) {
- if (!error.starts_with("error:"))
- error_stream << "error: ";
- error_stream << error;
- if (!error.ends_with('\n'))
- error_stream.EOL();
- } else {
- error_stream << "error: unknown error\n";
- }
- }
result.SetStatus(eReturnStatusFailed);
+ result.SetError(result_valobj_sp->GetError().ToError());
----------------
medismailben wrote:
Nice!
https://github.com/llvm/llvm-project/pull/112109
More information about the lldb-commits
mailing list