================ @@ -1355,29 +1312,30 @@ SBTarget::WatchpointCreateByAddress(lldb::addr_t addr, size_t size, SBWatchpoint sb_watchpoint; lldb::WatchpointSP watchpoint_sp; - TargetSP target_sp(GetSP()); - uint32_t watch_type = 0; - if (options.GetWatchpointTypeRead()) - watch_type |= LLDB_WATCH_TYPE_READ; - if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeAlways) - watch_type |= LLDB_WATCH_TYPE_WRITE; - if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeOnModify) - watch_type |= LLDB_WATCH_TYPE_MODIFY; - if (watch_type == 0) { - error.SetErrorString("Can't create a watchpoint that is neither read nor " - "write nor modify."); - return sb_watchpoint; - } - if (target_sp && addr != LLDB_INVALID_ADDRESS && size > 0) { - std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); - // Target::CreateWatchpoint() is thread safe. - Status cw_error; - // This API doesn't take in a type, so we can't figure out what it is. - CompilerType *type = nullptr; - watchpoint_sp = - target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error); - error.SetError(std::move(cw_error)); - sb_watchpoint.SetSP(watchpoint_sp); + if (TargetSP target_sp = GetSP()) { + uint32_t watch_type = 0; + if (options.GetWatchpointTypeRead()) + watch_type |= LLDB_WATCH_TYPE_READ; + if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeAlways) + watch_type |= LLDB_WATCH_TYPE_WRITE; + if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeOnModify) + watch_type |= LLDB_WATCH_TYPE_MODIFY; + if (watch_type == 0) { + error.SetErrorString("Can't create a watchpoint that is neither read nor " + "write nor modify."); + return sb_watchpoint; + } + if (addr != LLDB_INVALID_ADDRESS && size > 0) { ---------------- labath wrote:
```suggestion uint32_t watch_type = 0; if (options.GetWatchpointTypeRead()) watch_type |= LLDB_WATCH_TYPE_READ; if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeAlways) watch_type |= LLDB_WATCH_TYPE_WRITE; if (options.GetWatchpointTypeWrite() == eWatchpointWriteTypeOnModify) watch_type |= LLDB_WATCH_TYPE_MODIFY; if (watch_type == 0) { error.SetErrorString("Can't create a watchpoint that is neither read nor " "write nor modify."); return sb_watchpoint; } if (TargetSP target_sp = GetSP(); target_sp && addr != LLDB_INVALID_ADDRESS && size > 0) { ``` https://github.com/llvm/llvm-project/pull/141284 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits