Windows Debugging w/o MS

Thomas Lenarz Thomas.Lenarz at netcologne.de
Wed May 23 02:56:01 EDT 2007


On Tue, 22 May 2007 18:49:04 -0700, "Christopher Anderson"
<sidewinder.asu at gmail.com> wrote:

>problem is, when I attempt to use it, I get a segfault. Now, I'm
>pretty sure this segfault is just a bug in my C++ code. So of course,
>I would like to debug this thing somehow. I tried using the mingw gdb
>giving it my python.exe to run, but obviously this python has no debug
>info, and wasn't even compiled with mingw. I was hoping it would still
>somehow debug my extension module right, but when I do a backtrace
>after it segfaults, I get nothing useful.

I have no experience in writing python extension-modules. However, I
would give the following scheme a try. It helped myself a lot while
debugging segfaulting modules plugged into a framework, for  which I
haven't had the source-code. It is done easyly and quickly. If it
doesn't  work you won't lose a lot of time:

1. At the earliest stage of your own C++-Code, code an infinite loop
depending on a single variable.

e.g.: int i=0; for(;i==0;);

2. When you start your test now and it does not segfault before your
code is reached, the process will be stuck in this loop.

3. Attach gdb to the process using the --pid option. (Unfortunately I
did this only on Unix with dbx. Hope it works on windows and gdb as
well.

4. Look if you are now able to see your source in gdb.

5. Set a breakpoint immediately after the infinite loop.

6. Free the loop by setting the variable i to a value different from
0.

7. You should be able to single step now.

I am not sure if this will work. But it might be worth a try.

Thomas






More information about the Python-list mailing list