Files
FWS-Kitty/kitty/backtrace.h
T
BlackAngelTV 3d174c45a4 chore: import official kitty sources from upstream
Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty, vendored at upstream commit 91fb38a without its git history.
2026-11-04 11:35:59 +01:00

34 lines
661 B
C

/*
* Copyright (C) 2022 Kovid Goyal <kovid at kovidgoyal.net>
*
* Distributed under terms of the GPL3 license.
*/
#pragma once
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#if __has_include(<execinfo.h>)
#include <execinfo.h>
static inline void
print_stack_trace(void) {
void *array[256];
size_t size;
// get void*'s for all entries on the stack
size = backtrace(array, 256);
// print out all the frames to stderr
backtrace_symbols_fd(array, size, STDERR_FILENO);
}
#else
static inline void
print_stack_trace(void) {
fprintf(stderr, "Stack trace functionality not available.\n");
}
#endif