Ahh, wonderful.  Thanks Jonathan!

--Brett

On Fri, Dec 12, 2008 at 12:51 PM, Jonathan Adams <jonathan.ad...@sun.com> wrote:
> On Fri, Dec 12, 2008 at 12:05:21PM -0800, Brett Monroe wrote:
>> Happy Friday,
>>
>> I'm having a hard time wrapping my head around the proper way to use
>> conditional expressions in DTrace.
>>
>> The following line seems to not want to compile:
>>
>> args[0]->b_flags & B_READ ? (
>> @dev_r[args[1]->dev_statname,args[1]->dev_pathname]=sum(args[0]->b_bcount)
>> ) : ( @dev_w[args[1]->dev_statname]=sum(args[0]->b_bcount) );
>
> You cannot use conditional expressions to do different actions; they can
> only be used in expressions.  You need to use predicates:
>
> io:::start
> / args[0]->b_flags & B_READ /
> {
>        @dev_r[args[1]->dev_statname,args[1]->dev_pathname] =
>            sum(args[0]->b_bcount);
> }
>
> io:::start
> / !(args[0]->b_flags & B_READ) /
> {
>        @dev_w[args[1]->dev_statname] = sum(args[0]->b_bcount);
> }
>
> Cheers,
> - jonathan
>
>> I get the following error:
>>
>>   dtrace: failed to compile script ./script.d: line 6: operator ?:
>> operands cannot be of dynamic type
>>
>> My general (and apparently wrong) understanding is that all three
>> expressions should evaluate to either true or false so (B_READ bit is
>> set or not, @dev_r aggregate gets populated or not, or the @dev_w
>> aggregate gets populated or not).  It seems on the surface to be
>> pretty strait forward....but of course I am missing something.
>>
>> Any help would be appreciated.
>> --Brett
>> _______________________________________________
>> dtrace-discuss mailing list
>> dtrace-discuss@opensolaris.org
>
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to