how to debug extended module?

J

junyoung

Hi, I am a newbie who want to implement a extend module to use native
python language with my own shared library.

to test wrapper library(extend module, name is 'test.so'), I created
some test-cases.

There are some errors what I couldn't figure our reasons.

ex)
SystemError: error return without exception set
.....
....

so, I ran the ddd with python and then I set test.py as a argument of
it.

ex)
ddd python

in ddd
run with arguments : test.py


but in this situation, I couldn't step in my own shared library
(compiled as the debug mode).

Is there any clear way to debug my extend module(that it, debug shared
library)??
 
D

Diez B. Roggisch

junyoung said:
Hi, I am a newbie who want to implement a extend module to use native
python language with my own shared library.


If it's a C shared library, don't bother extending it. Use ctypes to
wrap it. Much easier, and no need for a compiler.
to test wrapper library(extend module, name is 'test.so'), I created
some test-cases.

There are some errors what I couldn't figure our reasons.

ex)
SystemError: error return without exception set
....
...

This indicates that you violated the exception protocol.

http://docs.python.org/c-api/exceptions.html
so, I ran the ddd with python and then I set test.py as a argument of
it.

ex)
ddd python

in ddd
run with arguments : test.py


but in this situation, I couldn't step in my own shared library
(compiled as the debug mode).

Is there any clear way to debug my extend module(that it, debug shared
library)??

I do it like this:

# gdb python
gdb $ set args test.py
gdb $ run


You can only debug a binary program (test.py isn't one, python is). But
trough the args, you get yours script running.

It *might* help to have a python debug build, I personally never needed
that.

Diez
 
J

junyoung

If it's a C shared library, don't bother extending it. Use ctypes to
wrap it. Much easier, and no need for a compiler.






This indicates that you violated the exception protocol.

http://docs.python.org/c-api/exceptions.html






I do it like this:

# gdb python
gdb $ set args test.py
gdb $ run

You can only debug a binary program (test.py isn't one, python is). But
trough the args, you get yours script running.

It *might* help to have a python debug build, I personally never needed
that.

Diez

here is my results. anyway, check this out.

(gdb) set args connect.py
set args connect.py
(gdb) run
run
Starting program: /usr/bin/python connect.py
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7f619747e6e0 (LWP 23683)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x415a9950 (LWP 23686)]
[Thread 0x415a9950 (LWP 23686) exited]
[New Thread 0x415a9950 (LWP 23687)]
[Thread 0x415a9950 (LWP 23687) exited]
Traceback (most recent call last):
File "connect.py", line 25, in <module>
main()
File "connect.py", line 18, in main
connection_test()
File "connect.py", line 15, in connection_test
cnxn.close()
SystemError: error return without exception set

Program exited with code 01.
(gdb)

as you see, I can't load symbol table information from gdb.

now python is defaulted installed as release.

my os is ubuntu
the python is installed in /usr/bin
the python version is 2.5.1

do i need to re-install python as debug mode?
 
J

junyoung

junyoung schrieb:
If it's a C shared library, don't bother extending it. Use ctypes to
wrap it. Much easier, and no need for a compiler.
This indicates that you violated the exception protocol.
I do it like this:
# gdb python
gdb $ set args test.py
gdb $ run
You can only debug a binary program (test.py isn't one, python is). But
trough the args, you get yours script running.
It *might* help to have a python debug build, I personally never needed
that.

here is my results. anyway, check this out.

(gdb) set args connect.py
set args connect.py
(gdb) run
run
Starting program: /usr/bin/python connect.py
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7f619747e6e0 (LWP 23683)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x415a9950 (LWP 23686)]
[Thread 0x415a9950 (LWP 23686) exited]
[New Thread 0x415a9950 (LWP 23687)]
[Thread 0x415a9950 (LWP 23687) exited]
Traceback (most recent call last):
File "connect.py", line 25, in <module>
main()
File "connect.py", line 18, in main
connection_test()
File "connect.py", line 15, in connection_test
cnxn.close()
SystemError: error return without exception set

Program exited with code 01.
(gdb)

as you see, I can't load symbol table information from gdb.

now python is defaulted installed as release.

my os is ubuntu
the python is installed in /usr/bin
the python version is 2.5.1

do i need to re-install python as debug mode?

after compiling it(python) as debug mode, I could debug it ;(

I don't still know why I have to compile it as debug mode to step in
my own library. interesting....
 
Y

Yinon Ehrlich

here is my results. anyway, check this out.
(gdb) set args connect.py
set args connect.py
(gdb) run
run
Starting program: /usr/bin/python connect.py
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x7f619747e6e0 (LWP 23683)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0x415a9950 (LWP 23686)]
[Thread 0x415a9950 (LWP 23686) exited]
[New Thread 0x415a9950 (LWP 23687)]
[Thread 0x415a9950 (LWP 23687) exited]
Traceback (most recent call last):
File "connect.py", line 25, in <module>
main()
File "connect.py", line 18, in main
connection_test()
File "connect.py", line 15, in connection_test
cnxn.close()
SystemError: error return without exception set
Program exited with code 01.
(gdb)
as you see, I can't load symbol table information from gdb.
now python is defaulted installed as release.
my os is ubuntu
the python is installed in /usr/bin
the python version is 2.5.1
do i need to re-install python as debug mode?

after compiling it(python) as debug mode, I could debug it ;(

I don't still know why I have to compile it as debug mode to step in
my own library. interesting....

BTW: No need to compile, just 'apt-get install python-dbg'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top