forked from SevenChords/CipesAtHome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstacktrace.h
39 lines (32 loc) · 1.24 KB
/
stacktrace.h
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
#ifndef STACKTRACE_H_
#define STACKTRACE_H_
#include <stdio.h>
#include "absl/base/port.h"
#include "internal/base_essentials.h"
#include "internal/base_assert.h"
#ifdef __cplusplus
extern "C" {
#endif
#if INCLUDE_STACK_TRACES
#ifndef STACK_TRACE_FRAMES
#define STACK_TRACE_FRAMES 40
#define WIN_MAX_STACK_TRACE_FRAMES 63
#endif
_CIPES_STATIC_ASSERT(STACK_TRACE_FRAMES < WIN_MAX_STACK_TRACE_FRAMES, "Windows can only fetch up to " _XSTR(WIN_MAX_STACK_TRACE_FRAMES) " frames at one, so keep this below that.");
ABSL_ATTRIBUTE_NOINLINE void printStackTraceF(FILE* f);
#else
ABSL_ATTRIBUTE_ALWAYS_INLINE inline void printStackTraceF(FILE* f) {}
#endif
#if INCLUDE_STACK_TRACES && _IS_WINDOWS
// Prepare to initialize anything that needs to be done to initialize stacktracing.
// Ideally this should only be called once per program, but will have logic to prevent multiple initializing from causing problems.
// Also, if you fail to call this method, then printStackTraceF will call it for you, but is much more likely to fail at that point
// as by then you are typically in an error condition.
void prepareStackTraces();
#else
ABSL_ATTRIBUTE_ALWAYS_INLINE inline void prepareStackTraces() {}
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* STACKTRACE_H_ */