From: Francis Deslauriers Date: Wed, 5 Sep 2018 03:24:19 +0000 (-0400) Subject: Fix: tests: missing frame pointer for callstack test on some compiler X-Git-Tag: v2.12.0-rc1~822 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=51c2fb6c453e66de5f2552569daa490a4f02a4fd;ds=sidebyside Fix: tests: missing frame pointer for callstack test on some compiler 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 Signed-off-by: Jérémie Galarneau --- diff --git a/tests/utils/testapp/gen-syscall-events-callstack/Makefile.am b/tests/utils/testapp/gen-syscall-events-callstack/Makefile.am index a62d16451..4d171ba80 100644 --- a/tests/utils/testapp/gen-syscall-events-callstack/Makefile.am +++ b/tests/utils/testapp/gen-syscall-events-callstack/Makefile.am @@ -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 diff --git a/tests/utils/testapp/gen-syscall-events-callstack/gen-syscall-events-callstack.c b/tests/utils/testapp/gen-syscall-events-callstack/gen-syscall-events-callstack.c index 48210fab0..26c10c83f 100644 --- a/tests/utils/testapp/gen-syscall-events-callstack/gen-syscall-events-callstack.c +++ b/tests/utils/testapp/gen-syscall-events-callstack/gen-syscall-events-callstack.c @@ -34,9 +34,15 @@ * 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();