zephyr/tests/arch/common/stack_unwind/src/main.c
Yong Cong Sin b8b98c2c29 tests: arch: common: add stack_unwind test
Added test for archs that support it. It triggers an exception
and verify that the fatal message has stack unwind info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-04-20 13:54:43 -04:00

40 lines
476 B
C

/*
* Copyright (c) 2024 Meta
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <stdbool.h>
#include <zephyr/kernel.h>
static void func1(int a);
static void func2(int a);
static void func2(int a)
{
printf("%d: %s\n", a, __func__);
if (a >= 5) {
k_oops();
}
func1(a + 1);
}
static void func1(int a)
{
printf("%d: %s\n", a, __func__);
func2(a + 1);
}
int main(void)
{
printf("Hello World! %s\n", CONFIG_BOARD);
func1(1);
return 0;
}