Debugging Subprocesses in PyDev - python

We are trying to debug C++ code called by a Python script (using subprocess.call). Is there a way to do this with PyDev? I am a Java developer and we are developing an Eclipse RCP application, and can write custom code as needed to make this work.

If you want to debug c++ code, you need a c++ debugger (and PyDev won't really help you there).
My suggestion is looking for a c++ debugger in this case (you can use gdb in windows and linux -- on windows you can also use visual c++ if you want -- you should be able to attach to a running process on both cases -- I think that CDT also has some gdb integration which you can use if you set it up properly).

Related

Visual Studio Python WPF debugging

So I spend almost all of my programming time on Linux, but recently, for a project, I had to try out PTVS and WPF. As it is a very good framework, I would like to learn it further, but the issue in question is a huge disadvantage when compared to running python programs on Linux.
So say I have a little WPF project on IronPython2.7, with some buttons and some functions handling those buttons' click events. The problem is that not every exception/error present in that code is shown in debugger: sometimes it just says "the process exited with code 0x01". That, for example, happens if I try to access an array element outside of array bounds.
The question is: is there a way to fix this and be able to see all the errors and exceptions while debugging a WPF program?
By default, IronPython projects in Visual Studio run using the managed debugger. This makes it really easy to debug mixed Python/.NET code, however, you don't get quite as nice an experience when you only have Python code.
To change this, right-click your project in Solution Explorer and select Properties. On the Debug tab, there's a dropdown for the launcher - you can see a screenshot here.
It's probably got IronPython (.NET) launcher selected, but changing it to Standard Python launcher should give you better pure-Python debugging. The downside is that you won't be able to step into .NET code anymore, and it's a little bit more invasive. In general though, the improvements are worth it if you are not using IronPython to extend a .NET application.

Which IronPython editor I can use to develop scripts for Tibco Spotfire controls

Can we use any IRONPython editor to develop scripts for Tibco Spotfire controls.
Can we use IDLE editor to develop IRONPython scripts for Tibco Spotfire? If yes then how to integrate the tibco module with IDLE editor, Can anyone help on this??
You should be able to use any development tool (ide) which supports ironpython. One of the best in my point of view is PTVS (Python Tools for Visual Studio), just search for it. But when you want some thing very lightweight with only some syntax hilighting, i prefer using Visual Studio Code or Atom. But PTVS has a lot of nice features. One of the most important ones are those for debugging, because they prevent you from using some console printing or some thing similar as debugging tool. Just take a look at it.
EDIT
As far as i can see, it should work just fines with PTVS. Taking a look at this, is't just some API as any other api: API-Doc
Spotfre has its own IDE for developing scripts but it is very poor one when analysing its functionalities. I dont think you can use any IDE to debug the scripts but you can at least use the one suggested by BendEg to make creation of the code more 'pleasant'.
Spotfire uses IronPython, which is a .NET implementation of python. In other words, is .NET driven by python. To test simple python functions, you can use CodeSkulptor, a cloud based python interpreter. For IronPython, you can use this java based online version but again, this is to test simple scripts

Debug C-library from Python (ctypes)

I have a Python-program that uses ctypes and a C-shared library (dll-file). As an IDE, I am using Eclipse, where both projects will be developed (the C-shared library and the python program that uses it).
My idea is: when I start the Python-program in Debug-mode, can I somehow debug the shared library, which is written in C, too? Meaning: Can I set breakpoints and when the Python-program reaches that breakpoint in the shared library, executing stops and I can change variable values etc.?
Actually, it is a fairly simple thing to do using the CDT and PyDev environments in Eclipse.
I assume here that you have already configured the projects correctly, so you can build and debug each one seperately.
Basically, you simply need to start the Python project in Debug mode and then to attach the CDT debugger to the running python process. To make it easier I'll try to describe it step by step:
Run your Python project in debug mode. Put a breakpoint somewhere after the loading of the dll using ctypes. Make note of the pid of the python process created (you should see a first line in the console view stating the pid. something like: pydev debugger: starting (pid: 1234))
Create a Debug configuration for your CDT project, choosing the type "C/C++ Attach to Application". You can use the default configuration.
Debug your project using the configuration you've created. A window should appear, asking you which process you want to attach to. Choose the python process having the right pid.
You can now add breakpoints to you C code.
You'll have two debuggers in the debug perspective, as if they were two different processes. You should always make sure the C/C++ debugging session is running when you work with the python debugger - as long as the C/C++ debugging session is suspended, the python debugger will be unresponsive.
As far as I know, not in eclipse.
However, Python tools for visual studio has this capability:
https://pytools.codeplex.com/wikipage?title=Mixed-mode%20debugging
It is also possible to get this for free. From the Microsoft website, you'll need (as well as a copy of Windows)
1) Visual Studio (paid Pro+ version or free Express versions (starting w 2.1Beta))
2) PTVS extension (this gives VS Python support)
3) A Python interpreter and Python Libraries (these are not bundled with PTVS)
This means that you can debug python and c side-by-side. Calls to libraries written in c are captured by the debugger, provided that they were compiled with symbols by visual studio.
Note that the capabilities of mixed mode debugging tend to be less featured for native python, but it is still capable of using the regular native debugger.

