stacktrace: use referenced context
#include <fluent-bit/flb_info.h>
/* Libbacktrace support */
-#if defined(FLB_HAVE_LIBBACKTRACE) && defined(FLB_DUMP_STACKTRACE)
+#if defined(FLB_HAVE_LIBBACKTRACE)
#include <backtrace.h>
#include <backtrace-supported.h>
@@ -34,8 +34,6 @@ struct flb_stacktrace {
int line;
};
-extern struct flb_stacktrace flb_st;
-
static void flb_stacktrace_error_callback(void *data,
const char *msg, int errnum)
{
@@ -60,21 +58,18 @@ static int flb_stacktrace_print_callback(void *data, uintptr_t pc,
return 0;
}
-static inline void flb_stacktrace_init(char *prog)
+static inline void flb_stacktrace_init(char *prog, struct flb_stacktrace *st)
{
- memset(&flb_st, '\0', sizeof(struct flb_stacktrace));
- flb_st.state = backtrace_create_state(prog,
+ memset(st, '\0', sizeof(struct flb_stacktrace));
+ st->state = backtrace_create_state(prog,
BACKTRACE_SUPPORTS_THREADS,
flb_stacktrace_error_callback, NULL);
}
-static inline void flb_stacktrace_print()
+static inline void flb_stacktrace_print(struct flb_stacktrace *st)
{
- struct flb_stacktrace *ctx;
-
- ctx = &flb_st;
- backtrace_full(ctx->state, 3, flb_stacktrace_print_callback,
- flb_stacktrace_error_callback, ctx);
+ backtrace_full(st->state, 3, flb_stacktrace_print_callback,
+ flb_stacktrace_error_callback, st);
}
#endif
