From: Mark Wielaard Date: Thu, 8 Sep 2011 11:57:21 +0000 (+0200) Subject: Rename CONTEXT regflags to probe_flags. Now simply indicates user mode. X-Git-Tag: release-1.7~153^2~52 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=92c25572;p=systemtap.git Rename CONTEXT regflags to probe_flags. Now simply indicates user mode. Renamed common_probe_context.h regflags to probe_flags, rename constant from _STP_REGS_USER_FLAG to _STP_PROBE_STATE_USER_MODE and use throughout tapsets to check whether in user_mode() or not. --- diff --git a/runtime/common_probe_context.h b/runtime/common_probe_context.h index bab4fb2b9..fff16d2ba 100644 --- a/runtime/common_probe_context.h +++ b/runtime/common_probe_context.h @@ -29,6 +29,9 @@ const char *probe_name; and what information it gets passed. */ int probe_type; +/* Common status of probe. _STP_PROBE_STATE_ flags. */ +int probe_flags; + /* Number of "actions" this probe handler is still allowed to do. Setup in common_probe_entryfn_prologue to either MAXACTION or Checked by code generated by c_unparser::record_actions (), which will @@ -60,10 +63,8 @@ const char *last_error; /* Last statement (token) executed. Often set together with last_error. */ const char *last_stmt; -/* status of pt_regs regs field. _STP_REGS_ flags. */ -int regflags; /* Set when probe handler gets pt_regs handed to it. This can be either - the kernel registers or the user space registers. The regflags field + the kernel registers or the user space registers. The probe_flags field will indicate which and whether the user registers are complete. */ struct pt_regs *regs; diff --git a/runtime/regs.h b/runtime/regs.h index ca98c3126..08449aa6a 100644 --- a/runtime/regs.h +++ b/runtime/regs.h @@ -11,10 +11,6 @@ #ifndef _REGS_H_ /* -*- linux-c -*- */ #define _REGS_H_ -/* Defines for the struct context regsflags field. - _STP_REGS_USER regsflags bit to indicate regs fully from user. */ -#define _STP_REGS_USER_FLAG 1 - #if defined (STAPCONF_X86_UNIREGS) && (defined (__x86_64__) || defined (__i386__)) #define REG_IP(regs) regs->ip diff --git a/runtime/runtime_defines.h b/runtime/runtime_defines.h index ed0288bcc..6a31d2fce 100644 --- a/runtime/runtime_defines.h +++ b/runtime/runtime_defines.h @@ -57,6 +57,7 @@ typedef char string_t[MAXSTRINGLEN]; #define STP_OVERLOAD #endif +/* Defines for CONTEXT probe_type. */ /* begin, end or never probe, triggered by stap module itself. */ #define _STP_PROBE_HANDLER_BEEN 1 /* user space instruction probe, trigger by utrace signal report. */ @@ -94,3 +95,7 @@ typedef char string_t[MAXSTRINGLEN]; #define _STP_PROBE_HANDLER_HWBKPT 15 /* kernel tracepoint probe, triggered by tracepoint event call. */ #define _STP_PROBE_HANDLER_TRACEPOINT 16 + +/* Defines for CONTEXT probe_flags. */ +/* Probe occured in user space, also indicate regs fully from user. */ +#define _STP_PROBE_STATE_USER_MODE 1 diff --git a/runtime/stack.c b/runtime/stack.c index 3fb6a673e..4dfb4b219 100644 --- a/runtime/stack.c +++ b/runtime/stack.c @@ -167,7 +167,8 @@ static void _stp_stack_print(struct context *c, int sym_flags, int stack_flags) ri = NULL; if (stack_flags == _STP_STACK_KERNEL) { - if (! c->regs || (c->regflags & _STP_REGS_USER_FLAG)) { + if (! c->regs + || (c->probe_flags & _STP_PROBE_STATE_USER_MODE)) { /* For the kernel we can use an inexact fallback. When compiled with frame pointers we can do a pretty good guess at the stack value, @@ -201,7 +202,7 @@ static void _stp_stack_print(struct context *c, int sym_flags, int stack_flags) } } else if (stack_flags == _STP_STACK_USER) { /* use task_pt_regs, regs might be kernel regs, or not set. */ - if (c->regs && (c->regflags & _STP_REGS_USER_FLAG)) { + if (c->regs && (c->probe_flags & _STP_PROBE_STATE_USER_MODE)) { regs = c->regs; uregs_valid = 1; } else { diff --git a/tapset-itrace.cxx b/tapset-itrace.cxx index 77a285524..b576b1de0 100644 --- a/tapset-itrace.cxx +++ b/tapset-itrace.cxx @@ -192,7 +192,7 @@ itrace_derived_probe_group::emit_module_decls (systemtap_session& s) common_probe_entryfn_prologue (s.op, "STAP_SESSION_RUNNING", "p->probe", "_STP_PROBE_HANDLER_ITRACE"); s.op->newline() << "c->regs = regs;"; - s.op->newline() << "c->regflags |= _STP_REGS_USER_FLAG;"; + s.op->newline() << "c->probe_flags |= _STP_PROBE_STATE_USER_MODE;"; // call probe function s.op->newline() << "(*p->probe->ph) (c);"; diff --git a/tapset-perfmon.cxx b/tapset-perfmon.cxx index b7fb80f27..5bf15236b 100644 --- a/tapset-perfmon.cxx +++ b/tapset-perfmon.cxx @@ -155,7 +155,7 @@ perf_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "if ((stp->attr.type == PERF_TYPE_HARDWARE"; s.op->newline() << " || stp->attr.type == PERF_TYPE_HW_CACHE)"; s.op->newline() << " && user_mode(regs))"; - s.op->newline(1)<< "c->regflags |= _STP_REGS_USER_FLAG;"; + s.op->newline(1)<< "c->probe_flags |= _STP_PROBE_STATE_USER_MODE;"; s.op->newline(-1) << "(*stp->probe->ph) (c);"; common_probe_entryfn_epilogue (s.op); diff --git a/tapset-timers.cxx b/tapset-timers.cxx index 09fc40eff..f0f08ad20 100644 --- a/tapset-timers.cxx +++ b/tapset-timers.cxx @@ -436,7 +436,7 @@ profile_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "c->regs = regs;"; // Timer interrupts save all registers, so if the interrupt happened // in user space we can rely on it being the full user pt_regs. - s.op->newline() << "if (user_mode(regs)) c->regflags |= _STP_REGS_USER_FLAG;"; + s.op->newline() << "if (user_mode(regs)) c->probe_flags |= _STP_PROBE_STATE_USER_MODE;"; for (unsigned i=0; iprobe", "_STP_PROBE_HANDLER_UTRACE_SYSCALL"); s.op->newline() << "c->regs = regs;"; - s.op->newline() << "c->regflags |= _STP_REGS_USER_FLAG;"; + s.op->newline() << "c->probe_flags |= _STP_PROBE_STATE_USER_MODE;"; // call probe function s.op->newline() << "(*p->probe->ph) (c);"; diff --git a/tapset/arm/registers.stp b/tapset/arm/registers.stp index 1f3087960..42448b8db 100644 --- a/tapset/arm/registers.stp +++ b/tapset/arm/registers.stp @@ -43,9 +43,9 @@ function _stp_get_register_by_offset:long (offset:long) %{ /* pure */ THIS->__retvalue = value; %} -function _stp_probing_kernel:long () %{ /* pure */ - THIS->__retvalue = !user_mode(CONTEXT->regs); -%} +function _stp_probing_kernel:long () { + return !user_mode(); +} /* Return the named register value as a signed value. */ function register:long (name:string) { diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 64401f69f..9b2869059 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -103,7 +103,7 @@ function probefunc:string () %{ /* pure */ /* pragma:symbols */ _stp_snprint_addr(THIS->__retvalue, MAXSTRINGLEN, REG_IP(CONTEXT->regs), _STP_SYM_SYMBOL, - (CONTEXT->regflags & _STP_REGS_USER_FLAG + (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE ? current : NULL)); if (THIS->__retvalue[0] == '.') /* powerpc symbol has a dot*/ strlcpy(THIS->__retvalue,THIS->__retvalue + 1,MAXSTRINGLEN); @@ -131,7 +131,7 @@ function probemod:string () %{ /* pure */ *dst++ = *ptr++; *dst = 0; } else if (CONTEXT->regs - && ! (CONTEXT->regflags & _STP_REGS_USER_FLAG)) { + && ! (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)) { struct _stp_module *m; m = _stp_kmod_sec_lookup (REG_IP(CONTEXT->regs), NULL); if (m && m->name) diff --git a/tapset/context.stp b/tapset/context.stp index 478696c6e..2b7611ae6 100644 --- a/tapset/context.stp +++ b/tapset/context.stp @@ -242,11 +242,8 @@ function registers_valid:long () */ function user_mode:long () %{ /* pure */ /* unprivileged */ - if (CONTEXT->regs && (CONTEXT->regflags & _STP_REGS_USER_FLAG)) { - THIS->__retvalue = 1; - } else { - THIS->__retvalue = 0; - } + THIS->__retvalue = (CONTEXT->probe_flags + & _STP_PROBE_STATE_USER_MODE) ? 1 : 0; %} /** diff --git a/tapset/i386/registers.stp b/tapset/i386/registers.stp index 5646caa29..730f078cd 100644 --- a/tapset/i386/registers.stp +++ b/tapset/i386/registers.stp @@ -61,9 +61,9 @@ function _stp_get_register_by_offset:long (offset:long) %{ /* pure */ THIS->__retvalue = value; %} -function _stp_probing_kernel:long () %{ /* pure */ - THIS->__retvalue = !user_mode(CONTEXT->regs); -%} +function _stp_probing_kernel:long () { + return !user_mode(); +} /* * esp and ss aren't saved on a breakpoint in kernel mode, so diff --git a/tapset/s390/registers.stp b/tapset/s390/registers.stp index df49229b0..d608cf81d 100644 --- a/tapset/s390/registers.stp +++ b/tapset/s390/registers.stp @@ -50,9 +50,9 @@ function probing_32bit_app() %{ /* pure */ THIS->__retvalue = 0; %} -function _stp_probing_kernel: long () %{ /* pure */ - THIS->__retvalue = !user_mode(CONTEXT->regs); -%} +function _stp_probing_kernel: long () { + return !user_mode(); +} function _stp_get_register_by_offset:long (offset:long) %{ /* pure */ long value; diff --git a/tapset/utrace.stp b/tapset/utrace.stp index f32af9210..6c6d91cff 100644 --- a/tapset/utrace.stp +++ b/tapset/utrace.stp @@ -5,7 +5,8 @@ %} function _utrace_syscall_nr:long () %{ /* pure */ /* myproc-unprivileged */ - if (! CONTEXT->regs || ! (CONTEXT->regflags & _STP_REGS_USER_FLAG)) { + if (! CONTEXT->regs + || ! (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)) { CONTEXT->last_error = "invalid call without context registers"; } else { THIS->__retvalue = syscall_get_nr(current, CONTEXT->regs); @@ -14,7 +15,8 @@ function _utrace_syscall_nr:long () %{ /* pure */ /* myproc-unprivileged */ function _utrace_syscall_arg:long (n:long) %{ /* pure */ /* myproc-unprivileged */ unsigned long arg = 0; - if (! CONTEXT->regs || ! (CONTEXT->regflags & _STP_REGS_USER_FLAG)) { + if (! CONTEXT->regs + || ! (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)) { CONTEXT->last_error = "invalid call without context registers"; } else { syscall_get_arguments(current, CONTEXT->regs, (int)THIS->n, 1, &arg); @@ -29,7 +31,8 @@ function _utrace_syscall_return:long () %{ /* pure */ /* myproc-unprivileged */ * getting sign extended. This caused return values to not match * up with the same values passes as arguments. */ - if (! CONTEXT->regs || ! (CONTEXT->regflags & _STP_REGS_USER_FLAG)) { + if (! CONTEXT->regs + || ! (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)) { CONTEXT->last_error = "invalid call without context registers"; } else { THIS->__retvalue = (unsigned long)syscall_get_return_value(current, diff --git a/tapsets.cxx b/tapsets.cxx index fd5a6aafc..633597ae1 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -160,7 +160,7 @@ common_probe_entryfn_prologue (translator_output* o, string statestr, o->newline() << "c->probe_type = " << probe_type << ";"; // reset Individual Probe State union o->newline() << "memset(&c->ips, 0, sizeof(c->ips));"; - o->newline() << "c->regflags = 0;"; + o->newline() << "c->probe_flags = 0;"; o->newline() << "#ifdef STAP_NEED_REGPARM"; // i386 or x86_64 register.stp o->newline() << "c->regparm = 0;"; o->newline() << "#endif"; @@ -6917,7 +6917,7 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "goto probe_epilogue;"; s.op->newline(-1) << "}"; s.op->newline() << "c->regs = regs;"; - s.op->newline() << "c->regflags |= _STP_REGS_USER_FLAG;"; + s.op->newline() << "c->probe_flags |= _STP_PROBE_STATE_USER_MODE;"; // Make it look like the IP is set as it would in the actual user // task when calling real probe handler. Reset IP regs on return, so @@ -6948,7 +6948,7 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(-1) << "}"; s.op->newline() << "c->regs = regs;"; - s.op->newline() << "c->regflags |= _STP_REGS_USER_FLAG;"; + s.op->newline() << "c->probe_flags |= _STP_PROBE_STATE_USER_MODE;"; // Make it look like the IP is set as it would in the actual user // task when calling real probe handler. Reset IP regs on return, so