diff --git a/src/dwarf/dwarf_handler.cpp b/src/dwarf/dwarf_handler.cpp index 39ff89a..c806248 100644 --- a/src/dwarf/dwarf_handler.cpp +++ b/src/dwarf/dwarf_handler.cpp @@ -268,6 +268,19 @@ void pst_handler_init(pst_handler* h, ucontext_t* hctx) { pst_context_init(&h->ctx, hctx); list_head_init(&h->functions); + h->allocated = false; +} + +pst_handler* pst_handler_new(ucontext_t* hctx) +{ + pst_handler* handler = pst_alloc(pst_handler); + + if(handler) { + pst_handler_init(handler, hctx); + handler->allocated = true; + } + + return handler; } void pst_handler_fini(pst_handler* h) diff --git a/src/dwarf/dwarf_handler.h b/src/dwarf/dwarf_handler.h index d68b3a5..9107194 100644 --- a/src/dwarf/dwarf_handler.h +++ b/src/dwarf/dwarf_handler.h @@ -15,14 +15,14 @@ #include "common.h" #include "context.h" -typedef struct pst_context pst_context; - typedef struct pst_handler { pst_context ctx; // context of unwinding list_head functions; // list of functions in stack frame + bool allocated; // whether this object was allocated or not } pst_handler; void pst_handler_init(pst_handler* h, ucontext_t* hctx); +pst_handler* pst_handler_new(ucontext_t* hctx); void pst_handler_fini(pst_handler* h); bool pst_handler_handle_dwarf(pst_handler* h);