From 8b8c68c86412119edee6f48dd9c7b10c6e7071d0 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 5 Oct 2012 14:28:26 -0700 Subject: [PATCH] stapdyn: implement more of dyninst/context.stp Added cpu(), registers_valid(), uaddr(), and addr(). --- runtime/dyninst/runtime_defines.h | 2 ++ tapset/dyninst/context.stp | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/runtime/dyninst/runtime_defines.h b/runtime/dyninst/runtime_defines.h index 2ac5c19be..318125ba3 100644 --- a/runtime/dyninst/runtime_defines.h +++ b/runtime/dyninst/runtime_defines.h @@ -1,3 +1,5 @@ +#define _GNU_SOURCE + #define STP_NO_OVERLOAD 1 /* We don't need to worry about pagefaults in loc2c-runtime.h */ diff --git a/tapset/dyninst/context.stp b/tapset/dyninst/context.stp index 668f8cd48..e3a333760 100644 --- a/tapset/dyninst/context.stp +++ b/tapset/dyninst/context.stp @@ -9,6 +9,7 @@ // NB: functionally equivalent to linux/context.stp %{ +#include #include #include #include @@ -78,9 +79,16 @@ function euid:long () // TODO function is_myproc:long () // NB: dyninst by nature is myproc-only, *except if you're root* -// TODO function cpu:long () +function cpu:long () +%{ /* pure */ /* unprivileged */ + STAP_RETVALUE = sched_getcpu(); +%} + -// TODO function registers_valid:long () +function registers_valid:long () +%{ /* pure */ /* unprivileged */ + STAP_RETVALUE = (CONTEXT->uregs != NULL); +%} function user_mode:long () { @@ -105,9 +113,15 @@ function user_mode:long () // TODO function stack_unused:long () -// TODO function addr:long () +function addr:long () +{ + return uaddr() +} -// TODO function uaddr:long () +function uaddr:long () +%{ /* pure */ /* unprivileged */ + STAP_RETVALUE = (intptr_t)(CONTEXT->uregs ? REG_IP(CONTEXT->uregs) : 0); +%} // TODO function cmdline_args:string(n:long, m:long, delim:string) -- 2.43.5