linux - Self attach using ptrace? -
is possible ptrace same process thread in process? found discussion @ [1] seems suggest way (may or may not work) seems bit involved me not intimately familiar pthreads api. has tried this? code pointer great.
you emphatically not want use posix threads (pthreads) this. posix threads introduce whole new set of application semantics not apply here.
the second paragraph explains how right way:
and first 1 found reasonable way avoid problem: debugging thread can "vfork()" (or, if vfork() bad in libc, direct "clone(clone_vfork|clone_mm)" thing) have new thread in _different_ thread group, able ptrace , "synchronized" vm, because shares other threads might want debug
this mechanism how user-space debuggers gdb(1) , crash(8) work: create either closely-coupled child process using vfork(2) or use similar linux-specific clone(2) system call.
if fact, how every program except primeval init(1) program run: current process forks, , 1 process [usually child] exec(2)' desired program overwrite execution environment.
Comments
Post a Comment