如何使用Visual Studio调试进程? [英] How to debug a process using Visual Studio?

查看:218
本文介绍了如何使用Visual Studio调试进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果应用程序†崩溃,





我打了Debug,Visual Studio是我当前注册的Just-In-Time(JIT)调试器:





Visual Studio出现,但无法调试任何内容:



)或不支持符号( OllyDbg Delphi )。此外,我的问题是使用Visual Studio进行调试,因为我已经安装了它,而且它已经是我注册的JIT。



如何使用Visual Studio调试程序?



另外:有没有人写过支持Microsoft符号服务器的图形调试器?



编辑:将标题更改为流程,而不是应用,因为后者意味着我的应用程序。



编辑:假设原始应用程序是由Steve Gibson用汇编语言编写的。也就是说,没有源代码或调试信息。 Visual Studio应该仍然能够向我展示一个汇编转储。

解决方案

看看截图,Visual Studio正在调试在运行模式下,您需要在执行进程之前先断开执行,才能查看调用堆栈等等。



打破进程的执行您需要点击断点,或者您可以随时使用暂停/中断所有工具栏项( Control + Alt + 来打破进程的执行。



然后,您应该能够访问Debug - > Windows菜单下的以下窗口:




  • 反汇编窗口

  • 注册窗口

  • 调用堆栈窗口

  • 模块窗口显示已加载模块的列表,以及从中加载相应符号的位置(如果已加载)



一些其他有用的窗口:




  • 如果您一次调试多个进程,则进程窗口很有用

  • 线程窗口

  • 记忆窗口(其中有四个)

  • 本地窗口



其中一些默认情况下可能不可见,具体取决于您在第一次启动Visual Studio时选择的窗口配置 - 如果找不到它们,然后右键单击工具栏,然后转到自定义添加它们。



Visual studio不会从反汇编重建soucre代码 - 您真的需要原始的源代码可用,否则符号几乎肯定不会与调试的源代码相匹配。



如果您调试未使用源代码的非托管模块,那么我建议您至少尝试 WinDbg - 它的用户界面有时候有点笨重,它确实有一个陡峭的学习曲线,但它是一个非常强大的调试器,支持Visual Studio不支持许多功能 - 它可能更适合您需要做的那种调试。



(Visual Studio是一个奇妙的调试器,但主要用于调试源代码可用的模块,因此缺少某些功能,有利于更好的用户体验) 。


If an application† crashes,

I hit "Debug" and Visual Studio is my currently registered Just-In-Time (JIT) debugger:

Visual Studio appears, but there's no way to debug anything:

  • I do not see any disassembly
  • I do not see any registers (assuming it runs on a CPU with registers)
  • The call stack is empty (assuming the CPU has a stack pointer)
  • I do not see any symbols (assuming it had any)
  • I do not see reconstructed source code from reflection (assuming it was managed)

Other JIT debugger products are able to show disassembly, but they are either command-line based (Debugging Tools for Windows), or do not support symbols (OllyDbg, Delphi). Additionally, my question is about debugging using Visual Studio, since I already have it installed, and it is already my registered JIT.

How do you debug a program using Visual Studio?

Alternatively: has anyone written a graphical debugger that supports the Microsoft symbol server?

† Not, necessarily, written in Visual Studio.

Edit: Changes title to process rather than application, since the latter somehow implies "my application."

Edit: Assume the original application was written in assembly language by Steve Gibson. That is, there is no source code or debug information. Visual Studio should still be able to show me an assembly dump.

解决方案

Looking at the screenshot it appears that Visual Studio is currently debugging in Run mode - you need to break execution of the process before it makes sense to look at things like the call stack, etc...

To break execution of the process you either need to hit a breakpoint, or you can break execution of the process at any time by using the Pause / Break all toolbar item (Control + Alt + Break).

Then you should be able to access the following windows under the Debug -> Windows menu:

  • The disassembly window
  • The registers window
  • The call stack window
  • The modules window shows a list of loaded modules along with where their corresponding symbols are loaded from (if loaded)

Some other useful windows:

  • The processes window is useful if you are debugging more than one process at a time
  • The Threads window
  • The Memory window (there are four of them)
  • The Locals window

Some of these might not be visible by default depending on which window configuration you selected when you first started Visual Studio - if you can't find them then right click on the toolbar and goto customise to add them.

Visual studio doesn't reconstruct soucre code from disassembly - you really need to have the original source code available to you, otherwise the symbols almost certainly won't match the source code you are debugging.

If you are debugging unmanaged modules without source code then I recommend you at least try WinDbg - its user interface is a bit clunky at times, and it does have a steep learning curve, however it is a very powerful debugger supporting many features that Visual Studio doesn't - it may be more suited to the sort of debugging you need to do.

(Visual Studio is a fantastic debugger, however it's primarily used to debug modules where the source code is available and so it lacks certain features in favour of a better user experience).

这篇关于如何使用Visual Studio调试进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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