Skip to content

Commit 9ee0bc9

Browse files
committed
tests/stack_unwind: Avoid inlining and tail-calls
We want the stack trace to show the correct nesting of functions, so we need to prevent the compiler from in-lining functions or performing tail-call optimizations. Add __noinline to prevent inlining. Add another printf in each function to avoid tail calls. Signed-off-by: Keith Packard <[email protected]>
1 parent 670ccab commit 9ee0bc9

File tree

1 file changed

+4
-2
lines changed
  • tests/arch/common/stack_unwind/src

1 file changed

+4
-2
lines changed

tests/arch/common/stack_unwind/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
static void func1(int a);
1313
static void func2(int a);
1414

15-
static void func2(int a)
15+
static void __noinline func2(int a)
1616
{
1717
printf("%d: %s\n", a, __func__);
1818

@@ -21,12 +21,14 @@ static void func2(int a)
2121
}
2222

2323
func1(a + 1);
24+
printf("bottom %d: %s\n", a, __func__);
2425
}
2526

26-
static void func1(int a)
27+
static void __noinline func1(int a)
2728
{
2829
printf("%d: %s\n", a, __func__);
2930
func2(a + 1);
31+
printf("bottom %d: %s\n", a, __func__);
3032
}
3133

3234
int main(void)

0 commit comments

Comments
 (0)