MihailPro

gdb

Dec 16th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. user@localhost:~/Documents/MOS/LAB3> gcc -g ourcat.c -o ourcat.out
  2. user@localhost:~/Documents/MOS/LAB3> gdb -quiet ourcat.out
  3. Reading symbols from ourcat.out...done.
  4. (gdb) break printFile
  5. Breakpoint 1 at 0x400689: file ourcat.c, line 23.
  6. (gdb) break 26
  7. Breakpoint 2 at 0x4006ef: file ourcat.c, line 26.
  8. (gdb) run 1.txt 2.txt
  9. Starting program: /home/user/Documents/MOS/LAB3/ourcat.out 1.txt 2.txt
  10. Missing separate debuginfo for /lib64/ld-linux-x86-64.so.2
  11. Try: zypper install -C "debuginfo(build-id)=eb2c8c73c3e72388ba2922084444fdb2b7c592ba"
  12. Missing separate debuginfo for /lib64/libc.so.6
  13. Try: zypper install -C "debuginfo(build-id)=d15eed2af0706b9f841d2d763796fef6e5a63aec"
  14.  
  15. Breakpoint 1, printFile (fileName=0x7fffffffe2d2 "1.txt") at ourcat.c:23
  16. 23 void printFile(char* fileName) {
  17. (gdb) c
  18. Continuing.
  19.  
  20. Breakpoint 2, printFile (fileName=0x7fffffffe2d2 "1.txt") at ourcat.c:26
  21. 26 int fileDesc = open(fileName, O_RDONLY);
  22. (gdb) watch readBytes
  23. Hardware watchpoint 3: readBytes
  24. (gdb) c
  25. Continuing.
  26.  
  27. Hardware watchpoint 3: readBytes
  28.  
  29. Old value = 0
  30. New value = 5
  31. 0x0000000000400752 in printFile (fileName=0x7fffffffe2d2 "1.txt") at ourcat.c:27
  32. 27 while ((readBytes = read(fileDesc, buffer, BUFFER_SIZE)) > 0) {
  33. (gdb) print fileName
  34. $1 = 0x7fffffffe2d2 "1.txt"
  35. (gdb) c
  36. Continuing.
  37. 1234
  38.  
  39. Hardware watchpoint 3: readBytes
  40.  
  41. Old value = 5
  42. New value = 0
  43. 0x0000000000400752 in printFile (fileName=0x7fffffffe2d2 "1.txt") at ourcat.c:27
  44. 27 while ((readBytes = read(fileDesc, buffer, BUFFER_SIZE)) > 0) {
  45. (gdb) delete
  46. Delete all breakpoints? (y or n) y
  47. (gdb) c
  48. Continuing.
  49. 45678
  50. [Inferior 1 (process 14043) exited normally]
  51. (gdb) exit
  52. Undefined command: "exit". Try "help".
  53. (gdb) quit
Advertisement
Add Comment
Please, Sign In to add comment