Introduction

compared with
Current by aleventhal
on Aug 07, 2008 13:38.

(show comment)
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (2)

View page history
}
{noformat}
If you follow the script and result closely, you might find that the behaviour is not exactly what was expected. The last trace is run, right after i == 1 was printed. If you keep in mind this is a *script* that is somehow interpreted (although, in practice it is compiled before running), and not a structured language, you can avoid situations like this. As it is being interpreted, the second clause ({{/i < 0/}}) when {{i == 1}}, enters, prints the trace, decreases {{i}}, and then the third clause is interpreted! Therefore, as {{i}} became 0, it enters inmediately after the print for 1 sec was output. To modify this behaviour, and have a true {{if-else}} behaviour, you should write the third clause, before the second.
Similar to the first example, {{hello.d}}, {{countdown.d}} uses a sequence of characters enclosed in double quotes, called a _string constant_, to print a final message when the countdown is complete. The {{exit}} function is then used to exit {{dtrace}} and return to the shell prompt.\\
\\If you look back at the structure of {{countdown.d}}, you will see that by creating two clauses with the same probe description but different predicates and actions, we effectively created the logical flow (if the third clause is re-arranged):
{noformat}
i = 10

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact