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
(gdb) break main
(gdb) run
(gdb) break assembly_program.s:9
No source file named assembly_program.s.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (assembly_program.s:9) pending.
(gdb) set follow-fork-mode child
(gdb) set follow-exec-mode new
stepping into the execve() line
Code:
(gdb) s
process 6629 is executing new program: /home/jason/Development/asm/assembly_program
Program exited normally.
I read that re-issuing the "run" command might restart the program loaded by execve(), so issuing "run":
Code:
(gdb) run
Starting program: /home/jason/Development/asm/assembly_program
Program received signal SIGSEGV, Segmentation fault.
_start () at assembly_program.s:19
(gdb)
I have also tried setting the break point after the first program completes and prior to re-issuing the run command:
Code:
[New process 6638]
process 6638 is executing new program: /home/jason/Development/asm/assembly_program
Program exited normally.
(gdb) break assembly_program.s:9
Note: breakpoint -11 also set at pc 0x4000b0.
Breakpoint 2 at 0x4000b0: file assembly_program.s, line 9.
(gdb) run
Starting program: /home/jason/Development/asm/assembly_program
Program received signal SIGSEGV, Segmentation fault.
_start () at assembly_program.s:19
(gdb)
But either way, gdb blows right past my breakpoint. Any thoughts on how to debug this program?