libwebsockets
Lightweight C library for HTML5 websockets
Toggle main menu visibility
Loading...
Searching...
No Matches
lws-backtrace.h
Go to the documentation of this file.
1
/*
2
* libwebsockets - small server side websockets and web server implementation
3
*
4
* Copyright (C) 2010 - 2022 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*/
24
36
37
typedef
struct
{
38
uintptr_t
st
[32];
39
uintptr_t
asize
;
40
41
uint8_t
sp
;
42
uint8_t
pre
;
43
uint8_t
post
;
44
}
lws_backtrace_info_t
;
45
46
typedef
struct
{
47
uint8_t
*
comp
;
48
size_t
pos
;
49
size_t
len
;
50
}
lws_backtrace_comp_t
;
51
52
/*
53
* lws_backtrace() - init and fiull a backtrace struct
54
*
55
* \param si: the backtrace struct to populate
56
* \param pre: the number of call levels to snip from the top
57
* \param post: the number of call levels to snip from the bottom
58
*
59
* This describes the call stack into \p si. \p si doesn't need preparing
60
* before the call. \p pre levels of the call stack at the top will be snipped,
61
* this will usually want to be 1 or 2 to conceal the helpers that are making
62
* the call stack, such as lws_backtrace itself.
63
*
64
* \p post levels of the call stack at the bottom will be snipped, this is to
65
* conceal loaders or other machinery that was used to start your application,
66
* otherwise those entries will bloat all call stacks results on that platform.
67
*
68
* Returns 0 for success.
69
*/
70
LWS_VISIBLE
LWS_EXTERN
int
71
lws_backtrace
(
lws_backtrace_info_t
*si,
uint8_t
pre,
uint8_t
post);
72
73
/*
74
* lws_backtrace_compression_stream_init() - init and fiull a backtrace struct
75
*
76
* \param c: the backtrace compression struct
77
* \param comp: the buffer to take the compressed bytes
78
* \param comp_len: the number of bytes available at \p comp
79
*
80
* This initializes the caller's lws_backtrace_comp_t. Because it's expected
81
* the caller will want to put his own compressed data after the compressed
82
* backtrace, he is responsible for the compression context.
83
*/
84
LWS_VISIBLE
LWS_EXTERN
void
85
lws_backtrace_compression_stream_init
(
lws_backtrace_comp_t
*c,
86
uint8_t
*comp,
size_t
comp_len);
87
88
/*
89
* lws_backtrace_compression_stream() - add bitfields to compression stream
90
*
91
* \param c: the backtrace compression context struct
92
* \param v: the bitfield to add to the stream
93
* \param bits: the number of bits of v to add
94
*
95
* This inserts bits from the LSB end of v to the compression stream.
96
*
97
* This is used by the backtrace compression, user code can use this to add
98
* its own bitfields into the compression stream after the compressed backtrace.
99
*
100
* User data should be added after, so that the backtrace can be processed even
101
* if the additional data is not understood by the processing script.
102
*
103
* Returns 0 for success or nonzero if ran out of compression output buffer.
104
*/
105
LWS_VISIBLE
LWS_EXTERN
int
106
lws_backtrace_compression_stream
(
lws_backtrace_comp_t
*c, uintptr_t v,
107
unsigned
int
bits);
108
109
/*
110
* lws_backtrace_compression_destream() - add bitfields to compression stream
111
*
112
* \param c: the backtrace compression context struct
113
* \param _v: pointer to take the bitfield result
114
* \param bits: the number of bits to bring out into _v
115
*
116
* This reads the compression stream and creates a bitfield from it in \p _v.
117
*
118
* Returns 0 for success (with \p _v set to the value), or nonzero if ran out
119
* of compression output buffer.
120
*/
121
LWS_VISIBLE
LWS_EXTERN
int
122
lws_backtrace_compression_destream
(
lws_backtrace_comp_t
*c, uintptr_t *_v,
123
unsigned
int
bits);
124
125
/*
126
* lws_backtrace_compress_backtrace() - compress backtrace si into c
127
*
128
* \param si: the backtrace struct to compress
129
* \param c: the backtrace compression context struct
130
*
131
* This compresses backtrace information acquired in \p si into the compression
132
* context \p c. It compresses first the call stack length and then each IP
133
* address in turn.
134
*
135
* Returns 0 for success.
136
*/
137
LWS_VISIBLE
LWS_EXTERN
int
138
lws_backtrace_compress_backtrace
(
lws_backtrace_info_t
*si,
139
lws_backtrace_comp_t
*c);
140
142
160
183
LWS_VISIBLE
LWS_EXTERN
void
184
lws_alloc_metadata_gen
(
size_t
size,
uint8_t
*comp,
size_t
comp_len,
size_t
*adj,
185
size_t
*cl);
186
206
LWS_VISIBLE
LWS_EXTERN
void
207
_lws_alloc_metadata_adjust
(
lws_dll2_owner_t
*active,
void
**v,
size_t
adj,
uint8_t
*comp,
unsigned
int
cl);
208
221
LWS_VISIBLE
LWS_EXTERN
void
222
_lws_alloc_metadata_trim
(
void
**ptr,
uint8_t
**comp,
uint16_t
*complen);
223
235
LWS_VISIBLE
LWS_EXTERN
int
236
lws_alloc_metadata_parse
(
lws_backtrace_info_t
*si,
const
uint8_t
*adjusted_alloc);
237
247
LWS_VISIBLE
LWS_EXTERN
int
248
lws_alloc_metadata_dump_stdout
(
struct
lws_dll2
*d,
void
*user);
249
265
LWS_VISIBLE
LWS_EXTERN
void
266
_lws_alloc_metadata_dump
(
lws_dll2_owner_t
*active,
lws_dll2_foreach_cb_t
cb,
267
void
*arg);
268
269
#if defined(LWS_WITH_ALLOC_METADATA_LWS)
270
/*
271
* Wrapper for _lws_alloc_metadata_dump() that uses the list owner that tracks
272
*
273
*/
274
LWS_VISIBLE
LWS_EXTERN
void
275
_lws_alloc_metadata_dump_lws
(
lws_dll2_foreach_cb_t
cb,
void
*arg);
276
#else
277
#define _lws_alloc_metadata_dump_lws(_a, _b)
278
#endif
279
lws_dll2_owner_t
struct lws_dll2_owner lws_dll2_owner_t
lws_dll2_foreach_cb_t
int(* lws_dll2_foreach_cb_t)(struct lws_dll2 *d, void *user)
Definition
lws-dll2.h:260
lws_dll2
Definition
lws-dll2.h:226
uint16_t
unsigned short uint16_t
Definition
libwebsockets.h:698
LWS_EXTERN
#define LWS_EXTERN
Definition
libwebsockets.h:296
uint8_t
unsigned char uint8_t
Definition
libwebsockets.h:699
LWS_VISIBLE
#define LWS_VISIBLE
Definition
libwebsockets.h:291
_lws_alloc_metadata_adjust
LWS_VISIBLE LWS_EXTERN void _lws_alloc_metadata_adjust(lws_dll2_owner_t *active, void **v, size_t adj, uint8_t *comp, unsigned int cl)
_lws_alloc_metadata_trim
LWS_VISIBLE LWS_EXTERN void _lws_alloc_metadata_trim(void **ptr, uint8_t **comp, uint16_t *complen)
lws_backtrace_comp_t::len
size_t len
Definition
lws-backtrace.h:49
lws_backtrace_info_t::post
uint8_t post
Definition
lws-backtrace.h:43
lws_backtrace_info_t::asize
uintptr_t asize
Definition
lws-backtrace.h:39
lws_backtrace_info_t::pre
uint8_t pre
Definition
lws-backtrace.h:42
_lws_alloc_metadata_dump_lws
#define _lws_alloc_metadata_dump_lws(_a, _b)
Definition
lws-backtrace.h:277
lws_backtrace_compression_stream
LWS_VISIBLE LWS_EXTERN int lws_backtrace_compression_stream(lws_backtrace_comp_t *c, uintptr_t v, unsigned int bits)
lws_backtrace_compression_destream
LWS_VISIBLE LWS_EXTERN int lws_backtrace_compression_destream(lws_backtrace_comp_t *c, uintptr_t *_v, unsigned int bits)
lws_backtrace_comp_t::pos
size_t pos
Definition
lws-backtrace.h:48
lws_backtrace_info_t::sp
uint8_t sp
Definition
lws-backtrace.h:41
lws_backtrace_info_t::st
uintptr_t st[32]
Definition
lws-backtrace.h:38
_lws_alloc_metadata_dump
LWS_VISIBLE LWS_EXTERN void _lws_alloc_metadata_dump(lws_dll2_owner_t *active, lws_dll2_foreach_cb_t cb, void *arg)
lws_alloc_metadata_parse
LWS_VISIBLE LWS_EXTERN int lws_alloc_metadata_parse(lws_backtrace_info_t *si, const uint8_t *adjusted_alloc)
lws_backtrace
LWS_VISIBLE LWS_EXTERN int lws_backtrace(lws_backtrace_info_t *si, uint8_t pre, uint8_t post)
lws_backtrace_comp_t::comp
uint8_t * comp
Definition
lws-backtrace.h:47
lws_alloc_metadata_gen
LWS_VISIBLE LWS_EXTERN void lws_alloc_metadata_gen(size_t size, uint8_t *comp, size_t comp_len, size_t *adj, size_t *cl)
lws_backtrace_compression_stream_init
LWS_VISIBLE LWS_EXTERN void lws_backtrace_compression_stream_init(lws_backtrace_comp_t *c, uint8_t *comp, size_t comp_len)
lws_alloc_metadata_dump_stdout
LWS_VISIBLE LWS_EXTERN int lws_alloc_metadata_dump_stdout(struct lws_dll2 *d, void *user)
lws_backtrace_compress_backtrace
LWS_VISIBLE LWS_EXTERN int lws_backtrace_compress_backtrace(lws_backtrace_info_t *si, lws_backtrace_comp_t *c)
lws_backtrace_comp_t
Definition
lws-backtrace.h:46
lws_backtrace_info_t
Definition
lws-backtrace.h:37
include
libwebsockets
lws-backtrace.h
Generated on
for libwebsockets by
1.18.0