--- .gitignore | 2 ++ Makefile.am | 54 +++++++++++++++++++++++++++++++++--- cflow.rc | 16 +++++++++++ src/.cscope_rebuild_commands | 1 + src/main.c | 5 ++++ src/myMakeLog.c | 31 +++++++++++++++++++++ src/myMakeLog.h | 12 ++++++++ 7 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 cflow.rc create mode 100644 src/.cscope_rebuild_commands create mode 100644 src/myMakeLog.c create mode 100644 src/myMakeLog.h
diff --git a/.gitignore b/.gitignore index cf4109d5..9288f9f5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ TAGS GPATH GRTAGS GTAGS +make.cflow +make.rcflow .*cache .*gdbinit .gdb_history diff --git a/Makefile.am b/Makefile.am index 096ff661..61522ed8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,10 +34,11 @@ make_SRCS = src/ar.c src/arscan.c src/commands.c src/commands.h \ src/getopt.h src/getopt1.c src/gettext.h src/guile.c \ src/hash.c src/hash.h src/implicit.c src/job.c src/job.h \ src/load.c src/loadapi.c src/main.c src/makeint.h src/misc.c \ - src/mkcustom.h src/os.h src/output.c src/output.h src/read.c \ - src/remake.c src/rule.c src/rule.h src/shuffle.h src/shuffle.c \ - src/signame.c src/strcache.c src/variable.c src/variable.h \ - src/version.c src/vpath.c src/warning.c src/warning.h + src/mkcustom.h src/myMakeLog.c src/os.h src/output.c \ + src/output.h src/read.c src/remake.c src/rule.c src/rule.h \ + src/shuffle.h src/shuffle.c src/signame.c src/strcache.c \ + src/variable.c src/variable.h src/version.c src/vpath.c \ + src/warning.c src/warning.h w32_SRCS = src/w32/pathstuff.c src/w32/w32os.c src/w32/compat/dirent.c \ src/w32/compat/posixfcn.c src/w32/include/dirent.h \ @@ -209,6 +210,51 @@ check-regression: tests/config-flags.pm echo "Can't find the $(PACKAGE_NAME) test suite ($(top_srcdir)/tests)."; \ fi +# Without --brief reverse graph blows up to at least 20G and forward graph is +# pretty huge also so that's sort of mandatory +CFLOW_MANDATORY_FLAGS = --brief + +# It might be desireable to change this, but it gives best looking output IMO: +CFLOW_FLAGS = --level 'begin=' --level '0= ' --level '1=| ' --level end0='| ' --level end1='\\ ' --omit-arguments --omit-symbol-names -i x +# One might not want -i x to the above to try to see users of variables, I'm +# not sure it's really reliable enough to be worthwhile. Maybe good old grep +# and then using syntax folding to quickly figure out which function each +# reference is in is better for that. -i _ can be used to not avoid symbols +# starting with _. + +# These are common to both call and callee graph building: +CFLOW_COMMON_FLAGS = $(CFLOW_MANDATORY_FLAGS) $(CFLOW_FLAGS) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) + +# Presumably other modern automake setups have something like this around: +make_CFLOW_INPUT=$(make_SRCS) + +# Ideas for more improvements: +# +# * Filter (with perl probably) all function entries that don't have a source +# location. They're probably all library function calls and they're likely +# not of interest. Note that function entries can be distinguished fromn +# variables by the presence of (). +# +# * A version with source locations removed (probably with perl) +# +# * An interface to interogate (e.g. show only tree for or involving a +# partigular function). +# +# * Support easy createion of version from cflow without -i x +# +# * If appropriate don't show noise () when not doing -i x +# +# * Make variables or something to drive the above as appropriate. +# + +make.cflow: $(make_CFLOW_INPUT) cflow.rc Makefile + CFLOWRC=$(top_srcdir)/cflow.rc \ + cflow -omake.cflow $(CFLOW_COMMON_FLAGS) $(make_CFLOW_INPUT) +make.rcflow: $(make_CFLOW_INPUT) cflow.rc Makefile + CFLOWRC=$(top_srcdir)/cflow.rc \ + cflow -omake.rcflow --reverse $(CFLOW_COMMON_FLAGS) $(make_CFLOW_INPUT) # --------------- Maintainer's Section diff --git a/cflow.rc b/cflow.rc new file mode 100644 index 00000000..c02f411d --- /dev/null +++ b/cflow.rc @@ -0,0 +1,16 @@ +# As advised in the manual for working with GNU sources: +--symbol __inline:=inline +--symbol __inline__:=inline +--symbol __const__:=const +--symbol __const:=const +--symbol __restrict:=restrict +--symbol __extension__:qualifier +--symbol __attribute__:wrapper +--symbol __asm__:wrapper +--symbol __nonnull:wrapper +--symbol __wur:wrapper + +# Hack because cflow gets confused by integer literals with e.g. L, UL suffixes +# (there are probably more of these that should be added): +--symbol L:keyword +--symbol UL:keyword diff --git a/src/.cscope_rebuild_commands b/src/.cscope_rebuild_commands new file mode 100644 index 00000000..1b08bea8 --- /dev/null +++ b/src/.cscope_rebuild_commands @@ -0,0 +1 @@ +cscope -b -q -R diff --git a/src/main.c b/src/main.c index 6a129768..a92b2ace 100644 --- a/src/main.c +++ b/src/main.c @@ -32,6 +32,8 @@ this program. If not, see <https://www.gnu.org/licenses/>. */ # include <fcntl.h> #endif +#include "myMakeLog.h" + #if MK_OS_VMS int vms_use_mcr_command = 0; int vms_always_use_cmd_file = 0; @@ -1210,6 +1212,9 @@ main (int argc, char **argv, char **envp) no_default_sh_exe = 1; #endif + mLInit (); + mL ("HI THERE"); + initialize_variable_output (); /* Useful for attaching debuggers, etc. */ diff --git a/src/myMakeLog.c b/src/myMakeLog.c new file mode 100644 index 00000000..6cbd1963 --- /dev/null +++ b/src/myMakeLog.c @@ -0,0 +1,31 @@ + +#include <assert.h> + +#include "myMakeLog.h" + +static FILE *mml = NULL; + +void +mLInit (void) +{ + mml = fopen("/tmp/myMakeLog", "a"); + assert (mml != NULL); +} + +void +mL (char const *format, ...) +{ + va_list args; + int return_code; + + assert (mml != NULL); + + va_start (args, format); + vfprintf (mml, format, args); + va_end (args); + + fprintf (mml, "\n"); + + return_code = fflush (mml); + assert (return_code == 0); +} diff --git a/src/myMakeLog.h b/src/myMakeLog.h new file mode 100644 index 00000000..a2db09e2 --- /dev/null +++ b/src/myMakeLog.h @@ -0,0 +1,12 @@ + +#include <stdarg.h> +#include <stdio.h> + +void +mLInit (void); + +void +mL (const char *format, ...) __attribute__((format(printf, 1, 2))); + +#define mCP() \ + mL ("%s:%i: hit checkpoint (in function %s)", __FILE__, __LINE__, __func__) -- 2.43.0