From d4e9307fe1d3a772cd1b79485fa7c830a3adb2b1 Mon Sep 17 00:00:00 2001 From: Nikolai Nosov Date: Wed, 5 Feb 2020 12:12:02 +0400 Subject: [PATCH] add pst_handler_new() --- src/dwarf/dwarf_handler.cpp | 13 +++++++++++++ src/dwarf/dwarf_handler.h | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) 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);