Run process with gdb and detach it -
is possible run process gdb
, modify memory , detach
process afterwards?
i can't start process outside of gdb
need modify memory, before first instruction executed.
when detach
process started gdb
, gdb
hang, killing gdb
process makes debugged process still running.
i use following script launch process:
echo '# custom gdb function finds entry_point assigns $entry_point_address entry_point b *$entry_point_address run set *((char *)0x100004147) = 0xeb set *((char *)0x100004148) = 0xe2 detach # gdb hangs here quit # quit never gets executed ' | gdb -quiet "$file"
this happens in both of gdb
versions:
gnu gdb 6.3.50-20050815 (apple version gdb-1824) gnu gdb 6.3.50-20050815 (apple version gdb-1822 + reverse.put.as patches v0.4)
i'm pretty sure can't detach inferior processes started directly under gdb
, however, following might work you, based on recent gdb
, don't know how of work on version 6.3.
create small shell script, this:
#! /bin/sh echo $$ sleep 10 exec /path/to/your/program arg1 arg2 arg3
now start up, spot pid echo $$
, , attach shell script gdb -p pid
. once attached can:
(gdb) set follow-fork-mode child (gdb) catch exec (gdb) continue continuing. [new process new-pid] process new-pid executing new program: /path/to/your/program [switching process new-pid] catchpoint 1 (exec'd /path/to/your/program), 0x00007f40d8e9fc80 in _start () (gdb)
you can modify child process required. once you're finished do:
(gdb) detach
and /path/to/your/program
should resume (or start in case) running.
Comments
Post a Comment