[Python-bugs-list] [ python-Bugs-456738 ] Support for smoother debugging of C exts

noreply@sourceforge.net noreply@sourceforge.net
Mon, 03 Sep 2001 14:36:06 -0700


Bugs item #456738, was opened at 2001-08-29 19:42
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=456738&group_id=5470

Category: Python Interpreter Core
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Support for smoother debugging of C exts

Initial Comment:
With every new Python release, the first thing that I
do is modify Modules/main.c to add an empty function
called

void Py_DebugTrap(void) { return; }

The purpose of this function is to give me a handy
place to set a breakpoint so that I can debug my C/C++
extension modules. 

It occured to me that this handy trick might be more
generally useful and worthy of inclusion in the
standard distributions.

Thoughts?

-- Michael Aivazis (aivazis@caltech.edu)

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2001-09-03 14:36

Message:
Logged In: YES 
user_id=21627

I don't think this is universally useful. It seems that, 
at a minimum, you have to add calls to Py_DebugTrap into 
the module to make it useful, right? Then why can't you 
just set breakpoints on the lines that you want to call 
Py_DebugTrap?

If the problem is that you cannot set a breakpoint on code 
that is not yet loaded, I can give you a number of 
alternatives:
- any advanced debugger should offer to break when a 
shared library is loaded. gdb does.
- you can set a breakpoint on Py_InitModule4 (or whatever 
your extension module calls)
- you can set a breakpoint on dlsym (or whatever your 
shared library system uses to find the address of the init 
function)
- you can statically link your extension module into the 
Python interpreter, and avoid DLL problems altogether.

If these suggestions don't address your problem, please 
explain in more detail what your problem is. Otherwise, I 
propose to close this report as "won't fix".


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=456738&group_id=5470