0

Sorry for compilcated title, but here is a dtrace output of my script, which I think will help explain what im talking about:

        16384                1
        38048                1
        38050                1
        38051                1
        38055                1

    -58632623                1
     -5180681                1
     -4576706                1
     -4498881                1
     -4472021                1
     -4464140                1
<...>
mymodule.so`FuncXXX
mymodule.so`FirstFunc+0x23c
8

mymodule.so`FuncXXX
mymodule.so`SecondFunc+0x4bc
9

mymodule.so`FuncXXX
mymodule.so`ThirdFunc+0x1e1
35

mymodule.so`FuncXXX
mymodule.so`FourthFunc+0x70
39

dtrace script is:

pid$1:mymodule:FuncXXX:entry{
    @a[arg1] = count();
    @b[arg2] = count();
    @c[ustack()] = count();
}

FuncXXX has singature: void FuncXXX(void *arg, long int p, int q);

Now, i want to aggregate variables p and q, but in order where FuncXXX has been called, eg:

mymodule.so`FuncXXX'
mymodule.so`FirstFunc'+0x23c
8

            16384                1
            38048                1
            38050                1
            38051                1
            38055                1

        -58632623                1
         -5180681                1
         -4576706                1
         -4498881                1
         -4472021                1
         -4464140                1

mymodule.so`FuncXXX'
mymodule.so`SecondFunc'+0x4bc
9

            49599                1
            51533                1
            51535                1
            52149                1
            52152                1

          -148909                1
          -135530                1
          -121514                1
          -117860                1
               -97633                1
and so on

Is it possible to do it ? Or should I trace FirstFunc, SecondFunc, ThirdFunc and FourthFunc independently ? But thing is, that in all of that funcions, FuncXXX can not always be called.

Best regards and thx for all the answers.

JosiP
  • 2,619
  • 5
  • 29
  • 33

1 Answers1

0

Aggregates can be indexed in multiple dimensions, i.e. you can write:

@a[ustack(2), arg1, arg2] = count();

You can also, if you're only interested in the caller of your probe function, use either the DTrace variable "caller" (gives you the address the probe func got called from unfortunately - not the symbol name) or give ustack() a number of stackframes to record, ustack(2) just giving you the probefunc (FuncXXX in your case) and the place it got called from.

The above aggregation therefore tells you "how many times has FuncXXX been called from ... with a combination of arguments arg1/arg2".

FrankH.
  • 17,675
  • 3
  • 44
  • 63