This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Some functional test examples


I'll attempt to answer some of these.

Note that we are in the process of adjusting how we handle pointers in
the translator.  This will have impacts in the tapsets.  In particular,
copies from userspace will only happen if explicilty coded in embedded
C.

FYI, log() is now the same as print()

> ___________________________________________________________________
> # This I am sure is a cockpit error. I
> # do not know how to properly return a
> # string from an embedded C function to
> # a regular probe script function. I
> # highly doubt the translator has anything
> # to do with this. Some help on how to do
> # this would be nice.
> 
> function embed_param_pass(param)
> %{
>         THIS->__retvalue = THIS->param;
> %}
> 
> probe kernel.function("sys_open")
> {
>         log(embed_param_pass("Hello"));
> }

THIS->__retvalue is an array. You must strcpy the result into it.
This works:

function embed_param_pass(param)
%{
        strlcpy (THIS->__retvalue, THIS->param, MAXSTRINGLEN);
%}

probe kernel.function("sys_open")
{
        log(embed_param_pass("Hello"));
}


> ___________________________________________________________________
> # Why is this not working??? I think this is
> # a bug. Param resolution should not fail.
> 
> probe kernel.function("sys_close")
> {
>    log(string($fd))
> }

Its a bug.  Works on x86_64 for me, but not i686.
(same kernel)

> ___________________________________________________________________
> # Hmmm...this isn't working for me. I think
> # it should, according to the stap man page:
> #
> #  "The .return variant places a probe at
> #   the moment of return from the named
> #   function, so the return value is
> #   available as the "$retvalue"
> #   context variable."
> 
> probe kernel.function("sys_open").return
> {
>    log(string($retvalue))
> }

return probes are mostly untested in systemtap.

> ___________________________________________________________________
> # I didn't expect this to work. It may be
> # useful to have access to the registers.
> # Maybe as a built in (like get_pid()).
> 
> probe kernel.function("sys_open").return
> {
>    log(string($regs->eax))
> }

We have print_regs().  We could easily add functions to get specific
registers.  Here's an example.

function _get_eax () %{
        if (CONTEXT && CONTEXT->regs)
                THIS->__retvalue = CONTEXT->regs->eax;
        else
		THIS->__retvalue = -1;
%}

function get_eax() {
	return _get_eax() + 0
}


Martin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]