Subject: Re: bug#78221: 31.0.50; Improving *-change-functions notifications

From: Alan Mackenzie <[email-masked]>
Date: Sun, 4 May 2025 17:05:29 +0000

Hello, Stefan.

On Sun, May 04, 2025 at 11:27:23 -0400, Stefan Monnier wrote:
> > The right tool to find these is cflow, combined with grep and awk (or
> > python or perl or whatever) to search and filter cflow's output.  I've
> > used these before.

> Do you happen to remember the magic incantation to let `cflow` process
> our sources correctly?  I tried the rule below and the errors file
> suggests that the preprocessing is done correctly (it's full of
> complaints but only about redefinitions), yet the result doesn't include
> any info about the functions called by `insert_1_both` or
> `Fput_text_property` (to take two randomly sampled cases of interest).

>From my notes from 2018, the command I used on cflow was:

$ cflow --reverse -b -i +s --cpp -I. -I../lib -I/usr/include/glib-2.0 \
  -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 buffer.c \
  callproc.c \
  casefiddle.c cmds.c coding.c decompress.c editfns.c emacs.c \
  fileio.c fns.c \
  indent.c insdel.c print.c process.c search.c textprop.c \
  xdisp.c xml.c 2> /dev/null > ~/cflow.20180102b.txt.

I no longer remember what the options mean, but the files I scanned were
those containing calls to insdel.c's externally visible functions.

I later analysed cflow.20180102b.txt with an elisp script, which I still
have, and could send to you if you're interested.  (It's 125 lines long,
but poorly commented.)  This script scanned the cflow output,
recursively finding callers (direct and indirect) of
signal_\(before\|after\)_change.

>         Stefan

> diff --git a/src/Makefile.in b/src/Makefile.in
> index e4fc2fef711..2c7aa92f9b9 100644
> --- a/src/Makefile.in
> +++ b/src/Makefile.in
> @@ -699,6 +699,18 @@ MAKE_PDUMPER_FINGERPRINT =
>  MAKE_PDUMPER_FINGERPRINT =
>  endif
 
> +cgraph.cflow:
> +	cflow --all --brief --cpp='$(CC) -E $(ALL_CFLAGS)' \
> +	    $(ALLOBJS:.o=.c) 				   \
> +	    >$@ 2>$@.errors
> +
> +cgraph-rev.cflow:
> +	cflow --reverse --all --brief --cpp='$(CC) -E $(ALL_CFLAGS)' \
> +	    $(ALLOBJS:.o=.c) 					     \
> +	    >$@ 2>$@.errors
> +
> +flowcharts: cgraph-rev.cflow cgraph.cflow
> +
>  ## We have to create $(etc) here because init_cmdargs tests its
>  ## existence when setting Vinstallation_directory (FIXME?).
>  ## This goes on to affect various things, and the emacs binary fails

-- 
Alan Mackenzie (Nuremberg, Germany).