Coverage Report

Created: 2023-09-21 18:56

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Target/QueueList.h
Line
Count
Source
1
//===-- QueueList.h --------------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLDB_TARGET_QUEUELIST_H
10
#define LLDB_TARGET_QUEUELIST_H
11
12
#include <mutex>
13
#include <vector>
14
15
#include "lldb/Utility/Iterable.h"
16
#include "lldb/Utility/UserID.h"
17
#include "lldb/lldb-private.h"
18
19
namespace lldb_private {
20
21
// QueueList:
22
// This is the container for libdispatch aka Grand Central Dispatch Queue
23
// objects.
24
//
25
// Each Process will have a QueueList.  When the process execution is paused,
26
// the QueueList may be populated with Queues by the SystemRuntime.
27
28
class QueueList {
29
  friend class Process;
30
31
public:
32
  QueueList(Process *process);
33
34
  ~QueueList();
35
36
  /// Get the number of libdispatch queues that are available
37
  ///
38
  /// \return
39
  ///     The number of queues that are stored in the QueueList.
40
  uint32_t GetSize();
41
42
  /// Get the Queue at a given index number
43
  ///
44
  /// \param [in] idx
45
  ///     The index number (0-based) of the queue.
46
  /// \return
47
  ///     The Queue at that index number.
48
  lldb::QueueSP GetQueueAtIndex(uint32_t idx);
49
50
  typedef std::vector<lldb::QueueSP> collection;
51
  typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter,
52
                                 std::mutex>
53
      QueueIterable;
54
55
  /// Iterate over the list of queues
56
  ///
57
  /// \return
58
  ///     An Iterable object which can be used to loop over the queues
59
  ///     that exist.
60
84
  QueueIterable Queues() { return QueueIterable(m_queues, m_mutex); }
61
62
  /// Clear out the list of queues from the QueueList
63
  void Clear();
64
65
  /// Add a Queue to the QueueList
66
  ///
67
  /// \param [in] queue
68
  ///     Used by the SystemRuntime to populate the QueueList
69
  void AddQueue(lldb::QueueSP queue);
70
71
  /// Find a queue in the QueueList by QueueID
72
  ///
73
  /// \param [in] qid
74
  ///     The QueueID (same as returned by Thread::GetQueueID()) to find.
75
  ///
76
  /// \return
77
  ///     A QueueSP to the queue requested, if it is present in the QueueList.
78
  ///     An empty QueueSP will be returned if this queue was not found.
79
  lldb::QueueSP FindQueueByID(lldb::queue_id_t qid);
80
81
  /// Find a queue in the QueueList by IndexID
82
  ///
83
  /// \param [in] index_id
84
  ///     Find a queue by IndexID.  This is an integer associated with each
85
  ///     unique queue seen during a debug session and will not be reused
86
  ///     for a different queue.  Unlike the QueueID, a 64-bit value, this
87
  ///     will tend to be an integral value like 1 or 7.
88
  ///
89
  /// \return
90
  ///     A QueueSP to the queue requested, if it is present in the QueueList.
91
  ///     An empty QueueSP will be returned if this queue was not found.
92
  lldb::QueueSP FindQueueByIndexID(uint32_t index_id);
93
94
  std::mutex &GetMutex();
95
96
protected:
97
  // Classes that inherit from Process can see and modify these
98
  Process *m_process; ///< The process that manages this queue list.
99
  uint32_t
100
      m_stop_id; ///< The process stop ID that this queue list is valid for.
101
  collection m_queues; ///< The queues for this process.
102
  std::mutex m_mutex;
103
104
private:
105
  QueueList() = delete;
106
};
107
108
} // namespace lldb_private
109
110
#endif // LLDB_TARGET_QUEUELIST_H