“直到”的模拟词是“直到”。像 WinDbg 的 GDB 中的命令或在 WinDbg 中离开循环的简单方法?

发布于 2024-10-16 04:16:12 字数 288 浏览 6 评论 0原文

目前我按鼠标右键选择“将文件路径复制到剪贴板”菜单。接下来左键单击源代码行,直到执行代码、循环外(该行号在 WinDbg 的右下角指示)。

接下来在命令提示符中我设置断点(通过从剪贴板路径插入到文件并键入从状态栏读取的行号):

bp `d:\home\devel\plugin\plugin-svn\common\win-gui-admin.c:788`

这似乎太复杂了。在 GDB 中,为了离开循环,resured 命令until。有什么办法可以在WinDbg中做到这一点吗?

Currently I press right mouse button to select "Copy file path to clipboard" menu. Next left click to source line until where execute code, outside loop (this line number indicated in bottom right corner of WinDbg).

Next in command prompt I set breakpoint (by inserting from clipboard path to file and typing line number, which read from status bar):

bp `d:\home\devel\plugin\plugin-svn\common\win-gui-admin.c:788`

This seems too complicate. In GDB for leaving loops resurved command until. Any way to do this in WinDbg?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼波传意 2024-10-23 04:16:12

F7 为您提供“运行到光标”命令,我认为它可以满足您的要求。只需将光标放在您想要的任何源代码行上,然后按 F7。

-斯科特

F7 gives you the "Run to Cursor" command, which I think does what you're looking for. Just put the cursor on whatever source line you want and then hit F7.

-scott

明明#如月 2024-10-23 04:16:12

又是一个很晚的答案,但可以在 Windbg

.lines 中使用源代码级语法来启用 src 行支持
l+* 启用所有 src 选项
lsf 加载 src 文件
ls from,to 检查当前 src 文件中的 src 行
lsc 显示当前的 src 文件
`module!srcfile:linenum` 用于表示任何 src 文件中的任何行(src 语法需要用重音符号而不是单引号括起来)

这是一个示例演练

jmpouttaloo:\>dir /b
jmpouttaloo.cpp

jmpouttaloo:\>type jmpouttaloo.cpp
#include <stdio.h>
int main (void)
{
    int i=0,j=0,k=0,l=0;
    while (i++ < 100)
    {
        while (j++ < 100)
        {
            while(k++ < 100)
            {
                l++;
            }
            l++;
        }
        l++;
    }
    printf("%d\n",l);
    return 0;
}
jmpouttaloo:\>cl /Zi /nologo jmpouttaloo.cpp
jmpouttaloo.cpp

jmpouttaloo:\>dir /b *.exe
jmpouttaloo.exe

jmpouttaloo:\>jmpouttaloo.exe
300

.lines 在 cdb 中打开 src 行支持(在 Windbg 中默认为打开)
l+* 启用所有 src 行选项
lsf 加载src文件jmpouttaloo.cpp
在 main 上设置 bp 并运行 exe

jmpouttaloo:\>cdb -c ".lines;l+*; lsf jmpouttaloo.cpp; bp jmpouttaloo!main;g" jmpouttaloo.exe

单步执行,p 每步执行一个 src 行
分 6 步,我们进入最里面的 while 循环
现在我们想要系统地退出每个循环

ls start , count 显示从 start number 到 startnumber+count 的 src

行,直到我们到达特定的 src 行

do g Graveaccent colon linenumber Graveaccent

完整的 src行语法如下

graveaccent modulename! filename : linenumber graveaccent

第一次运行

0:000> cdb: Reading initial command '.lines;l+*; lsf jmpouttaloo.cpp; bp jmpouttaloo!main;g'


Breakpoint 0 hit
>    3: {
0:000> p
>    4:     int i=0,j=0,k=0,l=0;
0:000>
>    5:     while (i++ < 100)
0:000>
>    7:         while (j++ < 100)
0:000>
>    9:             while(k++ < 100)
0:000>
>   11:                 l++;
0:000>
>   12:             }
0:000>
>    9:             while(k++ < 100)

我们在循环第 12 行回到第 9 行我们需要在第 13 行退出此循环

0:000> ls 13,6   view src lines from line number 13 to 18 (6 lines )

13:             l++;
14:         }
15:         l++;
16:     }
17:     printf("%d\n",l);
18:     return 0;

0:000> dv  view locals we have stepped only once so all locals must be 1

          j = 0n1
          l = 0n1
          k = 0n1
          i = 0n1

0:000> g `:13` lets get out of innermost loop and look at the locals
>   13:             l++;
0:000> dv  
              j = 0n1
              l = 0n100 <-------
              k = 0n101 <-------------
              i = 0n1

