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

Method PyThread

src/pystack/_pystack/pythread.cpp:128–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128PyThread::PyThread(const std::shared_ptr<const AbstractProcessManager>& manager, remote_addr_t addr)
129: Thread(0, 0)
130{
131 d_pid = manager->Pid();
132
133 LOG(DEBUG) << std::hex << std::showbase << "Copying main thread struct from address " << addr;
134 Structure<py_thread_v> ts(manager, addr);
135
136 remote_addr_t frame_addr = getFrameAddr(manager, ts);
137 if (frame_addr != (remote_addr_t) nullptr) {
138 LOG(DEBUG) << std::hex << std::showbase << "Attempting to construct frame from address "
139 << frame_addr;
140 d_first_frame = std::make_unique<FrameObject>(manager, frame_addr, 0);
141 }
142
143 d_addr = addr;
144 remote_addr_t candidate_next_addr = ts.getField(&py_thread_v::o_next);
145 d_next_addr = candidate_next_addr == addr ? (remote_addr_t) nullptr : candidate_next_addr;
146
147 d_pthread_id = ts.getField(&py_thread_v::o_thread_id);
148 d_tid = getThreadTid(manager, ts, d_pthread_id);
149 d_next = nullptr;
150
151 if (d_next_addr != (remote_addr_t)NULL) {
152 LOG(DEBUG) << std::hex << std::showbase << "Attempting to construct a new thread address "
153 << d_next_addr;
154 d_next = std::make_unique<PyThread>(manager, d_next_addr);
155 }
156
157 d_gil_status = calculateGilStatus(ts, manager);
158 d_gc_status = calculateGCStatus(ts, manager);
159}
160
161int
162PyThread::getThreadTid(

Callers

nothing calls this directly

Calls 2

LOGClass · 0.85
PidMethod · 0.45

Tested by

no test coverage detected