瀏覽代碼

[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 年之前
父節點
當前提交
5430465185
共有 2 個檔案被更改,包括 29 行新增0 行删除
  1. 27
    0
      src/Makefile.housekeeping
  2. 2
    0
      src/include/ipxe/profile.h

+ 27
- 0
src/Makefile.housekeeping 查看文件

@@ -747,6 +747,33 @@ include/assert.h : $(ASSERT_LIST)
747 747
 
748 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 777
 # These files use .incbin inline assembly to include a binary file.
751 778
 # Unfortunately ccache does not detect this dependency and caches
752 779
 # builds even when the binary file has changed.

+ 2
- 0
src/include/ipxe/profile.h 查看文件

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

Loading…
取消
儲存