Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Debugging Embedded Python

1 view
Skip to first unread message

Mark Charsley

unread,
Jul 12, 2002, 9:44:00 AM7/12/02
to
We've got a (win32) C++ program that has an embedded python interpreter
that runs a bunch of scripts. We've been asked to enable it's users to run
the python scripts under a debugger, allowing the users to put in
breakpoints, examine/alter values etc.

Now the C++ program basically does the following...

- Initialises some C++ stuff
- loads in the python DLL
- initialises some python stuff
- starts a long complicated bunch of processing that bounces between
python and C++

One way to get the python running under a debugger is to tweak the system
so that the C++ executable becomes a C++ DLL that can be loaded as a
python extension. Then it's just a case of having a tiny python script
that

- initialises some python stuff
- loads in the C++ DLL
- initialises some C++ stuff
- starts a long complicated bunch of processing that bounces between
python and C++

It's then a simple matter of running the above python script in a python
debugger.

While this would work, it has two irritants
1) the work required to change the C++ executable into a python extension
DLL
2) the python debugger will (presumably) be built to use release-build
DLL's. Which means that any build where we can run the whole thing under a
python debugger (i.e. a release build) can't easily be run under a C++
debugger and vice versa.

Are there any win32-compatible python debuggers out there which can
a) do an "Attach to process" and debug any executable that's using the
python DLL
and/or
b) have source or pre-built debug builds available?

Many TIA

--

Mark - personal opinion only, could well be wrong, not representing
company, don't sue us etc. etc.

nealj

unread,
Jul 12, 2002, 4:10:00 PM7/12/02
to
Check out Hap www.sourceforge.net/projects/hapdebugger - it is very
close to what you need and I'll be posting an update in the next few
days that will make it even easier to use it to debug embedded python
scripts.

mark.charsley@REMOVE_THIS.radioscape.com (Mark Charsley) wrote in message news:<memo.20020712144413.1996A@a.a>...

Chris Liechti

unread,
Jul 12, 2002, 4:49:26 PM7/12/02
to
news:memo.20020712144413.1996A@a.a:

> We've got a (win32) C++ program that has an embedded python
> interpreter that runs a bunch of scripts. We've been asked to enable
> it's users to run the python scripts under a debugger, allowing the
> users to put in breakpoints, examine/alter values etc.

this is in the sys module:
settrace(tracefunc)
Set the system's trace function, which allows you to implement a Python
source code debugger in Python. See section 9.2, ``How It Works,'' in the
chapter on the Python debugger. The function is thread-specific; for a
debugger to support multiple threads, it must be registered using
settrace() for each thread being debugged.

so you could write the trace function in your c/c++ extension and register
it in the embedded python interpreter. that means that you write your own
debugger but its one way. an other is that you could (maybe) use a remote
debugger like HAP (somewhere on sf.net).

chris
--
Chris <clie...@gmx.net>

Anurag Uniyal

unread,
Jul 16, 2002, 3:42:04 AM7/16/02
to
Hi,
I think what you want can be found at
archaeopteryx.com.
You can get a 30 day trial verison.
I am using it and for debugging my embedded scripts
and by importing a script provided by archaeopteryx.com you can
attach debugger to any running script.

rgds
Anurag

mark.charsley@REMOVE_THIS.radioscape.com (Mark Charsley) wrote in message news:<memo.20020712144413.1996A@a.a>...

Mark Charsley

unread,
Jul 17, 2002, 5:40:00 AM7/17/02
to
In article <memo.20020712144413.1996A@a.a>,
mark.charsley@REMOVE_THIS.radioscape.com (Mark Charsley) wrote:

> We've got a (win32) C++ program that has an embedded python interpreter
> that runs a bunch of scripts. We've been asked to enable it's users to
> run the python scripts under a debugger, allowing the users to put in
> breakpoints, examine/alter values etc.

<SNIP>

Thanks all for your advice. Have finally got the pythonWin debugger
working. Not in my original executable, mind you (which still acts as if
the breakpoint had been hit, the debugger brought up and then instantly
shutdown by the user), but in a second executable which uses the same
source files and, as far as I've been able to tell, the same compiler
settings.

Don't you just love working with a completely deterministic, fully
predictable systems :-)

0 new messages