PTRACE: Tracknested ThreadC++

Programme in C++. Entwicklerforum
Anonymous
 PTRACE: Tracknested Thread

Post by Anonymous »

Ich erstelle einen Debugger mit Ptrace , der den globalen Variablenzugriff überwacht. Zu diesem Zweck muss ich auch allen Threads folgen, die vom nachverfolgten Programm erstellt wurden.

Code: Select all

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 #include 
#include 

int global_var = 10;

int main()
{
std::thread t(
[]()
{
std::cout

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post