简体   繁体   English

从eclipse中运行的python代码调试Visual Studio中的C ++代码

[英]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.

相关问题 调试从Eclipse中的python脚本运行的C ++代码 - Debug C++ code running from python script in Eclipse C ++代码未在Visual Studio中运行 - C++ code not running in Visual Studio 无法在Visual Studio Code中调试C ++代码 - Unable to debug c++ code in Visual Studio Code 无法在 Visual Studio 代码中调试我的 c++ 代码 - Not able to debug my c++ code in visual studio code 在 Linux 上从 Visual Studio Code 调试 Python C++ 扩展 - Debugging Python C++ extension from Visual Studio Code on Linux C ++-将C ++代码从Visual Studio移植到Linux Eclipse IDE时出现问题 - C++ - issue while porting C++ code from Visual Studio to Linux Eclipse IDE 如何在 Visual Studio 代码中调试 bazel c++ google 测试 - how to debug bazel c++ google test in visual studio code 在 macOS 上使用 Visual Studio Code 调试 C++ 标准库 - Debug C++ Standard Library with Visual Studio Code on macOS ImportError:从 C++ 运行 python 文件时,无法在 Visual Studio 调试控制台中导入名称“etree” - ImportError: cannot import name 'etree' in Visual Studio Debug console while running python file from C++ 可以从命令行运行C ++代码,但不能从Visual Studio中的调试模式运行 - can run C++ code from command line but not from debug mode in visual studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM