gdb, fork(), exec()
I'm looking for a little help on using gdb to debug a program. The program is very similar to the one here.
The program creates a child process with fork(), which then executes a new file using execve(). The file that execve() loads up is compiled hand-written assembly compiled with "as -g". I can get gdb to step into the child process after the call to fork() by issuing the command "set follow-fork-mode child". I've played with "set follow-exec-mode new", but that doesn't seem to be impacting what happens after I step past/into the execve() call. The basic layout of what I am doing in gdb is as follows: Code:
$ gdb parent_program Code:
(gdb) s Code:
(gdb) run Code:
[New process 6638] |
I have no idea whether this would help, but...
I would try to change my assembly code so that the first thing it does is (something like) go into an infinite loop (perhaps you want something nice in the loop, like sleep or yield) -- such that the loop would terminate if the value of a variable in main memory were different from what it was. Next run the code, which eventually forks, etc., and eventually executes your modified assembly code and gets stuck in the infinite loop. Fire up ddd and attach to the process that corresponds to the executing assembly (which is stuck in the infinite loop). Set a breakpoint after the loop. Set the value of the variable in main memory such that the loop will be exited. Continue (in ddd) and perhaps then -- fingers crossed -- your breakpoint will be encountered and not ignored. |
All times are GMT -5. The time now is 12:39 AM. |