Quick Debugging of Programs in Linux
In Linux, to inspect what a program is doing, which files it is accessing, etc., and overall, to debug it to identify where the issue lies, you can use GDB (GNU Debugger) and strace.
The following command is generally used for launching your program
|
|
For example
|
|
Here, -ex
executes a GDB command, and we specify r to run the program until it encounters an error or a breakpoint.
--args
indicates that the variables after the program name should be passed as arguments to the program. If the program does not take any arguments, you can omit this switch.
Another useful program is strace
which shows the system calls that program does
|
|