Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set follow-fork-mode
- set follow-fork-mode parent
- set follow-fork-mode child
- set follow-fork-mode ask
- catch exec
- #include <unistd.h>
- int main(void) {
- execl("./b", "./b", "ab", "cd", (char*)NULL);
- return 1;
- }
- #include <stdio.h>
- int main(int argc, char **argv ) {
- printf("%sn", argv[0]);
- printf("%sn", argv[1]);
- }
- gcc -g a.c -o a
- gcc -g b.c -o b
- gdb -nh -q a
- Reading symbols from a...done.
- (gdb) start
- Temporary breakpoint 1 at 0x4004ea: file a.c, line 4.
- Starting program: /home/cirsan01/test/gdb-exec/a
- Temporary breakpoint 1, main () at a.c:4
- 4 execl("./b", "./b", "ab", "cd", (char*)NULL);
- (gdb) file b
- A program is being debugged already.
- Are you sure you want to change the file? (y or n) y
- Load new symbol table from "b"? (y or n) y
- Reading symbols from b...done.
- (gdb) b main
- Breakpoint 2 at 0x4004f5: file b.c, line 4.
- (gdb) n
- Breakpoint 2, main (argc=0, argv=0x7fffffffa570) at b.c:4
- 4 printf("%sn", argv[1]);
- (gdb) n
- process 4877 is executing new program: /home/cirsan01/test/gdb-exec/b
- Breakpoint 2, main (argc=3, argv=0x7fffffffa598) at b.c:4
- 4 printf("%sn", argv[1]);
- (gdb) n
- ab
- 5 printf("%sn", argv[2]);
- (gdb) n
- cd
- 6 }
- (gdb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement