是否可以在调试时以编程方式与Visual Studio调试器通信?

时间:2022-06-12 02:58:03

I would like to control options on the debugger without using the debugging GUI's, preferably from inside the code being debugged. I would think that would be quite difficult, but maybe my debugged code can request a service from independent code that will communicate with the debugger.

我想在不使用调试GUI的情况下控制调试器上的选项,最好是在被调试的代码中。我认为这将是非常困难的,但也许我的调试代码可以从与调试器通信的独立代码请求服务。

This relates to another question of mine on controlling when to break on exceptions.

这涉及我控制何时打破例外的另一个问题。

2 个解决方案

#1


2  

You can write Visual Studio macros that can do anything the GUI can, but they can get rather involved. See the MSDN documentation on Automation and Extensibility for Visual Studio

您可以编写可以执行GUI所能执行的任何操作的Visual Studio宏,但是它们可以相互参与。请参阅有关Visual Studio的自动化和可扩展性的MSDN文档

Doing this from the code being debugged would be tricky, you would definitely need some new form of communication with VS, maybe a custom add-in. I don't think an independent service would fundamentally help here. The biggest problem is that your code will stop running when the debugger breaks.

从正在调试的代码执行此操作将是棘手的,您肯定需要一些与VS的新形式的通信,可能是自定义加载项。我不认为独立服务会从根本上帮助到这里。最大的问题是,当调试器中断时,您的代码将停止运行。

#2


0  

I know that you can do it with WinDBG and OutputDebugString, but for Visual Studio, I think you have to spool off another process, pipe commands to that, and have that manipulate the Debugger API.

我知道你可以使用WinDBG和OutputDebugString来做到这一点,但是对于Visual Studio,我认为你必须假脱机另一个进程,将命令管道到那个,并让它操纵Debugger API。

#1


2  

You can write Visual Studio macros that can do anything the GUI can, but they can get rather involved. See the MSDN documentation on Automation and Extensibility for Visual Studio

您可以编写可以执行GUI所能执行的任何操作的Visual Studio宏,但是它们可以相互参与。请参阅有关Visual Studio的自动化和可扩展性的MSDN文档

Doing this from the code being debugged would be tricky, you would definitely need some new form of communication with VS, maybe a custom add-in. I don't think an independent service would fundamentally help here. The biggest problem is that your code will stop running when the debugger breaks.

从正在调试的代码执行此操作将是棘手的,您肯定需要一些与VS的新形式的通信,可能是自定义加载项。我不认为独立服务会从根本上帮助到这里。最大的问题是,当调试器中断时,您的代码将停止运行。

#2


0  

I know that you can do it with WinDBG and OutputDebugString, but for Visual Studio, I think you have to spool off another process, pipe commands to that, and have that manipulate the Debugger API.

我知道你可以使用WinDBG和OutputDebugString来做到这一点,但是对于Visual Studio,我认为你必须假脱机另一个进程,将命令管道到那个,并让它操纵Debugger API。