z (Execute While)
The z command executes a command while a given condition is true.
Command ; z( Expression )
Command ; [Processor] z( Expression )
Specifies the command to execute while the Expression condition evaluates to a nonzero value. This command is always executed at least once.
Specifies the processor that applies to the test. For more information about the syntax, see Multiprocessor Syntax. You can specify processors only in kernel mode.
Specifies the condition to test. If this condition evaluates to a nonzero value, the Command command is executed again and then Expression is tested again. For more information about the syntax, see Numerical Expression Syntax.
User mode, kernel mode
Live, crash dump
In many debugger commands, the semicolon is used to separate unrelated commands. However, in the z command, a semicolon separates the "z" from the Command parameter.
The Command command is always executed at least once, and then Expression is tested. If the condition is a nonzero value, the command is again executed, and then Expression is tested again. (This behavior is similar to a C-language do - while loop, not a simple while loop.)
If there are several semicolons to the left of the "z", all commands to the left of the "z" repeat as long as the Expression condition is true. Such commands can be any debugger commands that permit a terminal semicolon.
If you add another semicolon and additional commands after the z command, these additional commands are executed after the loop is complete. We do not typically recommend a line that begins with "z" because it generates uninteresting output forever unless the condition becomes false because of some other action. Note that you can nest z commands.
The following code example shows an unnecessarily complex way to zero the eax register.
0:000> reax = eax - 1 ; z(eax)
The following example increments the eax and ebx registers until one of them is at least 8 and then it increments the ecx register once.
0:000> reax=eax+1; rebx=ebx+1; z((eax<8)|(ebx<8)); recx=ecx+1
The following example uses C++ expression syntax and uses the pseudo-register $t0 as a loop variable.
0:000> .expr /s c++ Current expression evaluator: C++ - C++ source expressions 0:000> db pindexcreate[@$t0].szKey; r$t0=@t0+1; z( @$t0 < cIndexCreate )