diff --git a/Makefile b/Makefile index 9cc37706..9d5900a9 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,6 @@ override TESTFLAGS += -b override TESTFLAGS += $(filter -j%,$(MAKEFLAGS)) ifdef VERBOSE override TESTFLAGS += -v -override CALLSFLAGS += -v override CODEFLAGS += -v override DATAFLAGS += -v override STACKFLAGS += -v @@ -77,7 +76,6 @@ override TESTFLAGS += --coverage endif ifdef BUILDDIR override TESTFLAGS += --build-dir="$(BUILDDIR:/=)" -override CALLSFLAGS += --build-dir="$(BUILDDIR:/=)" override CODEFLAGS += --build-dir="$(BUILDDIR:/=)" override DATAFLAGS += --build-dir="$(BUILDDIR:/=)" override STACKFLAGS += --build-dir="$(BUILDDIR:/=)" @@ -108,10 +106,6 @@ size: $(OBJ) tags: $(CTAGS) --totals --c-types=+p $(shell find -H -name '*.h') $(SRC) -.PHONY: calls -calls: $(CGI) - ./scripts/calls.py $^ $(CALLSFLAGS) - .PHONY: test_runner test_runner: $(BUILDDIR)runners/test_runner @@ -172,19 +166,14 @@ $(BUILDDIR)lfs.csv: $(OBJ) $(CGI) $(BUILDDIR)runners/test_runner: $(TEST_TAOBJ) $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@ -$(BUILDDIR)%.o: %.c - $(CC) -c -MMD $(CFLAGS) $< -o $@ +# our main build rule generates .o, .d, and .ci files, the latter +# used for stack analysis +$(BUILDDIR)%.o $(BUILDDIR)%.ci: %.c + $(CC) -c -MMD -fcallgraph-info=su $(CFLAGS) $< -o $(BUILDDIR)$*.o $(BUILDDIR)%.s: %.c $(CC) -S $(CFLAGS) $< -o $@ -# gcc depends on the output file for intermediate file names, so -# we can't omit to .o output. We also need to serialize with the -# normal .o rule because otherwise we can end up with multiprocess -# problems with two instances of gcc modifying the same .o -$(BUILDDIR)%.ci: %.c | $(BUILDDIR)%.o - $(CC) -c -MMD -fcallgraph-info=su $(CFLAGS) $< -o $| - $(BUILDDIR)%.a.c: %.c ./scripts/explode_asserts.py $< -o $@ diff --git a/scripts/stack.py b/scripts/stack.py index 6cdfc46f..b0894b84 100755 --- a/scripts/stack.py +++ b/scripts/stack.py @@ -384,6 +384,11 @@ def main(**args): print_entries(by='name') print_totals() + # catch recursion + if args.get('error_on_recursion') and any( + m.isinf(limit) for _, _, _, limit, _ in results): + sys.exit(2) + if __name__ == "__main__": import argparse @@ -424,6 +429,8 @@ if __name__ == "__main__": help="Show file-level calls.") parser.add_argument('-Y', '--summary', action='store_true', help="Only show the total stack size.") + parser.add_argument('-e', '--error-on-recursion', action='store_true', + help="Error if any functions are recursive.") parser.add_argument('--build-dir', help="Specify the relative build directory. Used to map object files \ to the correct source files.")