逐行跟踪模块?

Trace a module line by line?

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

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

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

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

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:

需要在windbg中添加符号和src路径,将无法正常解析。

您可以使用 Gui 添加路径:

'File>Symbol File Path...' 和 'File>Source File Path...' 使用图形用户界面 或 ctrl+Sctrl+P 分别。

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