conditional probes
Dave Nomura
dcnltc@us.ibm.com
Thu Jun 26 20:22:00 GMT 2008
I was starting to re-build my patch for itrace and noticed that most of
the utrace machinery had been removed from tapsets.cxx. Are there any
functional/interface changes that I should know about? I patterned my
changes off of the utrace stuff.
David Smith wrote:
> Frank Ch. Eigler wrote:
>
>> Hi -
>>
>>
>>> I think the problem is that from within the utrace .report_signal
>>> handler I want to call the function that corresponds to "if (condition)
>>> { ... }" which is represented as say probe_1064(struct context *), but I
>>> don't know where I would find the "struct context *" argument that the
>>> probe_1064() requires. [...]
>>>
>> Look at the "stap -p3" code generated from
>>
>> probe begin { println("hello") }
>> or probe kernel.function("sys_open") { println("hello") }
>> or probe process("bash").begin { println("hello") }
>>
>> You'll see that context allocation is done by the systemtap-generated
>> function that receives the callback from the kernel facility that
>> represents the event source. That function -- usually just one per
>> derived_probe_group -- then invokes the appropriate probe handler
>> function ("probe_NNNN (struct context *)") through a function pointer.
>>
>
> Dave,
>
> Frank gave you a good overview, but I thought I fill in a few more
> details. If you want to specifically see how utrace probes get called,
> you can look at the output of the following:
>
> # stap -p3 -e 'probe process("/bin/bash").syscall { printf("hello\n") }'
>
> The routine you'll want to study is 'stap_utrace_probe_syscall'.
> There's a lot of code in that routine, but most of it is boilerplate.
> That C routine gets output in the translator by
> utrace_derived_probe_group::emit_module_decls(). For instance, here's
> the code that generates 'stap_utrace_probe_syscall':
>
> s.op->newline() << "static u32 stap_utrace_probe_syscall(struct
> utrace_attached_engine *engine, struct task_struct *tsk, struct pt_regs
> *regs) {";
> s.op->indent(1);
> s.op->newline() << "struct stap_utrace_probe *p = (struct
> stap_utrace_probe *)engine->data;";
>
> common_probe_entryfn_prologue (s.op, "STAP_SESSION_RUNNING");
> s.op->newline() << "c->probe_point = p->pp;";
> s.op->newline() << "c->regs = regs;";
>
> // call probe function
> s.op->newline() << "(*p->ph) (c);";
> common_probe_entryfn_epilogue (s.op);
>
> s.op->newline() << "return UTRACE_ACTION_RESUME;";
> s.op->newline(-1) << "}";
>
> The utrace_derived_probe_group::emit_module_decls() function outputs all
> the .report_* related functions that the utrace probes need.
>
>
--
Dave Nomura
LTC Linux Power Toolchain
More information about the Systemtap
mailing list