Skip to content

Commit e8d31af

Browse files
committed
[lldb] Migrate condition evaluation failure to ReportError
Migrate to using ReportError to report a failure to evaluate a watchpoint condition. I had already done so for the parallel code for breakpoints. In the process, I noticed that I accidentally regressed the error reporting for breakpoint conditions by dropping the call to GetDescription. This patch rectifies that and adds a test. Because the call to GetDescription expects a Stream*, I also switches from using a raw_string_ostream to a StreamString for both breakpoints and watchpoints. (cherry picked from commit d10c0c7)
1 parent dac1e77 commit e8d31af

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

lldb/source/Target/StopInfo.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -452,19 +452,18 @@ class StopInfoBreakpoint : public StopInfo {
452452

453453
if (!condition_error.Success()) {
454454
const char *err_str =
455-
condition_error.AsCString("<Unknown Error>");
455+
condition_error.AsCString("<unknown error>");
456456
LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
457457

458-
std::string error_message;
459-
llvm::raw_string_ostream os(error_message);
460-
os << "stopped due to an error evaluating condition of "
461-
"breakpoint "
462-
<< bp_loc_sp->GetConditionText() << '\n';
463-
os << err_str;
464-
os.flush();
458+
StreamString strm;
459+
strm << "stopped due to an error evaluating condition of "
460+
"breakpoint ";
461+
bp_loc_sp->GetDescription(&strm, eDescriptionLevelBrief);
462+
strm << ": \"" << bp_loc_sp->GetConditionText() << "\"\n";
463+
strm << err_str;
465464

466465
Debugger::ReportError(
467-
std::move(error_message),
466+
strm.GetString().str(),
468467
exe_ctx.GetTargetRef().GetDebugger().GetID());
469468
} else {
470469
LLDB_LOGF(log,
@@ -861,20 +860,18 @@ class StopInfoWatchpoint : public StopInfo {
861860
}
862861
}
863862
} else {
864-
StreamSP error_sp = debugger.GetAsyncErrorStream();
865-
error_sp->Printf(
866-
"Stopped due to an error evaluating condition of watchpoint ");
867-
wp_sp->GetDescription(error_sp.get(), eDescriptionLevelBrief);
868-
error_sp->Printf(": \"%s\"", wp_sp->GetConditionText());
869-
error_sp->EOL();
870-
const char *err_str = error.AsCString("<Unknown Error>");
863+
const char *err_str = error.AsCString("<unknown error>");
871864
LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
872865

873-
error_sp->PutCString(err_str);
874-
error_sp->EOL();
875-
error_sp->Flush();
876-
// If the condition fails to be parsed or run, we should stop.
877-
m_should_stop = true;
866+
StreamString strm;
867+
strm << "stopped due to an error evaluating condition of "
868+
"watchpoint ";
869+
wp_sp->GetDescription(&strm, eDescriptionLevelBrief);
870+
strm << ": \"" << wp_sp->GetConditionText() << "\"\n";
871+
strm << err_str;
872+
873+
Debugger::ReportError(strm.GetString().str(),
874+
exe_ctx.GetTargetRef().GetDebugger().GetID());
878875
}
879876
}
880877

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# RUN: %clang_host %p/Inputs/dummy-target.c -o %t.out
2+
# RUN: %lldb -b -o "br s -n main -c 'bogus'" -o "run" %t.out 2>&1 | FileCheck %s
3+
4+
# CHECK: error: stopped due to an error evaluating condition of breakpoint 1.1: "bogus"
5+
# CHECK-NEXT: Couldn't parse conditional expression

0 commit comments

Comments
 (0)