3.3.5. Using GDB to intercept application system calls
To stop program execution when the program performs specific system calls, use GNU Debugger (GDB) catchpoints, then inspect the program state and system call parameters at those points.
Prerequisites
Procedure
Set the catchpoint:
(gdb) catch syscall syscall-nameThe command
catch syscallsets a special type of breakpoint that halts execution when the program performs a system call.The
syscall-nameoption specifies the name of the call. You can specify multiple catchpoints for various system calls. Leaving out thesyscall-nameoption causes GDB to stop on any system call.Start execution of the program.
If the program has not started execution, start it:
(gdb) rIf the program execution is halted, resume it:
(gdb) c
- GDB halts execution after the program performs any specified system call.
- Use further GDB commands to examine the program state and advance execution, according to the particular situation.
To exit the GDB debugging session:
(gdb) q