Next: , Previous: , Up: Sample Sessions   [Contents][Index]


1.1.4 Simple GNU Remake Debug Sessions

Now let’s go into the debugger. To do this, use the --debugger or -X option. Again we’ll use the Makefile from the source code of this distribution.

$  remake –debugger
...
Reading makefiles...
Updating makefiles....
Updating goal targets....

-> (/tmp/remake/Makefile:471)
Makefile: Makefile.in config.status
remake<0>

Before the prompt remake<0>, we show the position in the file (/tmp/remake/Makefile:471) of the target Makefile. We also show the dependencies of the target Makefile, namely: Makefile.in and config.status. The “0” in the prompt remake<0> is the command history number it increments as we enter commands.

Before the position are two dashes ->. This indicates that we have not done prerequisite checking for this target yet. Later we will come across other two-character icons like --, ++, and <-, to name few. But to get full information about why were are stopped, you can use the command info program:

remake<0> info program
Starting directory `/tmp/remake'
Program invocation:
	/tmp/remake/./remake  --debugger
Recursion level: 0
Program stopped at a breakpoint before prerequisite checking.
remake<1>

Notice that the prompt now lists “1” since we entered a command.

We can use the step command, (see Step), to progress a little in the interpretation or execution of the makefile:

remake<2> step
-> (/tmp/Makefile:457)
Makefile.in: Makefile.am config/gettext.m4 ... aclocal.m4
-> (/tmp/Makefile:488)
remake<3> step
-> (/tmp/Makefile:486)
aclocal.m4: config/dospaths.m4 config/gettext.m4 ...
remake<4> step

One subtlety in the output above. In the Makefile at line 486 you will see this:

$(ACLOCAL_M4):  $(am__aclocal_m4_deps)

In the location and dependent targets reported by GNU Remake above, variables have been expanded.

Let’s recap where we are right now. Target Makefile needs to build dependency Makefile.in and that depends on target aclocal.m4. We have now stepped into and stopped at that target.

You can see this dependency nesting using the where command:

remake<2> where
=>#0  aclocal.m4 at /tmp/remake/Makefile:486
  #1  Makefile.in at /tmp/remake/Makefile:457
  #2  Makefile at /tmp/remake/Makefile:471

If stepping is going too slowly, one can use next or set a breakpoint at a target. Let’s restart the program and then go directly to target config.h.in which is where we will see something else of interest.

remake<3> restart
Changing directory to /tmp/remake and restarting...
GNU Make 3.82+dbg-0.5
Built for i686-pc-linux-gnu
...
Reading makefiles...
Updating makefiles....

-> (/tmp/remake/Makefile:471)
Makefile: Makefile.in config.status
remake<0> continue config.h.in
Breakpoint 1 on target config.h.in: file Makefile, line 499.
Updating goal targets....
 /tmp/remake/Makefile:450	File `all' does not exist.

-> (/tmp/remake/Makefile:499)
config.h.in: config/dospaths.m4 ...
remake<1> step
-> (/tmp/remake/Makefile:499)
remake<2> step
   Prerequisite `stamp-h1' is newer than target `config.h'.
  /tmp/Makefile:490	Must remake target `config.h'.
Invoking recipe from Makefile:491 to update target `config.h'.
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if test ! -f config.h; then \
  rm -f stamp-h1; \
  /tmp/remake/./remake  stamp-h1; \
else :; fi
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

++ (/tmp/remake/Makefile:490)
config.h
remake<2>

Before the location we now have two pluses, ++. This means that the code shown above in between ##>>>>... and ##<<<<... is about to be run.

If you want the full details about a target, config.h.in at this point in time, one can use the target (Target) command:

remake<4> target

config.h: stamp-h1
#  Implicit rule search has not been done.
#  Implicit/static pattern stem: `'
#  Last modified 2011-03-21 18:10:08
#  File has not been updated.
# automatic
# @ := config.h
# automatic
# % :=
# automatic
# * :=
# automatic
# + := stamp-h1
# automatic
# | :=
# automatic
# < := stamp-h1
# automatic
# ^ := stamp-h1
# automatic
# ? := stamp-h1
#  commands to execute (from `Makefile', line 489):
	@if test ! -f $@; then \
	rm -f stamp-h1; \
	$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
	else :; fi

I could have gotten the same output explicitly giving a target name such as target config.h, or used the GNU Make automatic variable name @, e.g. target @.

And we don’t have to be stopped on a target to get information about a target:

remake<4> target Makefile
Makefile: Makefile.in config.status
#  Precious file (prerequisite of .PRECIOUS).
#  Implicit rule search has not been done.
#  Implicit/static pattern stem: `'
#  Last modified 2011-03-25 17:57:09
#  File has been updated.
#  Successfully updated.
# automatic
#  := Makefile
# automatic
# % :=
# automatic
# * :=
# automatic
# + := Makefile.in config.status
# automatic
# | :=
# automatic
# < := Makefile.in
# automatic
# ^ := Makefile.in config.status
# automatic
# ? :=
#  commands to execute (from `Makefile', line 470):
	@case '$?' in \
	*config.status*) \
	echo ' $(SHELL) ./config.status'; \
	$(SHELL) ./config.status;; \
	*) \
	echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
	cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
	esac;

However information may change depending on where remake is. In particular note that for target config.h we see “File has not been updated”, while for target Makefile, we get “File has been updated”.

This means that we are finished with target Makefile, but not target config.h.


Next: , Previous: , Up: Sample Sessions   [Contents][Index]