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: $return in wildcarded void functions


Frank Ch. Eigler wrote:
I've thought about it a while, and it seems easiest as well as fairly
general to support markup of the $variable use itself.  Since more
elaborate script code may want to substitute a missing $value, and
also know that such a substitution has been done, we'd probably need
two variables:

# probe module("uhci_hcd").function("*").return
# {
# if ($?return)
#   printf ("%s <- %s: %s\n", thread_indent(-2), probefunc(), errno_str($!return))
# else
#     printf ("%s <- %s: void\n", thread_indent(-2), probefunc())
# }

So $?var would return true or false if the given expression was
defined.  And $!var would return the value, if defined, or else fall
back to 0.  (This could also cover a fault being encountered while
$!var->field->array[99] pointer chains were gbeing followed.)

So:
   $?var==0 implies $!var==0
   $?var==0 implies $var would have caused compile-time error
   $?var==1 implies $!var equals what $var would have

I like this approach. Could it also work for variables defined locally in probes (e.g. ?var and !var, no $)? What about global variables?


I'm not crazy about returning 0 for a non-existent variable, but at least this method provides a way to avoid that.

Does $?var==1 imply that $var and $!var exist ?

Mike


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