[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Better Debugging

From: James L. Peterson
Subject: Better Debugging
Date: Wed, 17 Jan 2001 10:03:36 -0600

A major problem that I have with make is being able to debug the
makefiles.  I end up working on big projects that are supposed to
be for multiple platforms, so there are a lot of make variables
and thousands of lines of multiple makefiles.  My difficulty is
in seeing what everything expands to, so I can understand why
make is (or isn't) doing what it is doing.

The -d debug flag gives some information, but not a lot.  What
I would like to be able to see is:

(a) the values of all the variables
(b) what files are being included
(c) what the actual dependencies are

I've started trying to add this to the existing make-3.77 source.

I found the place where files are included, and the routine that
defines the values of variables, so I think I have (a) and (b).
Creating a dependency seems to be distributed in the code and I
haven't found all of them yet, but here is a start of what I've

I'm keying off the -d "debug_flag" variable.  I suppose a new
option (--explain-what-is-happening) could be added with a different
flag, but -d seems to be about right.

+ diff make-3.77/read.c make-debug/read.c
>             if (debug_flag)
>               {
>                 printf("INCLUDE %s (line %d in %s)\n", name, lineno, 
> filename);
>               }
>   if (debug_flag)
>     {
>       struct nameseq *f;
>       for (f=filenames; f != 0; f = f->next)
>       {
>         /* file name f->name depends on the list deps */
>         struct dep *d;
>         for (d=deps; d != 0; d = d->next)
>           {
>             printf("DEPENDS %s depends on %s (line %d in %s)\n", 
>                    f->name, d->name, lineno, filename);
>           }
>       }
>     }
+ diff make-3.77/variable.c make-debug/variable.c
>   if (debug_flag)
>     {
>       printf("DEFINE %.*s = %s\n", length, name, value);
>     }

Also, looking at the values of the variables that are defined,
it seems that it might help to also print the values of variables
after they are expanded -- I'm looking for that now.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]