55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/*
* Define HAVE_DWARF_EXCEPTIONS if HAVE_SEH_EXCEPTIONS is defined, as SEH
* exceptions are implemented as a wrapper around DWARF exceptions.
*/
#ifdef HAVE_SEH_EXCEPTIONS
# define HAVE_DWARF_EXCEPTIONS
#endif
#ifdef HAVE_DWARF_EXCEPTIONS
struct _Unwind_Context;
typedef enum {
_URC_OK = 0,
_URC_END_OF_STACK = 5
}_Unwind_Reason_Code;
struct backtrace_ctx {
void **backtrace;
uint8_t i;
};
extern _Unwind_Reason_Code _Unwind_Backtrace(
_Unwind_Reason_Code(*)(struct _Unwind_Context*, void*), void*);
# ifdef OF_ARM
extern int _Unwind_VRS_Get(struct _Unwind_Context*, int, uint32_t, int, void*);
# else
extern uintptr_t _Unwind_GetIP(struct _Unwind_Context*);
# endif
#endif
#if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS)
static of_mutex_t mutex;
static void __attribute__((__constructor__))
|
>
>
>
>
|
|
|
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/*
* Define HAVE_DWARF_EXCEPTIONS if HAVE_SEH_EXCEPTIONS is defined, as SEH
* exceptions are implemented as a wrapper around DWARF exceptions.
*/
#ifdef HAVE_SEH_EXCEPTIONS
# define HAVE_DWARF_EXCEPTIONS
#endif
#if defined(OF_ARM) && !defined(__ARM_DWARF_EH__)
# define HAVE_ARM_EHABI_EXCEPTIONS
#endif
#ifdef HAVE_DWARF_EXCEPTIONS
struct _Unwind_Context;
typedef enum {
_URC_OK = 0,
_URC_END_OF_STACK = 5
}_Unwind_Reason_Code;
struct backtrace_ctx {
void **backtrace;
uint8_t i;
};
extern _Unwind_Reason_Code _Unwind_Backtrace(
_Unwind_Reason_Code(*)(struct _Unwind_Context*, void*), void*);
# ifndef HAVE_ARM_EHABI_EXCEPTIONS
extern uintptr_t _Unwind_GetIP(struct _Unwind_Context*);
# else
extern int _Unwind_VRS_Get(struct _Unwind_Context*, int, uint32_t, int, void*);
# endif
#endif
#if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS)
static of_mutex_t mutex;
static void __attribute__((__constructor__))
|
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
#ifdef HAVE_DWARF_EXCEPTIONS
static _Unwind_Reason_Code
backtrace_callback(struct _Unwind_Context *ctx, void *data)
{
struct backtrace_ctx *bt = data;
if (bt->i < OF_BACKTRACE_SIZE) {
# ifdef OF_ARM
uintptr_t ip;
_Unwind_VRS_Get(ctx, 0, 15, 0, &ip);
bt->backtrace[bt->i++] = (void*)(ip & ~1);
# else
bt->backtrace[bt->i++] = (void*)_Unwind_GetIP(ctx);
# endif
return _URC_OK;
}
return _URC_END_OF_STACK;
}
#endif
|
>
>
|
<
<
|
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
#ifdef HAVE_DWARF_EXCEPTIONS
static _Unwind_Reason_Code
backtrace_callback(struct _Unwind_Context *ctx, void *data)
{
struct backtrace_ctx *bt = data;
if (bt->i < OF_BACKTRACE_SIZE) {
# ifndef HAVE_ARM_EHABI_EXCEPTIONS
bt->backtrace[bt->i++] = (void*)_Unwind_GetIP(ctx);
# else
uintptr_t ip;
_Unwind_VRS_Get(ctx, 0, 15, 0, &ip);
bt->backtrace[bt->i++] = (void*)(ip & ~1);
# endif
return _URC_OK;
}
return _URC_END_OF_STACK;
}
#endif
|