473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Debugging embedded python

hello there!
I am playing with embedded python these days. I wrote sth like this:

------------------------------ Code -------------------------------
#include <Python.h>
#include <iostream>
#include <cmath>

/* Return the square root of an argument */
static PyObject* Fotis_root(PyObject *self, PyObject *args)
{
double d=0;
if(!PyArg_ParseTuple(args,"d",&d))
return NULL;
return Py_BuildValue("d", sqrt(d));
}

static PyMethodDef FotisMethods[] = {
{"root",Fotis_root, METH_VARARGS,
"Return the root of a double."},
{NULL, NULL, 0, NULL}
};

int main(int argc,char** argv)
{
Py_Initialize();
Py_InitModule("fotis", FotisMethods);
PyRun_SimpleString("from fotis import root");
PyRun_SimpleString("print \"Testing embedded python...\"");
FILE* fp=stdin;
char *filename="Embedded";
PyRun_InteractiveLoop(fp,filename);
Py_Finalize();
return 0;
}

------------------------------------------------------------------
I linked it to python24.lib (under eclipse cdt/win2k) and it compiles,
links and runs fine.
The problem is when I try to debug it (gdb). I cannot go single
stepping into the code, more than one threads seem to be running, I get
messages like "No source file named d:/workspace/pyTest/main.cpp", and
if I set a breakpoint to the function Fotis_root then I cannot see any
variables. In fact I cannot see no stack, no registers nothing, within
this function!
With msvc 6.0 debuging goes smoothly.
Any ideas?
Thank you.
Fotis._

Jul 21 '05 #1
2 2506
Hello Fotis,
I linked it to python24.lib (under eclipse cdt/win2k) and it compiles,
links and runs fine.
The problem is when I try to debug it (gdb). I cannot go single
stepping into the code, more than one threads seem to be running, I get
messages like "No source file named d:/workspace/pyTest/main.cpp", and
if I set a breakpoint to the function Fotis_root then I cannot see any
variables. In fact I cannot see no stack, no registers nothing, within
this function!

I *think* that you need to tell GDB where are the source directories (try
"help dir")

HTH.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)

iD8DBQFCyTUp8jAdENsUuJsRAuOgAKCntTlkEUwThAfNZou+hp cjldaiUACfd8qv
UVRflvoUJ9Xxra3JW+DfJWg=
=Nd14
-----END PGP SIGNATURE-----

Jul 21 '05 #2
Thank's a lot miki for your response!

It seems that this problem is now solved, yet a new one now occured.
And the name of my new problem is...

"<Stack is not available: Cannot access memory at address 0x1.>"

Let me rewrite the code a little bit more clearly...

//************************************************** *****************
// C O D E
//************************************************** *****************
01
//__________________________________________________ _________________
02 // Includes mpla, mpla mpla...
03 #include <Python.h>
04 #include <iostream>
05 #include <cmath>
06 using namespace std;
07
08
//__________________________________________________ _________________
09 // My function
10 /* Return the sqrt of a double */
11 static PyObject* Fotis_root(PyObject *self, PyObject *args)
12 {
13 double d=0;
14 if(!PyArg_ParseTuple(args,"d",&d)) return NULL;
15 return Py_BuildValue("d", sqrt(d));
16 }
17
18
//__________________________________________________ _________________
19 // Some python module stuff
20 static PyMethodDef FotisMethods[] = {
21 {"root",Fotis_root, METH_VARARGS,
22 "Return the root of a double."},
23 {NULL, NULL, 0, NULL}
23 };
24
25
//__________________________________________________ _________________
26 // Main program
27 int main(int argc,char** argv)
28 {
29 Py_Initialize();
30 Py_InitModule("fotis", FotisMethods);
31 PyRun_SimpleString("from fotis import root");
32 FILE* fp=stdin;
33 char *filename="Solver";
34 PyRun_InteractiveLoop(fp,filename); 35 Py_Finalize();
36 return 0;
37 }

Now lets say i set two breakpoints: line 29, and line 13. This is what
happens:
1. Breakpoint at line 29: There is a strange combination of next, step,
and other stuff that can move me from line 29 to line 34. No matter how
deeply I digged everywhere I cannot realy understand what really
happens there, but what the hack this is not what I'm really interested
in. by the way if i try too many steps then there is no way back...
2. Breakpoint at line 13: When I finally reach the much awaited line
34, the python interpreter is there and running and waiting for my
commands, which here is the fotis.root(double) command. when I give
though this command control is totally lost: i get the message
described above and after that everything seems to be dead. I really do
not know where I am, why am I there, and what exactly I am doing at the
point that I am.

What is really happening?

Any help will be very appreciated.
fotis._

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Howard Lightstone | last post by:
I know I've seen this elsewhere but I can't seem to find the answer.... I have Python embedded in a Windows application. I want to debug the non- python part of the app without using the debug...
2
by: Andrey Tatarinov | last post by:
Hi all. I have custom resource editor and wish python to be scripting language in it. But I don't want to lose ability of debugging which I currently have implementing all logic in C++. So...
2
by: A. Klingenstein | last post by:
I embedded Python in a Windows C++ program. Now I want to debug my embedded scripts which of course won't run in any IDE process. Commercial IDEs like WingIDE can attach to external processes by...
0
by: Thomas Korimort | last post by:
Hi, i have embedded the Python 2.3 engine into a C++ framework. Now i want to add to the basic editing features that are provided by this C++ framework also some debug functionality. Until now i...
1
by: Thomas Korimort | last post by:
Hi! I have embedded a Python interpreter into a C++ framework. When running some Python code in the interpreter, how can i get a traceback with line number file..., when an exception occurs? ...
3
by: Godzilla | last post by:
Has anyone install Python on Windows XP Embedded? We wish to evaluate the possible solution of installing Python with WinXPE on a PC/104 plus module. Thank you.
20
by: Jack | last post by:
Is there a Python packaging that is specifically for embedded systems? ie, very small and configurable so the user gets to select what modules to install? For Linux-based embedded systems in...
0
by: gbadamosi | last post by:
I am new to this. Please provide me information on Embedded Development and Debugging PC Tools for Python Programming. I need information on programming mode and debugging mode setting. Available...
7
by: luker | last post by:
Hello Experts, I am writing an application for a device running windows xp embedded. I want to code on my developer pc and deploy the running executable to the embedded device. - The two boxes...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.