Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user@localhost:~/Documents/MOS/LAB3> gcc -g ourcat.c -o ourcat.out
- user@localhost:~/Documents/MOS/LAB3> gdb -quiet ourcat.out
- Reading symbols from ourcat.out...done.
- (gdb) break printFile
- Breakpoint 1 at 0x400689: file ourcat.c, line 23.
- (gdb) break 26
- Breakpoint 2 at 0x4006ef: file ourcat.c, line 26.
- (gdb) run 1.txt 2.txt
- Starting program: /home/user/Documents/MOS/LAB3/ourcat.out 1.txt 2.txt
- Missing separate debuginfo for /lib64/ld-linux-x86-64.so.2
- Try: zypper install -C "debuginfo(build-id)=eb2c8c73c3e72388ba2922084444fdb2b7c592ba"
- Missing separate debuginfo for /lib64/libc.so.6
- Try: zypper install -C "debuginfo(build-id)=d15eed2af0706b9f841d2d763796fef6e5a63aec"
- Breakpoint 1, printFile (fileName=0x7fffffffe2d2 "1.txt") at ourcat.c:23
- 23 void printFile(char* fileName) {
- (gdb) c
- Continuing.
- Breakpoint 2, printFile (fileName=0x7fffffffe2d2 "1.txt") at ourcat.c:26
- 26 int fileDesc = open(fileName, O_RDONLY);
- (gdb) watch readBytes
- Hardware watchpoint 3: readBytes
- (gdb) c
- Continuing.
- Hardware watchpoint 3: readBytes
- Old value = 0
- New value = 5
- 0x0000000000400752 in printFile (fileName=0x7fffffffe2d2 "1.txt") at ourcat.c:27
- 27 while ((readBytes = read(fileDesc, buffer, BUFFER_SIZE)) > 0) {
- (gdb) print fileName
- $1 = 0x7fffffffe2d2 "1.txt"
- (gdb) c
- Continuing.
- 1234
- Hardware watchpoint 3: readBytes
- Old value = 5
- New value = 0
- 0x0000000000400752 in printFile (fileName=0x7fffffffe2d2 "1.txt") at ourcat.c:27
- 27 while ((readBytes = read(fileDesc, buffer, BUFFER_SIZE)) > 0) {
- (gdb) delete
- Delete all breakpoints? (y or n) y
- (gdb) c
- Continuing.
- 45678
- [Inferior 1 (process 14043) exited normally]
- (gdb) exit
- Undefined command: "exit". Try "help".
- (gdb) quit
Advertisement
Add Comment
Please, Sign In to add comment