Entering the Debugger

Invoking the Debugger Initially

The simplest way to debug your program is to run remake -X or remake --debugger.

Example Debugger Sessions

In this example we’ll use the Makefile from libcdio-paranoia

$  remake --debugger
Reading makefiles...
Updating makefiles....

-> (/tmp/remake/Makefile:1505)
Makefile: Makefile.in config.status

To be continued…

Calling the debugger within the Makefile

Sometimes it is not feasible to invoke the program from the debugger. Although the debugger tries to set things up to make it look like your program is called, sometimes the differences matter. Also the debugger adds overhead and slows down your program.

Another possibility then is to a function call into your Makefile to call the debugger at the spot you want to stop at.

Here is an Example:

foo: bar

      $(debugger "debug target break")

      $(debugger "first bar command")
      @echo hi

baz: debug
      @echo hello again
$ remake -f /tmp/foo.Makefile
debugger() function caled with parameter "bar called"
:o (/tmp/foo.Makefile:3)
remake<0> where
=>#0  bar at /tmp/foo.Makefile:6
  #1  foo at /tmp/foo.Makefile:1
remake<0> quit
remake: That's all, folks...

$ remake -f /tmp/foo.Makefile baz
debugger() function caled with parameter "debug target break"
:o (/src/external-vcs/github/rocky/remake/tmp/debugger.Makefile:3)
remake<0> where
=>#0  debug at /tmp/foo.Makefile:3
  #1  baz at /tmp/foo.Makefile:10

Entering the debugger when remake encounters an error

This is done by supplying the --post-mortem or -! option on invocation.

Note that in contrast to the situations above. although you can examine state and evaluating expressions, execution has terminated. Therefore, some of the execution-specific commands are no longer applicable.