Tools

Editors

Emacs and vim are the two standard editors which work via the terminal.

Emacs Shortcuts

Access the Emacs reference card here. Common shortcuts that you will use:

gdb

gdb is a GNU debugger that allows you to:

Commands

break main sets a break point (where you want to stop the execution) at the beginning of the main functions. run continues execution. next executes the statement on the current line and moves onto the next and then stops. Use the shortcut n. step begins to execute the statement on the current line. If the statement contains a function call, it steps into the function and pauses there. print <variable-name> prints out the value of the variable. p is the shotcut.

Valgrind

valgrind is a debugging tool for finding memory usage mistakes such as:

How to use valgrind?

  1. Compile program with the flag -g
  2. Run the program with valgrind --leak-check=full ./myFile <arg1> <arg2> ...
  3. Look for All heap bocks were freed and ERROR SUMMARY: 0 errors for no issues.