[Python-3000] Windows: debug mode
rasky at develer.com
Sun Feb 17 14:09:40 CET 2008
an issue related to the CRT removal/reduced usage under Windows is that
of debug mode, which I stand that it is mostly useless as it is currently
Python's debug mode under Windows mandates an ABI change: the debug
version of dynamic libraries (_d) are linked against the CRT debug
runtime, which is not ABI-compatible to the release runtime. So you
either have the _d version of all the extensions you need or you can't
even start your program in debug mode. I believe this started back in the
days where Python programs were small, had only a couple of dependencies,
and most developers were also core developers (core developers are
probably the only ones that can succesfully use the current debug mode).
Thus, what happens is that if you get a segfault in an extension library
(eg: one you're developing) within a large application, you are forced to
*recompile all your dependencies* to debug mode before being able to
debug your extension. This is long and tiresome: you might be using large
and complex extensions (like numpy or PyOpenGL) which are really hard to
compile and requires many C-level dependecies and complicated setup; in
fact, it is likely that you have always used them through their binary
release-only distributions, and now, simply to get a small stacktrace of
a crash in your extension, you are forced to setup the whole development
environment needed to recompile all those extensions!
So, what does a programmer do instead, today? It simply hacks his own
distutils script to compile his own extension in debug mode, but
*without* relying on Python's official debug mode support, that is
*without* using CRT's debug libraries; for example, adding /Zi and /DEBUG
switches to Visual Studio compiler and linker is sufficient to get a
*fully debuggable* extension that fully cooperates with the standard
Python runtime and the standard binary extensions. So, the programmer
totally ditches the official debug support (eg: --debug in distutils),
and has to come up with something himself.
Thus, I'm hereby proposing that we change this in Py3k so that Python's
debug mode does not mandate any ABI change anymore. This means that a
programmer will be able to mixmatch release-mode extensions and compile-
mode extensions, thus getting debuggability only of those extensions he
really cares. He will be able to compile in debug mode only his extension
by simply doing "setup.py build --debug" and get useful stacktraces and
debuggability (step-by-step, whatever) through it, without even needed a
debug build of Python.
If people agree on this goal, I'm willing to actually implement it in the
Python core (there must be a change in the logic through which "_d"
extensions are picked up since they would become optional rather than
required) and everywhere else it might be needed (eg: distutils).
More information about the Python-3000