如何在windbg中打印当前源代码行?

问题描述 投票:0回答:1

我想知道是否可以在windbg中显示当前源代码行吗?

现在,我每次单步执行代码时,便能够单步执行代码并在当前行之前和之后显示5行。很好,但是如果有一个命令可以按需打印当前源代码行而不必走到下一行,那就太好了。

windbg
1个回答
0
投票

如果要打印单个源行,请使用lsp默认值为20(0x14)

> lsp -a 1
WARNING: Source line display is disabled
At the prompt, display 0 source lines before and 1 after
For lsa commands, display 0 source lines before
For ls and lsa commands, display 1 source lines

现在使用lsa,其中表示当前Eip / Rip

0:000:x86> lsa .
>   28: void main(int argc, char *argv[]) {

或提供地址

0:000:x86> lsa @$ip+42
>   30:     SymInitialize(hProcess, NULL, FALSE);

您也可以将源代码行提供给lsa

0:000> lsa `symtype!symtype.cpp:16`
>   16:     if (maxcmplen == pSymInfo->NameLen) {
0:000> lsa `symtype!symtype.cpp:28`
>   28: void main(int argc, char *argv[]) {
© www.soinside.com 2019 - 2024. All rights reserved.