[英]Debug C++ code in visual studio from python code running in eclipse
Does any one know how we can do this? 有谁知道我们怎么做到这一点? I have python code in eclipse and whenever it calls c++ functions, i want the break point to go to the visual studio c++ project.
我在eclipse中有python代码,每当它调用c ++函数时,我都想让断点转到visual studio c ++项目。
You can use a __debugbreak
in visual studio so that every time the code is invoked it triggers the debugger (you may want to search the function in MSDN). 您可以在visual studio中使用
__debugbreak
,以便每次调用代码时都会触发调试器(您可能希望在MSDN中搜索该函数)。
Insert the instruction in the C++ function (or class method) you want to debug, eg 将指令插入要调试的C ++函数(或类方法)中,例如
void foo()
{
__debugbreak();
[...]
}
at this point compile the library and run the python script, when library loads and the code is executed a messagebox appears telling if you want to attach the visual studio debugger. 此时编译库并运行python脚本,当库加载并执行代码时,会出现一个消息框,告诉您是否要附加visual studio调试器。
It is the replacement of the old __asm { int 3 }
. 它是旧
__asm { int 3 }
的替代品。
If the C++ app runs as a separate process then its pretty easy. 如果C ++应用程序作为一个单独的进程运行,那么它很容易。 You can run the process yourself or attach visual studio to existing running process and put break points.
您可以自己运行该过程,也可以将visual studio附加到现有的运行过程并放置断点。
If C++ code is an embedded DLL/LIB then you can use python as debug/launch process. 如果C ++代码是嵌入式DLL / LIB,那么您可以使用python作为调试/启动过程。 As soon as python will load the DLL/LIB into your python code visual studio will activate your break points.
一旦python将DLL / LIB加载到您的python代码中,visual studio将激活您的断点。
Alternatively you can also add windows debugger launcher calls to your code. 或者,您也可以将Windows调试器启动器调用添加到您的代码中。 As soon as your code gets executed, you will see a dialog box asking if you want to attach a debugger.
一旦代码执行,您将看到一个对话框,询问您是否要附加调试器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.