Forráskód Böngészése

Add GCC instrumentation function (temporarily for analysis)

Instrumentation for #609 and others
See https://gcc.gnu.org/onlinedocs/gcc-4.5.1/gcc/Code-Gen-Options.html#index-finstrument_002dfunctions-2114
https://codingrelic.geekhold.com/2010/09/gcc-function-instrumentation.html
bel2125 7 éve
szülő
commit
43d1452a21
1 módosított fájl, 25 hozzáadás és 0 törlés
  1. 25 0
      src/civetweb.c

+ 25 - 0
src/civetweb.c

@@ -188,6 +188,31 @@ static void DEBUG_TRACE_FUNC(const char *func,
 #endif
 
 
+#if defined(__GNUC__) && defined(DEBUG)
+void __cyg_profile_func_enter(void *this_fn, void *call_site)
+    __attribute__((no_instrument_function));
+
+void __cyg_profile_func_exit(void *this_fn, void *call_site)
+    __attribute__((no_instrument_function));
+
+void
+__cyg_profile_func_enter(void *this_fn, void *call_site)
+{
+	if (this_fn != printf) {
+		printf("E %p %p\n", this_fn, call_site);
+	}
+}
+
+void
+__cyg_profile_func_exit(void *this_fn, void *call_site)
+{
+	if (this_fn != printf) {
+		printf("X %p %p\n", this_fn, call_site);
+	}
+}
+#endif
+
+
 #if !defined(IGNORE_UNUSED_RESULT)
 #define IGNORE_UNUSED_RESULT(a) ((void)((a) && 1))
 #endif