Windbg 如何使用VirtualBox从另一个VM调试一个VM中的Windows?

Windbg 如何使用VirtualBox从另一个VM调试一个VM中的Windows?,windbg,remote-debugging,Windbg,Remote Debugging,我正在为Windows 7编写一些启动(预登录)代码,并希望能够对其进行调试(如果只是想看看它是如何工作的,因为Microsoft的文档非常糟糕) 我的环境是Linux主机上的VirtualBox,有三个Windows虚拟机(一个Windows 2008域控制器、一个Windows 7开发机器和一个Windows 7测试机器),我希望能够使用两个虚拟机的虚拟串行连接从开发机器远程调试测试机器的启动过程 [在另一个生命中,我曾在Windows主机上使用VMware workstation从一个Li

我正在为Windows 7编写一些启动(预登录)代码,并希望能够对其进行调试(如果只是想看看它是如何工作的,因为Microsoft的文档非常糟糕)

我的环境是Linux主机上的VirtualBox,有三个Windows虚拟机(一个Windows 2008域控制器、一个Windows 7开发机器和一个Windows 7测试机器),我希望能够使用两个虚拟机的虚拟串行连接从开发机器远程调试测试机器的启动过程

[在另一个生命中,我曾在Windows主机上使用VMware workstation从一个Linux虚拟机调试另一个Linux虚拟机中的Linux内核驱动程序,因此我知道这类事情可能是可行的。]

我见过有人使用windbg从主机上调试VirtualBox VM中的Windows,但我需要从第二个客户机上调试(因为我的主机不是Windows)。有人知道怎么做吗

编辑: 在发布之前,我已经尝试过明显的方法。我在每个VM配置中创建了一个虚拟串行端口,并将它们连接到相同的主机管道,由开发虚拟机(调试器)创建,并由测试虚拟机(被调试器)使用。然后我跑了

bcdedit /dbgsettings serial debugport:1 baudrate:115200
bcdedit /debug {current} on
在测试虚拟机中,并将其关闭。在dev VM中运行windbg,选择内核调试(在正确的串行端口上),并重新启动测试VM。出现了一些关于没有任何可用符号和测试VM挂起的消息

后来我发现了这篇文章:这篇文章(尽管那个家伙正在使用Windows主机)似乎完全描述了我尝试过的方法,但他的测试VM并没有挂起。我在wndbg窗口中得到的输出与他的相同,但在开始“WindowsXP内核…”一行之前停止

我现在不太确定这个问题是否与VirtualBox有关,更不确定我是否正确使用了windbg。任何帮助都将不胜感激

另一次编辑我尝试将测试虚拟机的虚拟串行端口连接到主机文件,并在该文件中获得一些调试输出。我已尝试将两个虚拟机的虚拟串行端口设置为指向主机管道,并在Dev虚拟机中运行终端(而不是WinDbg),并在终端中获得调试信息

我想我现在已经确定这肯定是WinDbg而不是VirtualBox的问题(我将删除VirtualBox标签并用WinDbg替换),但我不确定WinDbg为什么不说话

更多信息: 我刚刚升级到VirtualBox 4.2.4(不确定版本是否重要),并再次研究了这个问题

我重建了测试虚拟机,更加耐心

现在看来测试虚拟机正在运行——我最终在windbg窗口中获得了一些输出——但调试操作系统启动大约需要15分钟!这对于日常内核调试显然没有用处。我不知道为什么这么慢。。。如果我在dev-VM中运行一个简单的终端而不是windbg(当然,调试信息大部分都是垃圾),那么就不会有明显的减速


有什么想法吗?

我知道这是一个非常可怕的死尸,但是

您是否尝试过为内核模式网络调试设置被调试者?我认为经济放缓在很大程度上是因为连续剧的g.d.速度太慢了

如果/当M$决定破坏该链接时,以上文章的这些部分是您需要执行的操作,以完成此设置:

设置目标计算机

要设置目标计算机,请执行以下步骤:

Verify that the target computer has a supported network adapter.

Connect the supported adapter to a network hub or switch using standard CAT5 or better network cable. Do not use a crossover cable, and do not use a crossover port in your hub or switch.

In an elevated Command Prompt window, enter the following commands, where w.x.y.z is the IP address of the host computer, and n is a port number of your choice:

    bcdedit /debug on
    bcdedit /dbgsettings net hostip:w.x.y.z port:n

bcdedit will display an automatically generated key. Copy the key and store it on a removable storage device like a USB flash drive. You will need the key when you start a debugging session on the host computer.

Note  We strongly recommend that you use an automatically generated key. However, you can create your own key as described later in the Creating Your Own Key section.

If there is more than one network adapter in the target computer, use Device Manager to determine the PCI bus, device, and function numbers for the adapter you want to use for debugging. Then in an elevated Command Prompt window, enter the following command, where b, d, and f are the bus number, device number, and function number of the adapter:
bcdedit /set "{dbgsettings}" busparams b.d.f
Reboot the target computer.
要连接到它,请使用以下步骤:

Using WinDbg

On the host computer, open WinDbg. On the File menu, choose Kernel Debug. In the Kernel Debugging dialog box, open the Net tab. Enter your port number and key. Click OK.

You can also start a session with WinDbg by opening a Command Prompt window and entering the following command, where n is your port number and Key is the key that was automatically generated by bcdedit when you set up the target computer:

windbg -k net:port=n,key=Key

If you are prompted about allowing WinDbg to access the port through the firewall, allow WinDbg to access the port for all the different network types.

Using KD

On the host computer, open a Command Prompt window. Enter the following command, where n is your port number and Key is the key that was automatically generated by bcdedit when you set up the target computer:

kd -k net:port=n,key=Key

If you are prompted about allowing KD to access the port through the firewall, allow KD to access the port for all the different network types.

您是否尝试重新启动调试计算机?这是很久以前的事了,但我记得上次使用VirtualBox时,我必须在WinDbg在调试器中运行时重新启动调试对象,以便建立连接。内核连接配置对话框中有一个选项“reconnect”,使WinDbg在调试对象重新启动时保持活动状态。是。如果我在Dev虚拟机上启动windbg,而测试虚拟机正在运行,并且什么也没有发生(两个虚拟机都继续运行,没有调试输出)。只有在重新启动测试VM(调试对象)时,我才能在windbg窗口中获得一些输出,测试VM才会挂起。它可能只是在断点处等待,但我已尝试在windbg窗口中键入g(可能没有足够的次数?),完全重复:。听起来和你描述的很相似,但如果你严格按照说明去做,你可能会发现最初出了什么问题。我想强调两点:a。调试器应该创建管道(而被调试器不应该);B在“内核调试”下,必须取消选中“COM”、“Pipe”。祝你好运。是的,这个问题(你的问题!)几乎是我的重复。你似乎做了和我一样的事。我一直在做其他事情,但需要重新审视一下,我会检查是否遗漏了什么。谢谢你的“两点”。。。我这样做是正确的(从我使用终端而不是windbg时看到调试输出的事实可以看出)。。。问题是windbg似乎看不到客户端启动,并一直等待建立连接(并且“管道”未选中)。这似乎是windbg的问题,而不是VirtualBox的问题。是的,这个问题有点像necro,因为我现在正在做完全不同的事情(感谢$Dedity,与Windows无关!)。不过,我不确定串行通信的速度是否是启动缓慢的原因,因为调试对象在连接到简单终端或只是将其输出转储到文件时启动速度足够快。调试程序运行时可能会发生更多通信。。。但您可以在15分钟内以115k2发送大量数据。这是个谜,但我不再在乎(直到下次)。不过,谢谢你的意见。它可能会帮助其他人。