attaching debugger to runinng python program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • alf

    #1

    attaching debugger to runinng python program

    Hi,

    I have a two fold question:
    -how to attach the debugger to running multi threaded program
    -the objective is to find an infinite loop in one of threads which
    makes the whole thingy going craze (100%CPU)

    The program itself is not easy, in fact quite hude and sometimes it
    takes hours to get to that infloop state.

    Any insight?

    Andy
  • Bill Pursell

    #2
    Re: attaching debugger to runinng python program


    alf wrote:
    Hi,
    >
    I have a two fold question:
    -how to attach the debugger to running multi threaded program
    -the objective is to find an infinite loop in one of threads which
    makes the whole thingy going craze (100%CPU)
    >
    The program itself is not easy, in fact quite hude and sometimes it
    takes hours to get to that infloop state.
    On linux:

    % python
    >>import os
    >>os.getpid()
    54321

    Now, in another shell,
    % gdb
    (gdb) attach 54321

    If you want debugging symbols, recompile python with -g.

    Comment

    • alf

      #3
      Re: attaching debugger to runinng python program

      Bill Pursell wrote:
      Now, in another shell,
      % gdb
      (gdb) attach 54321
      >
      Thx for the reply. But I wish to debug the python program, not python
      interpreter itself.

      Comment

      • olsongt@verizon.net

        #4
        Re: attaching debugger to runinng python program


        alf wrote:
        Bill Pursell wrote:
        Now, in another shell,
        % gdb
        (gdb) attach 54321
        >
        Thx for the reply. But I wish to debug the python program, not python
        interpreter itself.
        I haven't used this, but it looks like it's worth a try:



        Comment

        • Nebur

          #5
          Re: attaching debugger to runinng python program

          You may try winpdb.
          I find it to be a comfortable debugger that also can attach to running
          programs. (You need to add a line in your code where the program should
          stop and wait for the debugger to attach.)
          I am satisfied with it, but I did not debug a multi theaded app.
          However, it can handle threads. I'd be glad to later hear whether it
          did what you need, or not:



          Regards, Ruben

          Comment

          Working...