add pst_handler_new()

This commit is contained in:
2020-02-05 12:12:02 +04:00
parent bfb9200d3a
commit d4e9307fe1
2 changed files with 15 additions and 2 deletions
+13
View File
@@ -268,6 +268,19 @@ void pst_handler_init(pst_handler* h, ucontext_t* hctx)
{ {
pst_context_init(&h->ctx, hctx); pst_context_init(&h->ctx, hctx);
list_head_init(&h->functions); 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) void pst_handler_fini(pst_handler* h)
+2 -2
View File
@@ -15,14 +15,14 @@
#include "common.h" #include "common.h"
#include "context.h" #include "context.h"
typedef struct pst_context pst_context;
typedef struct pst_handler { typedef struct pst_handler {
pst_context ctx; // context of unwinding pst_context ctx; // context of unwinding
list_head functions; // list of functions in stack frame list_head functions; // list of functions in stack frame
bool allocated; // whether this object was allocated or not
} pst_handler; } pst_handler;
void pst_handler_init(pst_handler* h, ucontext_t* hctx); 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); void pst_handler_fini(pst_handler* h);
bool pst_handler_handle_dwarf(pst_handler* h); bool pst_handler_handle_dwarf(pst_handler* h);