================ @@ -251,6 +251,44 @@ const lldb::TargetSP Breakpoint::GetTargetSP() { bool Breakpoint::IsInternal() const { return LLDB_BREAK_ID_IS_INTERNAL(m_bid); } +llvm::Error Breakpoint::SetIsHardware(bool is_hardware) { + if (is_hardware == m_hardware) + return llvm::Error::success(); + + // Disable all non-hardware breakpoint locations. + std::vector<BreakpointLocationSP> locations; + for (BreakpointLocationSP location_sp : m_locations.BreakpointLocations()) { + if (!location_sp || !location_sp->IsEnabled()) + continue; + + lldb::BreakpointSiteSP breakpoint_site_sp = + location_sp->GetBreakpointSite(); + if (!breakpoint_site_sp || + breakpoint_site_sp->GetType() == BreakpointSite::eHardware) + continue; + + locations.push_back(location_sp); + location_sp->SetEnabled(false); + } + + // Toggle the hardware mode. + m_hardware = is_hardware; + + // Re-enable all breakpoint locations. + size_t num_failures = 0; + for (BreakpointLocationSP location_sp : locations) { + if (!location_sp->SetEnabled(true)) + num_failures++; + } + + if (num_failures != 0) + return llvm::createStringError( ---------------- jimingham wrote:
The locations we didn't convert to hardware will be left disabled. That's a useful but not obvious bit of information, which it would be good to include in the error string. Other than that this looks okay to me. https://github.com/llvm/llvm-project/pull/146602 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits