条件表达式是windbg常用的脚本必须使用到的:以下二选一,我习惯使用.if这种,和C++相近
j(execute If-Else)
j
Expression Command1
;
Command2
j
Expression
'
Command1
' ; '
Command2
'
多条命令当然要加单引号,因为这command1、command2之间也是用分号分隔的
<pre name="code" class="cpp">cx=fb08
0:000> j (eax!=0) r eax; r bx
bx=0
0:000> j (eax!=0) r eax; r bx; r cx
bx=0
0:000> j (eax!=0) r eax; 'r bx; r cx'
bx=0
cx=fb08
可以看到第二条由于没有单引号,所以后面的被忽略了!
.if
.if ( Condition ) { Commands } .if ( Condition ) { Commands } .else { Commands } .if ( Condition ) { Commands } .elsif ( Condition ) { Commands } .if ( Condition ) { Commands } .elsif ( Condition ) { Commands } .else { Commands }
0:000> .if (eax>ebx){r eax}.else{r ebx; r ecx}
ebx=00000000
ecx=001dfad0
当一个条件断点的末尾包含一个执行命令时,需要使用gc命令
例如,如果使用g (Go)命令来到达该断点,则恢复为自由执行。但是如果使用单步或跟踪来到达该断点,也会以单步或跟踪的方式来恢复执行