summaryrefslogtreecommitdiffstats
path: root/tapset
diff options
context:
space:
mode:
Diffstat (limited to 'tapset')
-rw-r--r--tapset/context.stp4
-rw-r--r--tapset/conversions.stp28
2 files changed, 31 insertions, 1 deletions
diff --git a/tapset/context.stp b/tapset/context.stp
index 32b009bf..6d600190 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -10,8 +10,9 @@ function print_backtrace () %{
}
%}
-function backtrace () %{
+function backtrace:string () %{
if (CONTEXT->regs) {
+ /* XXX: is String really necessary for this? */
String str = _stp_string_init (0);
_stp_stack_sprint (str, CONTEXT->regs, 0);
strlcpy (THIS->__retvalue, _stp_string_ptr(str), MAXSTRINGLEN);
@@ -79,6 +80,7 @@ function euid:long () %{
function print_stack(stk:string) %{
char *ptr = THIS->stk;
char *tok = strsep(&ptr, " ");
+ /* XXX: is this header really necessary & accurate? */
_stp_printf ("trace for %d (%s)\n", current->pid, current->comm);
while (tok && *tok) {
_stp_print_cstr(" ");
diff --git a/tapset/conversions.stp b/tapset/conversions.stp
index 901f26a4..50dbfeb0 100644
--- a/tapset/conversions.stp
+++ b/tapset/conversions.stp
@@ -6,3 +6,31 @@ function string:string (num:long) %{
sprintf (THIS->__retvalue, "%lld", (long long) THIS->num);
%}
+
+function kernel_string:string (addr:long) %{
+ char *destination = THIS->__retvalue;
+ deref_string (destination, THIS->addr, MAXSTRINGLEN);
+ goto success;
+deref_fault: /* branched to from deref() */
+ {
+ static char errmsg[40];
+ snprintf (errmsg, 40, "kernel string copy fault at 0x%p",
+ (void *) (uintptr_t) THIS->addr);
+ CONTEXT->last_error = errmsg;
+ }
+success: ;
+%}
+
+# NB: accessing user space is hazardous from certain kernel contexts.
+function user_string:string (addr:long) %{
+ long rc = _stp_strncpy_from_user (THIS->__retvalue,
+ (const char __user*) (uintptr_t) THIS->addr,
+ MAXSTRINGLEN);
+ if (rc < 0)
+ {
+ static char errmsg[40];
+ snprintf (errmsg, 40, "user string copy fault at 0x%p",
+ (void *) (uintptr_t) THIS->addr);
+ CONTEXT->last_error = errmsg;
+ }
+%}