bramante@matrix:~/test$ ll
total 16
drwxrwxr-x 2 bramante bramante 4096 Aug 19 01:08 ./
drwxr-xr-x 5 bramante bramante 4096 Aug 11 23:32 ../
-rw-rw-r-- 1 bramante bramante 385 Aug 19 00:50 gdb.cmds
-rw-rw-r-- 1 bramante bramante 463 Aug 19 00:21 test.c
bramante@matrix:~/test$ gcc -g -o ./test ./test.c
bramante@matrix:~/test$ ./test 15 > /dev/null &
[1] 3027
bramante@matrix:~/test$ sudo gdb --batch --command=gdb.cmds --pid=3027
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff23dfe000
0x00007f25b2148090 in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
Breakpoint 1 at 0x40058c: file ./test.c, line 8.
Breakpoint 1, test (getValue=0x7fff23ca24a4) at ./test.c:8
8 *getValue = count % 4 ;
main (argc=2, argv=0x7fff23ca2598) at ./test.c:23
23 printf("[*] value: %d\n",getValue);
test (getValue=0x7fff23ca24a4) at ./test.c:11
11 }
9 count += 1 ;
Because GDB is in replay mode, writing to memory will make the execution log unusable from this point onward. Write memory at address 0x7fff23ca24a4?(y or n) [answered Y; input not from terminal]
*getValue: 103
Process record is stopped and all execution logs are deleted.
Breakpoint 1, test (getValue=0x7fff23ca24a4) at ./test.c:8
8 *getValue = count % 4 ;
main (argc=2, argv=0x7fff23ca2598) at ./test.c:23
23 printf("[*] value: %d\n",getValue);
test (getValue=0x7fff23ca24a4) at ./test.c:11
11 }
9 count += 1 ;
Because GDB is in replay mode, writing to memory will make the execution log unusable from this point onward. Write memory at address 0x7fff23ca24a4?(y or n) [answered Y; input not from terminal]
*getValue: 100
Process record is stopped and all execution logs are deleted.
Breakpoint 1, test (getValue=0x7fff23ca24a4) at ./test.c:8
8 *getValue = count % 4 ;
main (argc=2, argv=0x7fff23ca2598) at ./test.c:23
23 printf("[*] value: %d\n",getValue);
test (getValue=0x7fff23ca24a4) at ./test.c:11
11 }
9 count += 1 ;
Because GDB is in replay mode, writing to memory will make the execution log unusable from this point onward. Write memory at address 0x7fff23ca24a4?(y or n) [answered Y; input not from terminal]
*getValue: 101
Process record is stopped and all execution logs are deleted.
Breakpoint 1, test (getValue=0x7fff23ca24a4) at ./test.c:8
8 *getValue = count % 4 ;
main (argc=2, argv=0x7fff23ca2598) at ./test.c:23
23 printf("[*] value: %d\n",getValue);
test (getValue=0x7fff23ca24a4) at ./test.c:11
11 }
9 count += 1 ;
Because GDB is in replay mode, writing to memory will make the execution log unusable from this point onward. Write memory at address 0x7fff23ca24a4?(y or n) [answered Y; input not from terminal]
*getValue: 102
Process record is stopped and all execution logs are deleted.
[Inferior 1 (process 3027) exited normally]
[1]+ Done ./test 15 > /dev/null
bramante@matrix:~/test$
bramante@matrix:~/test$ cat gdb.cmds
b test
define printFuncInfo
record
finish
rs
rn
if *getValue == 0
set *getValue=100
else
if *getValue == 1
set *getValue=101
else
if *getValue == 2
set *getValue=102
else
set *getValue=103
end
end
end
printf "*getValue: %d\n", *getValue
record stop
continue
end
commands 1
printFuncInfo
end
continue
bramante@matrix:~/test$