From 33cec99e963a8cb3ad49996d26003fa9fab1ba23 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 4 Sep 2018 23:24:19 -0400 Subject: [PATCH] Fix: tests: missing frame pointer for callstack test on some compiler MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- .../gen-syscall-events-callstack/Makefile.am | 2 +- .../gen-syscall-events-callstack.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) 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(); -- 2.34.1