Cthulhu
0.2.10
Cthulhu compiler collection
unwind.c
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-3.0-only
2
3
#include "
backtrace/backtrace.h
"
4
#include <stdio.h>
5
6
#define UNW_LOCAL_ONLY
7
#include <unwind.h>
8
9
static
unw_context_t gContext;
10
11
void
bt_init
(
void
)
12
{
13
unw_getcontext(&gContext);
14
}
15
16
void
bt_update
(
void
)
17
{
18
19
}
20
21
STA_DECL
22
const
char
*
bt_backend
(
void
)
23
{
24
return
"libunwind"
;
25
}
26
27
void
bt_read_inner
(
bt_trace_t
callback,
void
*user)
28
{
29
unw_cursor_t cursor;
30
unw_word_t ip, sp;
31
32
unw_init_local(&cursor, &gContext);
33
34
while
(unw_step(&cursor) > 0)
35
{
36
unw_get_reg(&cursor, UNW_REG_IP, &ip);
37
unw_get_reg(&cursor, UNW_REG_SP, &sp);
38
39
bt_address_t
frame = ip;
40
41
callback(frame, &frame);
42
}
43
}
44
45
bt_resolve_t
bt_resolve_inner
(
bt_address_t
frame,
bt_symbol_t
*symbol)
46
{
47
text_t
name = symbol->
name
;
48
(void)snprintf(name.text, name.
length
,
"0x%"
PRIxPTR, frame);
49
50
return
eResolveNothing
;
51
}
backtrace.h
STA_DECL
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
bt_init
void bt_init(void)
initialize the backtrace backend
Definition:
unwind.c:11
bt_address_t
uint_least64_t bt_address_t
an address of a symbol
Definition:
backtrace.h:26
bt_trace_t
void(* bt_trace_t)(bt_address_t frame, void *user)
user callback for bt_read
Definition:
backtrace.h:74
bt_resolve_t
bt_resolve_t
how much of a frame was reconstructed
Definition:
backtrace.h:47
bt_update
void bt_update(void)
update the loaded module cache
Definition:
unwind.c:16
bt_backend
STA_DECL const char * bt_backend(void)
get the backtrace backend name
Definition:
unwind.c:22
eResolveNothing
@ eResolveNothing
nothing was resolved
Definition:
backtrace.h:49
bt_symbol_t
a symbol
Definition:
backtrace.h:33
bt_symbol_t::name
text_t name
a buffer to hold the name
Definition:
backtrace.h:39
text_t
a range of text
Definition:
text.h:14
text_t::length
size_t length
the number of characters in the text
Definition:
text.h:19
bt_resolve_inner
bt_resolve_t bt_resolve_inner(bt_address_t frame, bt_symbol_t *symbol)
Definition:
unwind.c:45
bt_read_inner
void bt_read_inner(bt_trace_t callback, void *user)
Definition:
unwind.c:27
common
backtrace
src
unwind.c
Generated by
1.9.1