I am trying to mock a function (for unit testing parent function) using GDB. One way to do it would be to set a break point in function you intend to mock and use GDB return command.
However I am unable to do the same when GDB call command is used.
(gdb) b secret_check
Breakpoint 1 at 0x80483ba: file ut_gdb.c, line 6.
(gdb) start
Temporary breakpoint 2 at 0x804843c: file ut_gdb.c, line 34.
Starting program: ut.bin
Temporary breakpoint 2, main () at ut_gdb.c:34
34 int res = 0;
(gdb) bt
#0 main () at ut_gdb.c:34
(gdb) call fact(3)
Breakpoint 1, secret_check (check_type=1) at ut_gdb.c:6
6 if(check_type == 0){
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(fact) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) bt
#0 secret_check (check_type=1) at ut_gdb.c:6
#1 0x080483ff in fact (n=3) at ut_gdb.c:19
#2
#3 main () at ut_gdb.c:34
Is it a limitation in GDB ?