summaryrefslogtreecommitdiff
path: root/tests/memtest/thumb.cpp
blob: a70f4c3b947c19a065e4ab2d69bf0e1b0a9004ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <unwind.h>

extern "C" void arm_function_3(int*p);
extern "C" void thumb_function_1(int*p);
extern "C" void thumb_function_2(int*p);

extern "C" _Unwind_Reason_Code trace_function(_Unwind_Context *context, void *arg)
{
    int i = 0;
    printf("0x%x\n", _Unwind_GetIP(context));
    fflush(stdout);
    return _URC_NO_REASON;
}

void thumb_function_1(int*p)
{
    int a = 0;
    arm_function_3(&a);
}

void thumb_function_2(int*p)
{
    int a = 0;
    printf("unwinding...\n");
    _Unwind_Backtrace(trace_function, (void*)"backtrace!");
}