Pretty print in Eclipse CDT: unable to look at any variable

I'm developing a QT based application on ARM, iMX6 device.
Using toolchain from Freescale and Eclipse CDT Kepler, I would like to use pretty printer with GDB.
I followed the tutorial on http://anadoxin.org/blog/node/98 and the setup seems fine (no error while starting GDB).
However when looking at debug view panel, I'm not able to look at any datatype (not only QT but also int, double etc, the whole panel is blank. Furthermore also writing print variable to gdb Eclipse console doesn't generate a valid output).
I think my setup is fine:
GNU gdb (GDB) 7.6 for ARM device
Python: Python 2.7.3
Eclipse: Kepler
KUbuntu 12.04
Is there anyone that can help me understand what is wrong?
Can I send any command to gdb console in order to understand why pretty printer aren't working fine, and even worse, they corrupt the whole gdb debug view variables?
Any help will be really appreciated
I finally fixed it.
The problem was that my toolchain for ARM was built without the support for Python in GDB. If you search the web, you will find that there is a flag in the configuration named (--with-python).
Using it and rebuilding gdb, you will be able to use the python scripts available at
Pretty printers
Hope this will be helpful for the stackoverflow community.
best regards

Efficient ways for Python debugging when called from within C++ code

I have a C++ application (on Windows XP) that invokes some Python code. I currently use Winpdb as my python debugger.
Using winpdb as the debugger has some disadvantages since firstly, I need to add a pdb statement, and there is little control afforded to me during the execution since I add dynamic breakpoints.
Does anyone know of tools that can be used that work in a similar fashion to Visual Studio 2010 (or Visual Studio in general)? Most important for me is to be able to set up and remove breakpoints while the application is executing, much like we can do using Visual Studio.
I have looked at ActiveState Komodo IDE6 and Eclipse Python PyDev, but I do not think either one actually fits the bill. This is because I have various python modules that are initialized
using the C++ function call "Py_InitModule" with a name that might be different from the name of the .py file. There modules are not recognized by Komodo and Eclipse Python PyDev.
Please let me know if you have any suggestions. Thank you for your help.
Well, for me it seems that it'd work in PyDev... The only thing is that you have to attach the tracing to the debugger -- use pydevd.settrace(suspend=False) on the thread you want to trace and after that it should 'synchronize' the current breakpoints and their additions/removals ( more references: http://pydev.org/manual_adv_remote_debugger.html ) -- note that you could use pydevd.settrace(suspend=True) to work as a breakpoint as in in pdb.
I didn't really understand why you said it wouldn't work. Can you post your specific example of what's not working to see how that would be solvable? (some things may be customized in pydevd_file_utils.py to help in translating breakpoint paths).

Categories

Resources