2020-09-03 05:44:37 -07:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_LOG_BACKTRACE_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_LOG_BACKTRACE_H_
|
|
|
|
#include "libc/nexgen32e/stackframe.h"
|
2021-10-14 19:36:49 -07:00
|
|
|
#include "libc/runtime/memtrack.internal.h"
|
2020-11-25 08:19:00 -08:00
|
|
|
#include "libc/runtime/symbols.internal.h"
|
2020-09-03 05:44:37 -07:00
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
2021-10-14 19:36:49 -07:00
|
|
|
forceinline pureconst bool IsValidStackFramePointer(struct StackFrame *x) {
|
2022-06-12 11:47:20 -07:00
|
|
|
/* assumes __mmi_lock() is held */
|
2021-10-14 19:36:49 -07:00
|
|
|
return IsLegalPointer(x) && !((uintptr_t)x & 15) &&
|
|
|
|
(IsStaticStackFrame((uintptr_t)x >> 16) ||
|
2021-11-14 21:26:56 -08:00
|
|
|
IsOldStackFrame((uintptr_t)x >> 16) ||
|
|
|
|
/* lua coroutines need this */
|
|
|
|
IsMemtracked((uintptr_t)x >> 16, (uintptr_t)x >> 16));
|
2021-10-14 19:36:49 -07:00
|
|
|
}
|
|
|
|
|
2020-10-10 21:18:53 -07:00
|
|
|
void ShowBacktrace(int, const struct StackFrame *);
|
|
|
|
int PrintBacktraceUsingSymbols(int, const struct StackFrame *,
|
2020-09-03 05:44:37 -07:00
|
|
|
struct SymbolTable *);
|
|
|
|
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_LOG_BACKTRACE_H_ */
|