# GDB If you are a Mac user, you can use LLDB instead, the usage is similar. ## GDB compile with the '-g' parameter ``` gcc -g main.c -o main ``` enter gdb (for gdb) ``` gdb main ``` (for lldb) ``` lldb main ``` show source code ``` l ``` set breakpoints at line 10 ``` b 10 ``` show all breakpoints (for gdb) ``` info b ``` (for lldb) ``` breakpoint list ``` set testcase input file (for gdb) ``` run < testcase.txt ``` (for lldb) ``` settings set target.input-path testcase.txt ``` execute main ``` r ``` show the value of variable ``` p [variable_name] ``` continue execution to the next breakpoints ``` c ``` execute the next line ``` n ``` execute the next line, if there is a function call, step into that function ``` s ``` terminate the current debugging process ``` kill ``` leave gdb ``` q ```