0:000> g `:15` getting out of second innermost loop and inspect locals
>   15:         l++;
0:000> dv
              j = 0n101
              l = 0n200
              k = 0n200
              i = 0n1
0:000> g `:17` getting out of all loops   and inspect locals
>   17:     printf("%d\n",l);
0:000> dv
              j = 0n200
              l = 0n300
              k = 0n200
              i = 0n101
0:000> p
300    <--------------- output of printf 
>   18:     return 0;
0:000>

第二次运行

another jig this time we break on line 15 straight without even loading the src


jmpouttaloo:\>cdb -c ".lines;g `jmpouttaloo!jmpouttaloo.cpp:15`;dv;q" jmpouttaloo.exe | grep -A 4 "j ="
              j = 0n101
              l = 0n200
              k = 0n200
              i = 0n1
quit:

jmpouttaloo:\>

again a very late answer but one can use source level syntax in windbg

.lines to enable src line support
l+* to enable all src options
lsf to load src file
ls from,to to inspect src lines from current src file
lsc to show current src file
`module!srcfile:linenum` to denaote any line from any src file (src syntax needs to be wrapped in grave accents not single quotes)

here is a sample walkthrough

jmpouttaloo:\>dir /b
jmpouttaloo.cpp

jmpouttaloo:\>type jmpouttaloo.cpp
#include <stdio.h>
int main (void)
{
    int i=0,j=0,k=0,l=0;
    while (i++ < 100)
    {
        while (j++ < 100)
        {
            while(k++ < 100)
            {
                l++;
            }
            l++;
        }
        l++;
    }
    printf("%d\n",l);
    return 0;
}
jmpouttaloo:\>cl /Zi /nologo jmpouttaloo.cpp
jmpouttaloo.cpp

jmpouttaloo:\>dir /b *.exe
jmpouttaloo.exe

jmpouttaloo:\>jmpouttaloo.exe
300

.lines turns on src line support in cdb (it is on by defaukt in windbg )
l+* enables all src line options
lsf load src file jmpouttaloo.cpp
set a bp on main and run the exe

jmpouttaloo:\>cdb -c ".lines;l+*; lsf jmpouttaloo.cpp; bp jmpouttaloo!main;g" jmpouttaloo.exe

stepping with p steps one src line per step
in 6 steps we land inside the innermost while loop
now we want to get out of each loop systematically

ls start , count shows the src lines from start number to startnumber+count

to run until we get to certain src line

do g graveaccent colon linenumber graveaccent

the complete src line syntax as follows

graveaccent modulename! filename : linenumber graveaccent

first run

0:000> cdb: Reading initial command '.lines;l+*; lsf jmpouttaloo.cpp; bp jmpouttaloo!main;g'


Breakpoint 0 hit
>    3: {
0:000> p
>    4:     int i=0,j=0,k=0,l=0;
0:000>
>    5:     while (i++ < 100)
0:000>
>    7:         while (j++ < 100)
0:000>
>    9:             while(k++ < 100)
0:000>
>   11:                 l++;
0:000>
>   12:             }
0:000>
>    9:             while(k++ < 100)

we are in loop line 12 back to line 9 we need to exit out of this loop at line 13

0:000> ls 13,6   view src lines from line number 13 to 18 (6 lines )

13:             l++;
14:         }
15:         l++;
16:     }
17:     printf("%d\n",l);
18:     return 0;

0:000> dv  view locals we have stepped only once so all locals must be 1

          j = 0n1
          l = 0n1
          k = 0n1
          i = 0n1

0:000> g `:13` lets get out of innermost loop and look at the locals
>   13:             l++;
0:000> dv  
              j = 0n1
              l = 0n100 <-------
              k = 0n101 <-------------
              i = 0n1

0:000> g `:15` getting out of second innermost loop and inspect locals
>   15:         l++;
0:000> dv
              j = 0n101
              l = 0n200
              k = 0n200
              i = 0n1
0:000> g `:17` getting out of all loops   and inspect locals
>   17:     printf("%d\n",l);
0:000> dv
              j = 0n200
              l = 0n300
              k = 0n200
              i = 0n101
0:000> p
300    <--------------- output of printf 
>   18:     return 0;
0:000>

second run

another jig this time we break on line 15 straight without even loading the src


jmpouttaloo:\>cdb -c ".lines;g `jmpouttaloo!jmpouttaloo.cpp:15`;dv;q" jmpouttaloo.exe | grep -A 4 "j ="
              j = 0n101
              l = 0n200
              k = 0n200
              i = 0n1
quit:

jmpouttaloo:\>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文