Skip to content

Commit d10c0c7

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.
1 parent 77eee57 commit d10c0c7

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,
@@ -860,20 +859,18 @@ class StopInfoWatchpoint : public StopInfo {
860859
}
861860
}
862861
} else {
863-
StreamSP error_sp = debugger.GetAsyncErrorStream();
864-
error_sp->Printf(
865-
"Stopped due to an error evaluating condition of watchpoint ");
866-
wp_sp->GetDescription(error_sp.get(), eDescriptionLevelBrief);
867-
error_sp->Printf(": \"%s\"", wp_sp->GetConditionText());
868-
error_sp->EOL();
869-
const char *err_str = error.AsCString("<Unknown Error>");
862+
const char *err_str = error.AsCString("<unknown error>");
870863
LLDB_LOGF(log, "Error evaluating condition: \"%s\"\n", err_str);
871864

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

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)