Silent failures in python

I often experience issues when implementing VTK based python scripts, which are really hard to debug, sometimes not even an error message window is showing up (in my current case with vtkMetaImageWriter). Is there any way to make the debugging of the VTK python integration more verbose? It is a really frustrating trial and error sometimes …

You can enable debugging for any VTK object by calling its DebugOn() method, which provides more messages during executing. However, most likely it will help much more if you look at the source code of the class.

You can also run VTK in a debugger, step-by-step, but for that you need debug symbols. I don’t see any download links for the debug symbols on the VTK download page. So, you probably need to build VTK yourself with debug symbol generation enabled (on Windows, build the RelWithDebInfo configuration).

@ben.boeckel would it be possible to update the VTK wheels build process so that VTK is built with debug information generation enabled, and then make the debug information files available for download?

I’m sure it’s possible, but is there any documentation on a useful format that can easily be used? I don’t think wheels have any mechanism for this.

On Windows, probably the most common approach is to just zip all the pdb files and make it available on your download site.

If you want to be more fancy then you can create a folder structure in a standard format using sysmstore utility that you can serve from a web server. It helps with automatically finding the correct pdb version for the binaries.

1 Like

Sure, but how do those get used? Put another way, how would I test such a release artifact? What about non-Windows platforms?

You copy the pdb files to the same folder as the dll files and Visual Studio finds and uses the symbols automatically. All you need is to attach Visual Studio to the Python executable, open a VTK source file, and add a breakpoint anywhere. Visual Studio stops at the breakpoint and you can run the code step by step.

It works similarly on other operating systems ("-dbg" packages are often used in linux for distributing debug symbols) but I haven’t done much interactive debugging on non-Windows platforms, so I don’t know the details.