简体   繁体   中英

Debug C++ code running from python script in Eclipse

I have a C++ project and a python script that calls .exe file. I set breakpoints in one of cpp files, but they are not hit. I can't even go into this C++ project. I found similar question here, but for Visual Studio: Debug C++ code in visual studio from python code running in eclipse

Is there a similar way to do this trick in Eclipse? Or is there some other approriate way to debug C++ code, which is called from another process? I tried to attach to the process, but the problem is that, after script makes call, child process finishes very fast and I can't catch its pid.

To debug the executable, use the DebugBreak function in place of a breakpoint in your program. So in your C++ code, call DebugBreak somewhere in your program, preferably near the beginning -- this will serve as the breakpoint.

What will happen is that when your C++ executable runs from Python, your C++ executable will "crash" (not really crash, but it will seem like it did). What really is happening is that the DebugBreak function was called.

After the Windows OS goes through its set of message boxes saying "your application has something wrong with it" (note that there really is nothing wrong with the program), you are then given the option to debug it. Choose the "debug" option, the debugger you want to use (which will be Visual Studio), and you should be able from that point on to single step through your C++ code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM