I have an application running on target machine and trying to debug it from my PC using WinDbg. Now I would like to input some value to WinDbg before hitting the conditional breakpoint and the same shall be passed in as an argument to the conditional break point as soon as it is hit.
My ultimate aim is that I do not want WinDbg waiting for input for more than a second when the breakpoint is hit. As you all know, WinDbg freezes all threads when the breakpoint is hit, hence I'm getting lot timer elapse issue after continue (using g
).
I know that I can use a file (by putting desired data in) and parse it as soon as the break point is hit. But I want the user to enter desired data (maximum 5) before the breakpoint hits and pass in that data to application local when conditional break point is hit.
I use the following conditional breakpoint bp FileName.cpp:341 "j (1) '.echo \"Breakpoint hit, condition\";ed dwRand 12;gc'; 'gc'"
Actually I would like to get dwRand
value before the breakpoint hits, and upon breakpoint hit update the conditional breakpoint as ed dwRand <VALUE>
.
WinDbg does not freeze threads on its own, it suspends them, which is a difference (see .hh freeze
for details). If all your timers are on other threads, you can resume all of those threads:
0:000> r $t0 = @$tid
0:000> ~*e .if (@$t0 != $tid) {~~[$tid]m} .else { .echo "current thread" }
current thread
0:000> ~
. 0 Id: 1624.f6c Suspend: 1 Teb: 7efdd000 Unfrozen
1 Id: 1624.180c Suspend: 0 Teb: 7efda000 Unfrozen
2 Id: 1624.864 Suspend: 0 Teb: 7efd7000 Unfrozen
3 Id: 1624.1d4c Suspend: 0 Teb: 7efaf000 Unfrozen
4 Id: 1624.14b0 Suspend: 0 Teb: 7efac000 Unfrozen
5 Id: 1624.1e54 Suspend: 0 Teb: 7efa9000 Unfrozen
6 Id: 1624.774 Suspend: 0 Teb: 7efa6000 Unfrozen
7 Id: 1624.1810 Suspend: 0 Teb: 7efa0000 Unfrozen
Like this, only the current thread (0
) remains suspended (Suspend: 1
) until you finished modifying memory. All other threads are running (Suspend: 0
).
:\>ls -l
-rw-rw-rw- 1 Admin 0 128 2015-07-13 19:17 hitchange.cpp
:\>cat hitchange.cpp
#include <stdio.h>
#include <stdlib.h>
void main (void) {
for (int i =0; i< 10; i++){
printf("%08x\n",rand());
}
}
:\>..\compile.bat
:\>cl /Zi /EHsc /nologo /W4 /analyze *.cpp /link /RELEASE
hitchange.cpp
:\>hitchange.exe
00000029
00004823
000018be
00006784
00004ae1
00003d6c
00002cd6
000072ae
00006952
00005f90
:\>cdb -c "bp hitchange!printf \"r $t0 =poi(@esp+8);.printf \\\"actual rand valu
e @ [esp+8] = %08x\\n\\\",@$t0 ;ed @esp+8 f001;gc;\";g;q" hitchange.exe
0:000> cdb: Reading initial command 'bp hitchange!printf "r $t0 =poi(@esp+8);.pr
intf \"actual rand value @ [esp+8] = %08x\\n\",@$t0 ;ed @esp+8 f001;gc;";g;q'
actual rand value @ [esp+8] = 00000029
0000f001
actual rand value @ [esp+8] = 00004823
0000f001
actual rand value @ [esp+8] = 000018be
0000f001
actual rand value @ [esp+8] = 00006784
0000f001
actual rand value @ [esp+8] = 00004ae1
0000f001
actual rand value @ [esp+8] = 00003d6c
0000f001
actual rand value @ [esp+8] = 00002cd6
0000f001
actual rand value @ [esp+8] = 000072ae