]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
build: Add menuselect options to facilitate code tracing and coverage
authorGeorge Joseph <gjoseph@sangoma.com>
Thu, 30 Oct 2025 12:55:49 +0000 (06:55 -0600)
committerGeorge Joseph <gjoseph@sangoma.com>
Tue, 4 Nov 2025 14:15:54 +0000 (14:15 +0000)
The following options have been added to the menuselect "Compiler Flags"
section...

CODE_COVERAGE: The ability to enable code coverage via the `--enable-coverage`
configure flag has existed for many years but changing it requires
re-running ./configure which is painfully slow.  With this commit, you can
now enable and disable it via menuselect. Setting this option adds the
`-ftest-coverage` and `-fprofile-arcs` flags on the gcc and ld command lines.
It also sets DONT_OPTIMIZE. Note: If you use the `--enable-coverage` configure
flag, you can't turn it off via menuselect so choose one method and stick to
it.

KEEP_FRAME_POINTERS: This option sets `-fno-omit-frame-pointers` on the gcc
command line which can facilitate debugging with 'gdb' and tracing with 'perf'.
Unlike CODE_COVERAGE, this option doesn't depend on optimization being
disabled.  It does however conflict with COMPILE_DOUBLE.

Makefile.rules
build_tools/cflags.xml

index d39640ee29c37d87cafa26f510d511aa0dff8098..7319a1a6bb3a417d02dbb117bf5043c2ba93d6d2 100644 (file)
@@ -82,17 +82,21 @@ ifeq ($(CC),gcc)
        endif
 endif
 
-ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no)
+ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(findstring CODE_COVERAGE,$(MENUSELECT_CFLAGS))$(findstring CODE_PROFILE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no)
     _ASTCFLAGS+=$(OPTIMIZE)
 else
     _ASTCFLAGS+=-O0
 endif
 
-ifeq ($(AST_CODE_COVERAGE),yes)
+ifeq ($(findstring CODE_COVERAGE,$(MENUSELECT_CFLAGS))$(AST_CODE_COVERAGE),no)
+    _ASTCFLAGS_COVERAGE=
+else
     _ASTCFLAGS_COVERAGE=-ftest-coverage -fprofile-arcs
     _ASTLDFLAGS+=-ftest-coverage -fprofile-arcs
-else
-    _ASTCFLAGS_COVERAGE=
+endif
+
+ifneq ($(findstring KEEP_FRAME_POINTERS,$(MENUSELECT_CFLAGS)),)
+    _ASTCFLAGS+=-fno-omit-frame-pointer
 endif
 
 ifeq ($(findstring $(CONFIG_CFLAGS),$(_ASTCFLAGS)),)
index 38a2683f96ad80d6af11a236b9c2134c375ee1bb..41d35e7757453ddb2cf7ac469756ec5cc55ab461 100644 (file)
@@ -5,6 +5,8 @@
                </member>
                <member name="COMPILE_DOUBLE" displayname="Pre-compile with optimizations to detect errors, then discard and recompile with DONT_OPTIMIZE.  Creates intermediate .i files">
                        <depend>DONT_OPTIMIZE</depend>
+                       <conflict>KEEP_FRAME_POINTERS</conflict>
+                       <conflict>CODE_COVERAGE</conflict>
                        <support_level>core</support_level>
                </member>
                <member name="DEBUG_THREADS" displayname="Enable Thread Debugging">
                        <support_level>core</support_level>
                        <defaultenabled>no</defaultenabled>
                </member>
+               <member name="KEEP_FRAME_POINTERS" displayname="Set -fno-omit-frame-pointers to Facilitate Debugging and Tracing with 'perf'">
+                       <conflict>COMPILE_DOUBLE</conflict>
+                       <support_level>core</support_level>
+               </member>
+               <member name="CODE_COVERAGE" displayname="Set -ftest-coverage -fprofile-arcs to Enable gcov Code Coverage">
+                       <support_level>extended</support_level>
+                       <depend>DONT_OPTIMIZE</depend>
+               </member>
+
        </category>