diff --git a/include/libpst.h b/include/libpst.h index 27402b1..29ae5f0 100644 --- a/include/libpst.h +++ b/include/libpst.h @@ -17,11 +17,11 @@ typedef struct pst_handler pst_handler; -// allocate and initialize libpst handler. -pst_handler* pst_new_handler(ucontext_t* hctx); +// allocate libpst handler and initialize the library +pst_handler* pst_lib_init(ucontext_t* hctx); -// deallocate libpst handler -void pst_del_handler(pst_handler* h); +// deallocate libpst handler and deinitialize the library +void pst_lib_fini(pst_handler* h); // @@ -35,10 +35,9 @@ int pst_unwind_simple_fd(pst_handler* h, FILE* fd); // save stack trace information to provided buffer in RAM int pst_unwind_simple(pst_handler* h, char* buff, uint32_t buff_size); - +// // Advanced unwind routines. -// Unwinds current stack trace using DWARF debug sections in file if they present and print it to provided file descriptor. -// Additionally to pst_unwind_simple(...) provides types of parameters and variables in functions and their values +// Additionally to pst_unwind_simple(...) provides types of parameters and variables in functions and their values if possible // // write stack trace information to provided file descriptor diff --git a/src/libpst.c b/src/libpst.c index ab81986..beed1e3 100644 --- a/src/libpst.c +++ b/src/libpst.c @@ -12,8 +12,8 @@ #include "utils/allocator.h" #include "dwarf/dwarf_handler.h" -// allocate and initialize libpst handler. -pst_handler* pst_new_handler(ucontext_t* hctx) +// allocate and initialize libpst library +pst_handler* pst_lib_init(ucontext_t* hctx) { // global pst_alloc_init(&allocator); @@ -23,8 +23,8 @@ pst_handler* pst_new_handler(ucontext_t* hctx) return handler; } -// deallocate libpst handler -void pst_del_handler(pst_handler* h) +// deallocate libpst handler and library +void pst_lib_fini(pst_handler* h) { pst_free(h); diff --git a/tests/main.c b/tests/main.c index 69eb2f8..faf105f 100644 --- a/tests/main.c +++ b/tests/main.c @@ -62,7 +62,7 @@ void FatalSignalHandler(int sig, siginfo_t* info, void* context) printf("%s signal handled\n", strsignal(sig)); if((context != 0) && (sig == SIGSEGV || sig == SIGABRT || sig == SIGBUS || sig == SIGFPE)) { - pst_handler* handler = pst_new_handler((ucontext_t*)context); + pst_handler* handler = pst_lib_init((ucontext_t*)context); if(!handler) { printf("Failed to allocate pst handler\n"); return; @@ -75,7 +75,7 @@ void FatalSignalHandler(int sig, siginfo_t* info, void* context) printf("No stack trace obtained\n"); } - pst_del_handler(handler); + pst_lib_fini(handler); }