Debugging Catkin Workspace

Prerequisite

  1. Allow ptrace by following these instructions

Attach to a unstarted process

  1. Next in Qt Creator browse to the file you wish to debug and insert break points.
  2. Menu Bar > Debug > Start Debugging > Attach to Unstarted Application...
  3. Browse to the executable then select Start Watching.
  4. Now run your project. Ctrl + R
  5. Now depending on where the breakpoints were placed in qt, it should be stopped at a break point when it reaches one.

Attach to a running process

  1. Next in Qt Creator browse to the file you wish to debug and insert break points.
  2. Now run your project. Ctrl + R
  3. Menu Bar > Debug > Start Debugging > Attach to Running Application...
  4. Now select the Process ID and then click the button Attach to Process.
  5. Now depending on where the breakpoints were placed in qt, it should be stopped at a break point when it reaches one.

Note

  1. Sometime it will be paused at a ros::spin, so check after it has attached and if it is passed and not at a inserted breakpoint click the continue button in the debugger.
  2. Some nodes can execute fast enough to where the debugger is not fully attach to the process before it reaches the first breakpoint, resulting in it never stopping at the breakpoint. To solve this add a sleep(NumberOfSeconds) command at the start of the node to allow enough time for the debugger to attach. Usually 3 seconds is enough but varies depending on the size of the node.