在到达断点之前,数据输入到调试器 [英] Data input to debugger before hitting the breakpoint

查看:213
本文介绍了在到达断点之前,数据输入到调试器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序运行在目标机器上,并试图使用WinDbg从我的电脑上调试它。现在我想在敲击条件断点之前向WinDbg输入一些值,并且一旦命中,该条件断点将作为参数传递给条件断点。



我的最终目标是,我不想让WinDbg等待输入超过一秒钟,当断点被击中。你大家都知道,WinDbg冻结所有线程,当断点被击中,因此我得到很多定时器时间间隔问题后继续(使用 g )。



我知道我可以使用一个文件(通过放入所需的数据),并且一旦中断点被解析。但我想让用户在断点命中之前输入所需的数据(最多5个),并在命中条件断点时将数据传递给应用程序本地。



我使用以下条件断点 bp FileName.cpp:341j(1)'.echo \断点命中,条件\; ed dwRand 12; gc';'gc'



其实我想在断点命中之前得到 dwRand c:

解决方案

:\ > ls -l <​​/ h3>

  -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\\\
,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 -cbp hitchange! printf \r $ t0 = poi(@ esp + 8); printf \\\actual rand value
e @ [esp + 8] =%08x\\
\\ \,@ $ t0; ed @ esp + 8 f001; gc; \; g; qhitchange.exe



  0:000> cdb:读取初始命令bp hitchange!printfr $ t0 = poi(@ esp + 8); pr 
intf \实际rand值@ [esp + 8] =%08x\\\\
\,@ $ t0; ed @ esp + 8 f001; gc;; g; q'

实际rand值@ [esp + 8] = 00000029
0000f001
实际rand值@ [esp + 8] = 00004823
0000f001
实际rand值@ [esp + 8] = 000018be
0000f001
实际rand值@ [esp + 8] = 00006784
0000f001
实际rand值@ [esp + 8] = 00004ae1
0000f001
实际rand值@ [esp + 8] = 00003d6c
0000f001
实际rand值@ [esp + 8] = 00002cd6
0000f001
实际rand值@ [esp + 8] = 000072ae

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>.

解决方案

:\>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

这篇关于在到达断点之前,数据输入到调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