1 Reply Latest reply on Jan 18, 2010 8:27 PM by 807559

    umod,ufunc,usym not working


      I am new to dtrace so please have some patience.

      I am trying to use the ufunc function to get the function of the user process that was running before the probe fired:
      #!/usr/sbin/dtrace -s

      /* Prints the function and offset of the instruction of process running prior to probe firing*/
      printf(" %A\n", ufunc(arg1));
      The reasoning being arg1 is the PC of the process (if it was a user process) that was interrupted. However I get a compile error:
      dtrace: failed to compile script /tmp/rs: line 7: tracing function ufunc( ) may not be called from a D expression

      On searching the internet I get the following warning about umod & ufunc:
      "these are _action_ not _subroutines_. As such, they _cannot_ be used in D expressions"
      What does this mean?

      An example which is quoted is
      @[umod(arg1)] = count();

      which I interpret to mean an aggregation (unamed) where the key is umod(arg1) which is the module being run.
      Which surely means that umod has to be run to get the "key"? Can someone please explain this to me why umod/ufunc are not subroutines/functions then?

      Additionally, can I get the name of the module being run from a pid and use the inline definitons in /usr/lib/dtrace/procfs.d?

      Thanks for any help
        • 1. Re: umod,ufunc,usym not working
          You can think of a D expression as something that can be resolved to a value "where it stands." For example, "timestamp" is an expression that generalizes the value one needs at the point it is invoked.

          Actions work with the system in some way, e.g., to read symbols from a table in a process map. The computation required to produce data you want to record, in short, makes it untenable to help form an expression. Subroutines operate on already-received data in some way; they do not require interaction with the system, and so can be handled as part of an expression.

          I for one don't think it's helpful for the compiler to point out a distinction between actions and subroutines in this case, as if everyone who ends up down this road had meant to do exactly that, but whatcha gonna do?

          What you want to do in your example is appealing, of course. We'd all like to be able to do what you've shown. The problem has to do with keeping DTrace behaving in a reasonably efficient manner.

          Hope this helps,