2010-06-09 00:52:24 +08:00
|
|
|
//===-- BreakpointLocationCollection.cpp ------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
|
|
|
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
|
|
|
|
#include "lldb/Core/ModuleList.h"
|
2010-11-19 02:52:36 +08:00
|
|
|
#include "lldb/Breakpoint/Breakpoint.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
2010-06-16 10:00:15 +08:00
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// BreakpointLocationCollection constructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
BreakpointLocationCollection::BreakpointLocationCollection() :
|
|
|
|
m_break_loc_collection()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
BreakpointLocationCollection::~BreakpointLocationCollection()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BreakpointLocationCollection::Add(const BreakpointLocationSP &bp_loc)
|
|
|
|
{
|
|
|
|
BreakpointLocationSP old_bp_loc = FindByIDPair (bp_loc->GetBreakpoint().GetID(), bp_loc->GetID());
|
|
|
|
if (!old_bp_loc.get())
|
|
|
|
m_break_loc_collection.push_back(bp_loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-10 04:39:50 +08:00
|
|
|
BreakpointLocationCollection::Remove (lldb::break_id_t bp_id, lldb::break_id_t bp_loc_id)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
collection::iterator pos = GetIDPairIterator(bp_id, bp_loc_id); // Predicate
|
|
|
|
if (pos != m_break_loc_collection.end())
|
|
|
|
{
|
|
|
|
m_break_loc_collection.erase(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class BreakpointIDPairMatches
|
|
|
|
{
|
|
|
|
public:
|
2010-07-10 04:39:50 +08:00
|
|
|
BreakpointIDPairMatches (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) :
|
2010-06-09 00:52:24 +08:00
|
|
|
m_break_id(break_id),
|
|
|
|
m_break_loc_id (break_loc_id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator() (const BreakpointLocationSP &bp_loc) const
|
|
|
|
{
|
|
|
|
return m_break_id == bp_loc->GetBreakpoint().GetID()
|
|
|
|
&& m_break_loc_id == bp_loc->GetID();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2010-07-10 04:39:50 +08:00
|
|
|
const lldb::break_id_t m_break_id;
|
|
|
|
const lldb::break_id_t m_break_loc_id;
|
2010-06-09 00:52:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
BreakpointLocationCollection::collection::iterator
|
2010-07-10 04:39:50 +08:00
|
|
|
BreakpointLocationCollection::GetIDPairIterator (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
return std::find_if(m_break_loc_collection.begin(), m_break_loc_collection.end(), // Search full range
|
|
|
|
BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
|
|
|
|
}
|
|
|
|
|
|
|
|
BreakpointLocationCollection::collection::const_iterator
|
2010-07-10 04:39:50 +08:00
|
|
|
BreakpointLocationCollection::GetIDPairConstIterator (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
return std::find_if(m_break_loc_collection.begin(), m_break_loc_collection.end(), // Search full range
|
|
|
|
BreakpointIDPairMatches(break_id, break_loc_id)); // Predicate
|
|
|
|
}
|
|
|
|
|
|
|
|
BreakpointLocationSP
|
2010-07-10 04:39:50 +08:00
|
|
|
BreakpointLocationCollection::FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
BreakpointLocationSP stop_sp;
|
|
|
|
collection::iterator pos = GetIDPairIterator(break_id, break_loc_id);
|
|
|
|
if (pos != m_break_loc_collection.end())
|
|
|
|
stop_sp = *pos;
|
|
|
|
|
|
|
|
return stop_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BreakpointLocationSP
|
2010-07-10 04:39:50 +08:00
|
|
|
BreakpointLocationCollection::FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
BreakpointLocationSP stop_sp;
|
|
|
|
collection::const_iterator pos = GetIDPairConstIterator(break_id, break_loc_id);
|
|
|
|
if (pos != m_break_loc_collection.end())
|
|
|
|
stop_sp = *pos;
|
|
|
|
|
|
|
|
return stop_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
BreakpointLocationSP
|
2013-01-26 02:06:21 +08:00
|
|
|
BreakpointLocationCollection::GetByIndex (size_t i)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
BreakpointLocationSP stop_sp;
|
2010-07-10 04:39:50 +08:00
|
|
|
if (i < m_break_loc_collection.size())
|
2010-06-09 00:52:24 +08:00
|
|
|
stop_sp = m_break_loc_collection[i];
|
|
|
|
|
|
|
|
return stop_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BreakpointLocationSP
|
2013-01-26 02:06:21 +08:00
|
|
|
BreakpointLocationCollection::GetByIndex (size_t i) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
BreakpointLocationSP stop_sp;
|
2010-07-10 04:39:50 +08:00
|
|
|
if (i < m_break_loc_collection.size())
|
2010-06-09 00:52:24 +08:00
|
|
|
stop_sp = m_break_loc_collection[i];
|
|
|
|
|
|
|
|
return stop_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
BreakpointLocationCollection::ShouldStop (StoppointCallbackContext *context)
|
|
|
|
{
|
|
|
|
bool shouldStop = false;
|
2010-07-10 04:39:50 +08:00
|
|
|
const size_t count = GetSize();
|
2010-08-04 09:40:35 +08:00
|
|
|
for (size_t i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (GetByIndex(i)->ShouldStop(context))
|
2010-06-09 00:52:24 +08:00
|
|
|
shouldStop = true;
|
|
|
|
}
|
|
|
|
return shouldStop;
|
|
|
|
}
|
|
|
|
|
2010-06-16 10:00:15 +08:00
|
|
|
bool
|
|
|
|
BreakpointLocationCollection::ValidForThisThread (Thread *thread)
|
|
|
|
{
|
|
|
|
collection::iterator pos,
|
|
|
|
begin = m_break_loc_collection.begin(),
|
|
|
|
end = m_break_loc_collection.end();
|
|
|
|
|
|
|
|
for (pos = begin; pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if ((*pos)->ValidForThisThread (thread))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-26 10:19:28 +08:00
|
|
|
bool
|
|
|
|
BreakpointLocationCollection::IsInternal () const
|
|
|
|
{
|
|
|
|
collection::const_iterator pos,
|
|
|
|
begin = m_break_loc_collection.begin(),
|
|
|
|
end = m_break_loc_collection.end();
|
|
|
|
|
|
|
|
bool is_internal = true;
|
|
|
|
|
|
|
|
for (pos = begin; pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if (!(*pos)->GetBreakpoint().IsInternal ())
|
|
|
|
{
|
|
|
|
is_internal = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return is_internal;
|
|
|
|
}
|
2010-06-16 10:00:15 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
BreakpointLocationCollection::GetDescription (Stream *s, lldb::DescriptionLevel level)
|
|
|
|
{
|
|
|
|
collection::iterator pos,
|
|
|
|
begin = m_break_loc_collection.begin(),
|
|
|
|
end = m_break_loc_collection.end();
|
|
|
|
|
|
|
|
for (pos = begin; pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if (pos != begin)
|
|
|
|
s->PutChar(' ');
|
|
|
|
(*pos)->GetDescription(s, level);
|
|
|
|
}
|
|
|
|
}
|
2014-10-22 09:54:17 +08:00
|
|
|
|