@@ -45,7 +45,9 @@ BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner,
4545 SetThreadIDInternal (tid);
4646}
4747
48- BreakpointLocation::~BreakpointLocation () { ClearBreakpointSite (); }
48+ BreakpointLocation::~BreakpointLocation () {
49+ llvm::consumeError (ClearBreakpointSite ());
50+ }
4951
5052lldb::addr_t BreakpointLocation::GetLoadAddress () const {
5153 return m_address.GetOpcodeLoadAddress (&m_owner.GetTarget ());
@@ -72,13 +74,12 @@ bool BreakpointLocation::IsEnabled() const {
7274 return true ;
7375}
7476
75- bool BreakpointLocation::SetEnabled (bool enabled) {
77+ llvm::Error BreakpointLocation::SetEnabled (bool enabled) {
7678 GetLocationOptions ().SetEnabled (enabled);
77- const bool success =
78- enabled ? ResolveBreakpointSite () : ClearBreakpointSite ();
79+ llvm::Error error = enabled ? ResolveBreakpointSite () : ClearBreakpointSite ();
7980 SendBreakpointLocationChangedEvent (enabled ? eBreakpointEventTypeEnabled
8081 : eBreakpointEventTypeDisabled);
81- return success ;
82+ return error ;
8283}
8384
8485bool BreakpointLocation::IsAutoContinue () const {
@@ -422,25 +423,27 @@ lldb::BreakpointSiteSP BreakpointLocation::GetBreakpointSite() const {
422423 return m_bp_site_sp;
423424}
424425
425- bool BreakpointLocation::ResolveBreakpointSite () {
426+ llvm::Error BreakpointLocation::ResolveBreakpointSite () {
426427 if (m_bp_site_sp)
427- return true ;
428+ return llvm::Error::success () ;
428429
429430 Process *process = m_owner.GetTarget ().GetProcessSP ().get ();
430431 if (process == nullptr )
431- return false ;
432+ return llvm::createStringError ( " no process " ) ;
432433
433434 lldb::break_id_t new_id =
434435 process->CreateBreakpointSite (shared_from_this (), m_owner.IsHardware ());
435436
436- if (new_id == LLDB_INVALID_BREAK_ID) {
437- LLDB_LOGF (GetLog (LLDBLog::Breakpoints),
438- " Failed to add breakpoint site at 0x%" PRIx64 " (resolved=%s)" ,
439- m_address.GetOpcodeLoadAddress (&m_owner.GetTarget ()),
440- IsResolved () ? " yes" : " no" );
441- }
437+ if (new_id == LLDB_INVALID_BREAK_ID)
438+ return llvm::createStringError (
439+ llvm::formatv (" Failed to add breakpoint site at {0:x}" ,
440+ m_address.GetOpcodeLoadAddress (&m_owner.GetTarget ())));
441+
442+ if (!IsResolved ())
443+ return llvm::createStringError (
444+ " breakpoint site created but location is still unresolved" );
442445
443- return IsResolved ();
446+ return llvm::Error::success ();
444447}
445448
446449bool BreakpointLocation::SetBreakpointSite (BreakpointSiteSP &bp_site_sp) {
@@ -449,22 +452,21 @@ bool BreakpointLocation::SetBreakpointSite(BreakpointSiteSP &bp_site_sp) {
449452 return true ;
450453}
451454
452- bool BreakpointLocation::ClearBreakpointSite () {
453- if (m_bp_site_sp.get ()) {
454- ProcessSP process_sp (m_owner.GetTarget ().GetProcessSP ());
455- // If the process exists, get it to remove the owner, it will remove the
456- // physical implementation of the breakpoint as well if there are no more
457- // owners. Otherwise just remove this owner.
458- if (process_sp)
459- process_sp->RemoveConstituentFromBreakpointSite (GetBreakpoint ().GetID (),
460- GetID (), m_bp_site_sp);
461- else
462- m_bp_site_sp->RemoveConstituent (GetBreakpoint ().GetID (), GetID ());
463-
464- m_bp_site_sp.reset ();
465- return true ;
466- }
467- return false ;
455+ llvm::Error BreakpointLocation::ClearBreakpointSite () {
456+ if (!m_bp_site_sp)
457+ return llvm::createStringError (" no breakpoint site to clear" );
458+
459+ // If the process exists, get it to remove the owner, it will remove the
460+ // physical implementation of the breakpoint as well if there are no more
461+ // owners. Otherwise just remove this owner.
462+ if (ProcessSP process_sp = m_owner.GetTarget ().GetProcessSP ())
463+ process_sp->RemoveConstituentFromBreakpointSite (GetBreakpoint ().GetID (),
464+ GetID (), m_bp_site_sp);
465+ else
466+ m_bp_site_sp->RemoveConstituent (GetBreakpoint ().GetID (), GetID ());
467+
468+ m_bp_site_sp.reset ();
469+ return llvm::Error::success ();
468470}
469471
470472void BreakpointLocation::GetDescription (Stream *s,
0 commit comments