MCPcopy Create free account
hub / github.com/bloomberg/pystack / PyThread

Class PyThread

src/pystack/_pystack/pythread.h:31–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29};
30
31class PyThread : public Thread
32{
33 public:
34 // Enums
35 enum GilStatus { UNKNOWN = -1, NOT_HELD = 0, HELD = 1 };
36 enum GCStatus { COLLECTING_UNKNOWN = -1, NOT_COLLECTING = 0, COLLECTING = 1 };
37
38 // Constructors
39 PyThread(const std::shared_ptr<const AbstractProcessManager>& manager, remote_addr_t addr);
40
41 // Getters
42 std::shared_ptr<FrameObject> FirstFrame() const;
43 std::shared_ptr<PyThread> NextThread() const;
44
45 // Methods
46 GilStatus isGilHolder() const;
47 GCStatus isGCCollecting() const;
48
49 // Static Methods
50 static remote_addr_t getFrameAddr(
51 const std::shared_ptr<const AbstractProcessManager>& manager,
52 Structure<py_thread_v>& ts);
53
54 private:
55 // Data members
56 unsigned long d_pthread_id;
57 GilStatus d_gil_status;
58 GCStatus d_gc_status;
59 remote_addr_t d_addr;
60 remote_addr_t d_next_addr;
61 std::shared_ptr<PyThread> d_next;
62 std::shared_ptr<FrameObject> d_first_frame;
63
64 // Methods
65 GilStatus calculateGilStatus(
66 Structure<py_thread_v>& ts,
67 const std::shared_ptr<const AbstractProcessManager>& manager) const;
68 GCStatus calculateGCStatus(
69 Structure<py_thread_v>& ts,
70 const std::shared_ptr<const AbstractProcessManager>& manager) const;
71
72 // Static Methods
73 static int inferTidFromPThreadStructure(
74 const std::shared_ptr<const AbstractProcessManager>& manager,
75 unsigned long pthread_id);
76 static int getThreadTid(
77 const std::shared_ptr<const AbstractProcessManager>& manager,
78 Structure<py_thread_v>& ts,
79 unsigned long pthread_id);
80};
81
82std::shared_ptr<PyThread>
83getThreadFromInterpreterState(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected