Fix: tests: missing frame pointer for callstack test on some compiler
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 5 Sep 2018 03:24:19 +0000 (23:24 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 6 Sep 2018 15:26:55 +0000 (11:26 -0400)
The callstack testcase fails when the testapp is built with gcc 8. This
is because GCC8 may not emit frame pointers even when the
`-fno-omit-frame-pointer` is used.

To prevent that we manually mark these functions with optimization level
0.

On Clang we also need to include the `-mno-omit-leaf-frame-pointer` flag
along side with the existing `-fno-omit-frame-pointer` to ensure that
frame pointers are emitted. It's not clear if this incompatibility with
GCC is expected [1].

[1]: https://bugs.llvm.org/show_bug.cgi?id=9825

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/testapp/gen-syscall-events-callstack/Makefile.am
tests/utils/testapp/gen-syscall-events-callstack/gen-syscall-events-callstack.c

index a62d164515aa1247dae356d4b31f4959235f79cd..4d171ba80c70ed087642ccbd43f34c5b50aa9ccc 100644 (file)
@@ -1,5 +1,5 @@
 AM_CFLAGS += -I$(top_srcdir)/tests/utils/
-AM_CFLAGS += -fno-omit-frame-pointer
+AM_CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
 #  The feature called Position Independent Execution (PIE) may be enabled by
 #  default on some systems. Supporting this feature for this testapp would
 #  increase the complexity of the testcases using this testapp as it would make
index 48210fab07008553775f08522d0d4b9d7f996162..26c10c83f13978cde49f96a30e74d74bfd434e72 100644 (file)
  * events generated by our test process only.
  */
 
+#if defined(__clang__)
+#define nooptimization __attribute__((noinline)) __attribute__((optnone))
+#else
+#define nooptimization __attribute__((noinline)) __attribute__((optimize(0)))
+#endif
+
 volatile int val = 0;
 
-long __attribute__ ((noinline))
+long nooptimization
 my_gettid(void)
 {
     long ret;
@@ -62,20 +68,20 @@ my_gettid(void)
     return ret;
 }
 
-int __attribute__ ((noinline))
+int nooptimization
 fct_c(void)
 {
        return my_gettid();
 }
 
-int __attribute__ ((noinline))
+int nooptimization
 fct_b(void)
 {
        val += fct_c();
        return val;
 }
 
-int __attribute__ ((noinline))
+int nooptimization
 fct_a(void)
 {
        val += fct_b();
This page took 0.026197 seconds and 4 git commands to generate.