================ @@ -1266,25 +1235,22 @@ lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file, LLDB_INSTRUMENT_VA(this, dest_file, bkpt_list, append); SBError sberr; - TargetSP target_sp(GetSP()); - if (!target_sp) { - sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); + if (TargetSP target_sp = GetSP()) { + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + BreakpointIDList bp_id_list; + bkpt_list.CopyToBreakpointIDList(bp_id_list); + sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(), + bp_id_list, append); return sberr; } - - std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); - BreakpointIDList bp_id_list; - bkpt_list.CopyToBreakpointIDList(bp_id_list); - sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(), - bp_id_list, append); + sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); ---------------- bulbazord wrote:
Same suggestion here 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