diff options
author | Jim Ingham <jingham@apple.com> | 2016-09-14 19:07:35 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2016-09-14 19:07:35 +0000 |
commit | 01f166647195b7ffff11d270648a679fb7b65bf1 (patch) | |
tree | 368f3c232731851a4f0a9b3d5e5038669aed6af0 /lldb/source/API/SBTarget.cpp | |
parent | db30877477e0c6434fd4a62ada3cd7916a79efa5 (diff) | |
download | bcm5719-llvm-01f166647195b7ffff11d270648a679fb7b65bf1.tar.gz bcm5719-llvm-01f166647195b7ffff11d270648a679fb7b65bf1.zip |
Add SB API's for writing breakpoints to & creating the from a file.
Moved the guts of the code from CommandObjectBreakpoint to Target (should
have done it that way in the first place.) Added an SBBreakpointList class
so there's a way to specify which breakpoints to serialize and to report the
deserialized breakpoints.
<rdar://problem/12611863>
llvm-svn: 281520
Diffstat (limited to 'lldb/source/API/SBTarget.cpp')
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 5ada7fb8a30..66d375aa457 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1097,6 +1097,58 @@ bool SBTarget::DeleteAllBreakpoints() { return false; } +lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file, + SBBreakpointList &new_bps) { + SBError sberr; + TargetSP target_sp(GetSP()); + if (!target_sp) { + sberr.SetErrorString( + "BreakpointCreateFromFile called with invalid target."); + return sberr; + } + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + + BreakpointIDList bp_ids; + sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(), bp_ids); + if (sberr.Fail()) + return sberr; + + size_t num_bkpts = bp_ids.GetSize(); + for (size_t i = 0; i < num_bkpts; i++) { + BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i); + new_bps.AppendByID(bp_id.GetBreakpointID()); + } + return sberr; +} + +lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) { + SBError sberr; + TargetSP target_sp(GetSP()); + if (!target_sp) { + sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); + return sberr; + } + SBBreakpointList bkpt_list(*this); + return BreakpointsWriteToFile(dest_file, bkpt_list); +} + +lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file, + SBBreakpointList &bkpt_list) { + SBError sberr; + TargetSP target_sp(GetSP()); + if (!target_sp) { + sberr.SetErrorString("BreakpointWriteToFile called with invalid target."); + 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); + return sberr; +} + uint32_t SBTarget::GetNumWatchpoints() const { TargetSP target_sp(GetSP()); if (target_sp) { |