-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathstacktrace-common.h
More file actions
69 lines (55 loc) · 2.31 KB
/
Copy pathstacktrace-common.h
File metadata and controls
69 lines (55 loc) · 2.31 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef NETDATA_STACKTRACE_COMMON_H
#define NETDATA_STACKTRACE_COMMON_H 1
#include "libnetdata/libnetdata.h"
#include "stacktrace.h"
#include "../libjudy/judyl-typed.h"
#define NO_STACK_TRACE_PREFIX STACK_TRACE_INFO_PREFIX "stack trace is not available, "
#if defined(HAVE_LIBBACKTRACE)
#include "backtrace-supported.h"
#if BACKTRACE_SUPPORTED == 1
#define USE_LIBBACKTRACE 1
#endif
#endif
#if !defined(USE_LIBBACKTRACE) && defined(HAVE_LIBUNWIND)
#define USE_LIBUNWIND 1
#endif
#if !defined(USE_LIBBACKTRACE) && !defined(USE_LIBUNWIND) && defined(HAVE_BACKTRACE)
#define USE_BACKTRACE 1
#endif
#if !defined(USE_LIBBACKTRACE) && !defined(USE_LIBUNWIND) && !defined(USE_BACKTRACE) && !defined(HAVE_BACKTRACE)
#define USE_NOTRACE 1
#endif
// The structure for stacktrace storage
struct stacktrace {
uint64_t hash; // Hash of the stack trace
char *text; // Text representation (cached, lazy-initialized)
int frame_count; // Number of frames
void *frames[1]; // Variable-length array of frame pointers
};
// Cache for storing stack traces
DEFINE_JUDYL_TYPED(STACKTRACE, struct stacktrace *);
extern STACKTRACE_JudyLSet stacktrace_cache;
extern SPINLOCK stacktrace_lock;
extern bool cache_initialized;
// Filter names
extern const char *signal_handler_function;
extern const char *auxiliary_functions[];
extern const char *logging_functions[];
// Thread-local storage for root cause
extern __thread char root_cause_function[48];
// Common helper functions
void stacktrace_cache_init(void);
struct stacktrace *stacktrace_create(int num_frames);
bool stacktrace_is_auxiliary_function(const char *function);
bool stacktrace_is_logging_function(const char *function);
bool stacktrace_contains_logging_function(const char *text);
bool stacktrace_is_netdata_function(const char *function, const char *filename);
bool stacktrace_is_signal_handler_function(const char *function);
bool stacktrace_contains_signal_handler_function(const char *text);
void stacktrace_keep_first_root_cause_function(const char *function);
// Implementation-specific declarations
void impl_stacktrace_init(void);
int impl_stacktrace_get_frames(void **frames, int max_frames, int skip_frames);
void impl_stacktrace_to_buffer(STACKTRACE trace, BUFFER *wb);
#endif /* NETDATA_STACKTRACE_COMMON_H */