void CodeLiteLLDBApp::ApplyBreakpoints(const LLDBCommand& command) { wxPrintf("codelite-lldb: ApplyBreakpoints called\n"); if ( m_target.GetProcess().GetState() == lldb::eStateStopped ) { wxPrintf("codelite-lldb: ApplyBreakpoints: process state is stopped - will apply them now\n"); // we can apply the breakpoints // Apply all breakpoints with an-invalid breakpoint ID LLDBBreakpoint::Vec_t breakpoints = command.GetBreakpoints(); while( !breakpoints.empty() ) { LLDBBreakpoint::Ptr_t breakPoint = breakpoints.at(0); if ( !breakPoint->IsApplied() ) { switch( breakPoint->GetType() ) { case LLDBBreakpoint::kFunction: { wxPrintf("codelite-lldb: creating breakpoint by name: %s\n", breakPoint->GetName()); m_target.BreakpointCreateByName(breakPoint->GetName().mb_str().data(), NULL); break; } case LLDBBreakpoint::kFileLine: { wxPrintf("codelite-lldb: creating breakpoint by location: %s,%d\n", breakPoint->GetFilename(), breakPoint->GetLineNumber()); m_target.BreakpointCreateByLocation(breakPoint->GetFilename().mb_str().data(), breakPoint->GetLineNumber()); break; } } } breakpoints.erase(breakpoints.begin()); } NotifyBreakpointsUpdated(); } else { wxPrintf("codelite-lldb: ApplyBreakpoints: process state is _NOT_ Stopped - interrupting process\n"); // interrupt the process m_interruptReason = kInterruptReasonApplyBreakpoints; m_target.GetProcess().SendAsyncInterrupt(); } }
LLDBBreakpoint::Vec_t LLDBConnector::GetUnappliedBreakpoints() { LLDBBreakpoint::Vec_t unappliedBreakpoints; for(size_t i = 0; i < m_breakpoints.size(); ++i) { if(!m_breakpoints.at(i)->IsApplied()) { unappliedBreakpoints.push_back(m_breakpoints.at(i)); } } return unappliedBreakpoints; }
void CodeLiteLLDBApp::NotifyBreakpointsUpdated() { LLDBBreakpoint::Vec_t breakpoints; int num = m_target.GetNumBreakpoints(); wxPrintf("codelite-lldb: Calling NotifyBreakpointsUpdated(). Got %d breakpoints\n", num); for(int i=0; i<num; ++i) { lldb::SBBreakpoint bp = m_target.GetBreakpointAtIndex(i); if ( bp.IsValid() && bp.GetNumResolvedLocations() ) { // Add the parent breakpoint LLDBBreakpoint::Ptr_t mainBreakpoint( new LLDBBreakpoint() ); mainBreakpoint->SetId( bp.GetID() ); if ( bp.GetNumLocations() > 1 ) { // add all the children locations to the main breakpoint for(size_t i=0; i<bp.GetNumLocations(); ++i) { lldb::SBBreakpointLocation loc = bp.GetLocationAtIndex(i); lldb::SBFileSpec fileLoc = loc.GetAddress().GetLineEntry().GetFileSpec(); wxFileName bpFile( fileLoc.GetDirectory(), fileLoc.GetFilename() ); // Create a breakpoint for this location LLDBBreakpoint::Ptr_t new_bp(new LLDBBreakpoint()); new_bp->SetType( LLDBBreakpoint::kLocation ); new_bp->SetFilename( bpFile.GetFullPath() ); new_bp->SetLineNumber( loc.GetAddress().GetLineEntry().GetLine() ); new_bp->SetName( loc.GetAddress().GetFunction().GetName() ); mainBreakpoint->GetChildren().push_back( new_bp ); } } else { lldb::SBBreakpointLocation loc = bp.GetLocationAtIndex(0); lldb::SBFileSpec fileLoc = loc.GetAddress().GetLineEntry().GetFileSpec(); wxFileName bpFile( fileLoc.GetDirectory(), fileLoc.GetFilename() ); mainBreakpoint->SetType( LLDBBreakpoint::kFileLine ); mainBreakpoint->SetName( loc.GetAddress().GetFunction().GetName() ); mainBreakpoint->SetFilename( bpFile.GetFullPath() ); mainBreakpoint->SetLineNumber( loc.GetAddress().GetLineEntry().GetLine() ); } breakpoints.push_back( mainBreakpoint ); } } LLDBReply reply; reply.SetReplyType( kReplyTypeBreakpointsUpdated ); reply.SetBreakpoints( breakpoints ); SendReply( reply ); }
BreakpointInfo::Vec_t LLDBBreakpoint::ToBreakpointInfoVector(const LLDBBreakpoint::Vec_t& breakpoints) { BreakpointInfo::Vec_t bps; for(size_t i=0; i<breakpoints.size(); ++i) { LLDBBreakpoint::Ptr_t bp = breakpoints.at(i); BreakpointInfo gdbBp; gdbBp.Create(bp->GetFilename(), bp->GetLineNumber(), ++ s_internalGdbBpId); gdbBp.bp_type = BP_type_break; // dont add breakpoints to a non existent location bps.push_back( gdbBp ); } return bps; }
LLDBBreakpoint::Vec_t LLDBBreakpoint::FromBreakpointInfoVector(const BreakpointInfo::Vec_t& breakpoints) { LLDBBreakpoint::Vec_t bps; for(size_t i=0; i<breakpoints.size(); ++i) { if ( breakpoints.at(i).bp_type == BP_type_break ) { LLDBBreakpoint::Ptr_t bp(new LLDBBreakpoint() ); const BreakpointInfo &gdbBp = breakpoints.at(i); bp->SetName( gdbBp.function_name ); bp->SetFilename( gdbBp.file ); bp->SetLineNumber( gdbBp.lineno ); bp->SetType( kFileLine ); bps.push_back( bp ); } } return bps; }
void LLDBConnector::InvalidateBreakpoints() { // mark all the breakpoints as "not-applied" (id=-1) LLDBBreakpoint::Vec_t updatedList; for(size_t i = 0; i < m_breakpoints.size(); ++i) { m_breakpoints.at(i)->Invalidate(); if(wxFileName::Exists(m_breakpoints.at(i)->GetFilename())) { updatedList.push_back(m_breakpoints.at(i)); } } // we keep only breakpoints with valid filename m_breakpoints.swap(updatedList); ClearBreakpointDeletionQueue(); CL_DEBUG("codelite: InvalidateBreakpoints called"); m_pendingDeletionBreakpoints.clear(); }
void LLDBConnector::AddBreakpoints(const LLDBBreakpoint::Vec_t& breakpoints) { for(size_t i = 0; i < breakpoints.size(); ++i) { AddBreakpoint(breakpoints.at(i), false); } }