#include <vector>
#include "lldb/Core/Address.h"
+#include "lldb/Utility/Iterable.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
/// Destructor, currently does nothing.
~WatchpointList();
+ typedef std::list<lldb::WatchpointSP> wp_collection;
+ typedef LockingAdaptedIterable<wp_collection, lldb::WatchpointSP,
+ vector_adapter, std::recursive_mutex>
+ WatchpointIterable;
+
/// Add a Watchpoint to the list.
///
/// \param[in] wp_sp
/// The locker object that is set.
void GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
+ WatchpointIterable Watchpoints() const {
+ return WatchpointIterable(m_watchpoints, m_mutex);
+ }
+
protected:
- typedef std::list<lldb::WatchpointSP> wp_collection;
typedef std::vector<lldb::watch_id_t> id_vector;
id_vector GetWatchpointIDs() const;
return;
const WatchpointList &wp_list = exe_ctx.GetTargetPtr()->GetWatchpointList();
- const size_t wp_num = wp_list.GetSize();
- for (size_t idx = 0; idx < wp_num; ++idx) {
- const lldb::WatchpointSP wp_sp = wp_list.GetByIndex(idx);
+ for (lldb::WatchpointSP wp_sp : wp_list.Watchpoints()) {
StreamString strm;
wp_sp->Dump(&strm);
request.TryCompleteCurrentArg(std::to_string(wp_sp->GetID()),
if (!ProcessIsValid())
return false;
- size_t num_watchpoints = m_watchpoint_list.GetSize();
- for (size_t i = 0; i < num_watchpoints; ++i) {
- WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+ for (WatchpointSP wp_sp : m_watchpoint_list.Watchpoints()) {
if (!wp_sp)
return false;
return false;
size_t num_watchpoints = m_watchpoint_list.GetSize();
- for (size_t i = 0; i < num_watchpoints; ++i) {
- WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+ for (WatchpointSP wp_sp : m_watchpoint_list.Watchpoints()) {
if (!wp_sp)
return false;
if (!ProcessIsValid())
return false;
- size_t num_watchpoints = m_watchpoint_list.GetSize();
- for (size_t i = 0; i < num_watchpoints; ++i) {
- WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+ for (WatchpointSP wp_sp : m_watchpoint_list.Watchpoints()) {
if (!wp_sp)
return false;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
- size_t num_watchpoints = m_watchpoint_list.GetSize();
- for (size_t i = 0; i < num_watchpoints; ++i) {
- WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+ for (WatchpointSP wp_sp : m_watchpoint_list.Watchpoints()) {
if (!wp_sp)
return false;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
LLDB_LOGF(log, "Target::%s\n", __FUNCTION__);
- size_t num_watchpoints = m_watchpoint_list.GetSize();
- for (size_t i = 0; i < num_watchpoints; ++i) {
- WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+ for (WatchpointSP wp_sp : m_watchpoint_list.Watchpoints()) {
if (!wp_sp)
return false;
if (!ProcessIsValid())
return false;
- size_t num_watchpoints = m_watchpoint_list.GetSize();
- for (size_t i = 0; i < num_watchpoints; ++i) {
- WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i);
+ for (WatchpointSP wp_sp : m_watchpoint_list.Watchpoints()) {
if (!wp_sp)
return false;