Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. set follow-fork-mode
  2.  
  3. set follow-fork-mode parent
  4.  
  5. set follow-fork-mode child
  6.  
  7. set follow-fork-mode ask
  8.  
  9. catch exec
  10.  
  11. #include <unistd.h>
  12.  
  13. int main(void) {
  14. execl("./b", "./b", "ab", "cd", (char*)NULL);
  15. return 1;
  16. }
  17.  
  18. #include <stdio.h>
  19.  
  20. int main(int argc, char **argv ) {
  21. printf("%sn", argv[0]);
  22. printf("%sn", argv[1]);
  23. }
  24.  
  25. gcc -g a.c -o a
  26. gcc -g b.c -o b
  27. gdb -nh -q a
  28.  
  29. Reading symbols from a...done.
  30. (gdb) start
  31. Temporary breakpoint 1 at 0x4004ea: file a.c, line 4.
  32. Starting program: /home/cirsan01/test/gdb-exec/a
  33.  
  34. Temporary breakpoint 1, main () at a.c:4
  35. 4 execl("./b", "./b", "ab", "cd", (char*)NULL);
  36. (gdb) file b
  37. A program is being debugged already.
  38. Are you sure you want to change the file? (y or n) y
  39. Load new symbol table from "b"? (y or n) y
  40. Reading symbols from b...done.
  41. (gdb) b main
  42. Breakpoint 2 at 0x4004f5: file b.c, line 4.
  43. (gdb) n
  44.  
  45. Breakpoint 2, main (argc=0, argv=0x7fffffffa570) at b.c:4
  46. 4 printf("%sn", argv[1]);
  47. (gdb) n
  48. process 4877 is executing new program: /home/cirsan01/test/gdb-exec/b
  49.  
  50. Breakpoint 2, main (argc=3, argv=0x7fffffffa598) at b.c:4
  51. 4 printf("%sn", argv[1]);
  52. (gdb) n
  53. ab
  54. 5 printf("%sn", argv[2]);
  55. (gdb) n
  56. cd
  57. 6 }
  58. (gdb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement