Browse Source

[profile] Allow profiling to be globally enabled or disabled

As with assertions, profiling is enabled for objects built with any
debug level (including an explicit debug level of zero).

Allow profiling to be globally enabled or disabled by adding PROFILE=1
or PROFILE=0 respectively to the build command line.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
5430465185
2 changed files with 29 additions and 0 deletions
  1. 27
    0
      src/Makefile.housekeeping
  2. 2
    0
      src/include/ipxe/profile.h

+ 27
- 0
src/Makefile.housekeeping View File

747
 
747
 
748
 .PRECIOUS : include/assert.h
748
 .PRECIOUS : include/assert.h
749
 
749
 
750
+# (Single-element) list of profiling configuration
751
+#
752
+PROFILE_LIST := $(BIN)/.profile.list
753
+ifeq ($(wildcard $(PROFILE_LIST)),)
754
+PROFILE_OLD := <invalid>
755
+else
756
+PROFILE_OLD := $(shell cat $(PROFILE_LIST))
757
+endif
758
+ifneq ($(PROFILE_OLD),$(PROFILE))
759
+$(shell $(ECHO) "$(PROFILE)" > $(PROFILE_LIST))
760
+endif
761
+
762
+$(PROFILE_LIST) : $(MAKEDEPS)
763
+
764
+VERYCLEANUP += $(PROFILE_LIST)
765
+
766
+# Profiling configuration
767
+#
768
+ifneq ($(PROFILE),)
769
+CFLAGS	+= -DPROFILING=$(PROFILE)
770
+endif
771
+
772
+include/ipxe/profile.h : $(PROFILE_LIST)
773
+	$(Q)$(TOUCH) $@
774
+
775
+.PRECIOUS : include/ipxe/profile.h
776
+
750
 # These files use .incbin inline assembly to include a binary file.
777
 # These files use .incbin inline assembly to include a binary file.
751
 # Unfortunately ccache does not detect this dependency and caches
778
 # Unfortunately ccache does not detect this dependency and caches
752
 # builds even when the binary file has changed.
779
 # builds even when the binary file has changed.

+ 2
- 0
src/include/ipxe/profile.h View File

12
 #include <bits/profile.h>
12
 #include <bits/profile.h>
13
 #include <ipxe/tables.h>
13
 #include <ipxe/tables.h>
14
 
14
 
15
+#ifndef PROFILING
15
 #ifdef NDEBUG
16
 #ifdef NDEBUG
16
 #define PROFILING 0
17
 #define PROFILING 0
17
 #else
18
 #else
18
 #define PROFILING 1
19
 #define PROFILING 1
19
 #endif
20
 #endif
21
+#endif
20
 
22
 
21
 /**
23
 /**
22
  * A data structure for storing profiling information
24
  * A data structure for storing profiling information

Loading…
Cancel
Save