逐行跟踪模块?

时间:2015-05-14 07:05:40

标签: debugging windbg

我正在尝试使用WinDbg来跟踪我的程序(其中只有一个模块),并记录执行的行号。我稍后会自动完成这个过程,但是现在我只想逐行完成代码。

我正在尝试查看是否可以使用自动调试程序来计算自动化的代码覆盖率。

我有正确的符号。我该怎么做呢?调试器显然有能力逐行执行代码。

我尝试过使用l+tl+ol+sppr。我已启用源模式(l+t),但我没有在命令窗口中看到源代码,也没有看到任何源窗口。

2 个答案:

答案 0 :(得分:0)

cdb -lines -c“l + t; l + o; l + s; g main; p 12; q”printhello.exe

0:000> cdb: Reading initial command 'l+t;l+o;l+s;g main;p 12;q'

Source options are d:
     1/t - Step/trace by source line
     4/s - List source code at prompt
     8/o - Only show source code at prompt

>    5:         printf("lets say hello to the world for %8s time\n", count[0]);
lets say hello to the world for    first time
>    6:         printf("lets say hello to the world for %8s time\n", count[1]);
lets say hello to the world for   second time
>    7:         printf("lets say hello to the world for %8s time\n", count[2]);
lets say hello to the world for    third time
>    8:         printf("lets say hello to the world for %8s time\n", count[3]);
lets say hello to the world for   fourth time
>    9:         printf("lets say hello to the world for %8s time\n", count[4]);
lets say hello to the world for    fifth time
>   10:         printf("lets say hello to the world for %8s time\n", count[5]);
lets say hello to the world for    sixth time
>   11:         printf("lets say hello to the world for %8s time\n", count[6]);
lets say hello to the world for  seventh time
>   12:         printf("lets say hello to the world for %8s time\n", count[7]);
lets say hello to the world for   eighth time
>   13:         printf("lets say hello to the world for %8s time\n", count[8]);
lets say hello to the world for    ninth time
>   14:         printf("lets say hello to the world for %8s time\n", count[9]);
lets say hello to the world for    tenth time
>   15: }½½½½½½½½■?¶
printhello!__tmainCRTStartup+0x10b:
004013a8 83c40c          add     esp,0Ch
printhello!__tmainCRTStartup+0x111:
004013ae 3975e4          cmp     dword ptr [ebp-1Ch],esi ss:0023:0013ffa4=000000
00
printhello!__tmainCRTStartup+0x116:
004013b3 50              push    eax
quit:

答案 1 :(得分:0)

您需要将符号和src路径添加到windbg,它将无法正常解决此问题。

您可以使用Gui添加路径:

'文件>符号文件路径...' 和 '文件>源文件路径...'使用gui 或者分别是 ctrl + S ctrl + P

或者您可以使用命令执行此操作 .srcpath.sympath