Я строю отладчик, используя PTRACE , который контролирует глобальные переменные доступ. Чтобы сделать это, я также должен следить за всеми потоками, созданными прослеженной программой.
PTRACE_O_TRACECLONE (since Linux 2.5.46)
Stop the tracee at the next clone(2) and
automatically start tracing the newly cloned
process, which will start with a SIGSTOP, or
PTRACE_EVENT_STOP if PTRACE_SEIZE was used. A
waitpid(2) by the tracer will return a status value
such that
status>>8 == (SIGTRAP | (PTRACE_EVENT_CLONE
main.cpp:
#include
#include
#include
#include
#include
#include
std::unordered_set needsSetup{};
void setupNewThread(pid_t threadId)
{
ptrace(PTRACE_SETOPTIONS, threadId, nullptr,PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK | PTRACE_O_EXITKILL);
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79777366/ptrace-track-nested-thread[/url]
Я строю отладчик, используя PTRACE , который контролирует глобальные переменные доступ. Чтобы сделать это, я также должен следить за всеми потоками, созданными прослеженной программой.[code]PTRACE_O_TRACECLONE (since Linux 2.5.46) Stop the tracee at the next clone(2) and automatically start tracing the newly cloned process, which will start with a SIGSTOP, or PTRACE_EVENT_STOP if PTRACE_SEIZE was used. A waitpid(2) by the tracer will return a status value such that