how to debug extended module?

Discussion in 'Python' started by junyoung, Dec 1, 2009.

  1. junyoung

    junyoung Guest

    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)??
     
    junyoung, Dec 1, 2009
    #1
    1. Advertising

  2. junyoung schrieb:
    > 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
     
    Diez B. Roggisch, Dec 1, 2009
    #2
    1. Advertising

  3. junyoung

    junyoung Guest

    On 12¿ù1ÀÏ, ¿ÀÈÄ6½Ã14ºÐ, "Diez B. Roggisch" <> wrote:
    > junyoung schrieb:
    >
    > > 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


    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?
     
    junyoung, Dec 2, 2009
    #3
  4. junyoung

    junyoung Guest

    On 12¿ù2ÀÏ, ¿ÀÀü9½Ã54ºÐ, junyoung <> wrote:
    > On 12¿ù1ÀÏ, ¿ÀÈÄ6½Ã14ºÐ, "Diez B. Roggisch" <> wrote:
    >
    >
    >
    >
    >
    > > junyoung schrieb:

    >
    > > > 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

    >
    > 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....
     
    junyoung, Dec 3, 2009
    #4
  5. On Dec 3, 8:40 am, junyoung <> wrote:
    > On 12¿ù2ÀÏ, ¿ÀÀü9½Ã54ºÐ, junyoung <> wrote:
    >
    >
    >
    > > On 12¿ù1ÀÏ, ¿ÀÈÄ6½Ã14ºÐ, "Diez B. Roggisch" <> wrote:

    >
    > > > junyoung schrieb:

    >
    > > > > 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

    >
    > > 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'
     
    Yinon Ehrlich, Dec 6, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RonL
    Replies:
    0
    Views:
    753
  2. ringos75
    Replies:
    0
    Views:
    969
    ringos75
    Apr 14, 2005
  3. wen
    Replies:
    1
    Views:
    495
    Daniel Dittmar
    Aug 23, 2005
  4. Carl J. Van Arsdall

    C Extended module init/cleanup

    Carl J. Van Arsdall, Jan 23, 2006, in forum: Python
    Replies:
    1
    Views:
    319
    Farshid Lashkari
    Jan 23, 2006
  5. James O'Brien
    Replies:
    3
    Views:
    258
    Ben Morrow
    Mar 5, 2004
Loading...

Share This Page