Skip to content

Debuggers

GDB

GDB, the GNU Project debugger, allows you to see what is going on `inside’ another program while it executes – or what another program was doing at the moment it crashed.

Compile your code with debugging information

gcc [flags] -g [source file] -o [output filer]

Start session

gdb ./a.out

GDB commands

Command Description
help display a list of named classes of commands
run start the program
attach attach to a running process outside GDB
step go to the next source line, will step into a function/subroutine
next go to the next source line, function/subroutine calls are executed without stepping into them
continue continue executing
break sets breakpoint
watch set a watchpoint to stop execution when the value of a variable or an expression changes
list display (default 10) lines of source surrounding the current line
print print value of a variable
backtrace displays a stack frame for each active subroutine
detach detach from a process
quit exit GDB

To execute shell commands during the debugging session issue shell in front of the command, e.g.

(gdb) shell ls -l

For more information visit: GDB website

CUDA-GDB

CUDA-GDB is the NVIDIA tool for debugging CUDA applications running on Linux and Mac. CUDA-GDB is an extension to the x86-64 port of GDB, the GNU Project debugger. The tool provides developers with a mechanism for debugging CUDA applications running on actual hardware. This enables developers to debug applications without the potential variations introduced by simulation and emulation environments.

module load cuda

For more information visit: CUDA-GDB website