util: Force emission of stack frame in stack unit test
The `capture_not_overwritten` unit test captures and compares two
backtraces -- one from inside a call to `func_c` and one outside -- and
confirms that they are not identical. That is, that `func_c` is in the
backtrace.
On 32-bit x86, without `-fno-omit-frame-pointer`, the function will not
emit a stack frame. As a result, the unit test fails.
The fix is to compile `func_c` with the flag `-fno-omit-frame-pointer`
to prevent the compiler from optimizing out the stack frame which is
otherwise unneeded.
Bug: https://bugs.gentoo.org/823774
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4091
Fixes: d0d14f3f64 ("util: Add unit test for stack backtrace caputure")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30622>
This commit is contained in:
@@ -49,7 +49,8 @@ func_b(void)
|
||||
debug_backtrace_dump(backtrace, 16);
|
||||
}
|
||||
|
||||
static void ATTRIBUTE_NOINLINE
|
||||
/* This function must emit a stack frame for the unit test to work */
|
||||
static void ATTRIBUTE_NOINLINE ATTRIBUTE_OPTIMIZE("no-omit-frame-pointer")
|
||||
func_c(struct debug_stack_frame *frames)
|
||||
{
|
||||
debug_backtrace_capture(frames, 0, 16);
|
||||
|
||||
Reference in New Issue
Block a user