Created
August 10, 2022 10:10
-
-
Save funny-falcon/a83831fc09b0cbcd48938eb76b756adf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.16) | |
project(test_backtrace VERSION 0.1 LANGUAGES C) | |
set(CMAKE_C_STANDARD 99) | |
set(CMAKE_C_EXTENSIONS true) | |
find_library(LIBBACKTRACE backtrace) | |
add_executable(test_exe test_exe.c) | |
target_link_libraries(test_exe PUBLIC backtrace) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <backtrace.h> | |
static int | |
local_backtrace_callback(void *data, uintptr_t pc, | |
const char* filename, int lineno, | |
const char* function) | |
{ | |
return 0; | |
} | |
static void | |
local_try_backtrace(void) { | |
static struct backtrace_state * state = NULL; | |
if (state == NULL) | |
state = backtrace_create_state(NULL, 0, NULL, NULL); | |
backtrace_full(state, 0, local_backtrace_callback, NULL, NULL); | |
} | |
int main(void) { | |
local_try_backtrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment