Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68873

Re:gdb python how to output integer for examine memory

From Dave Angel <davea@davea.name>
Subject Re:gdb python how to output integer for examine memory
Date 2014-03-24 08:22 -0400
Organization news.gmane.org
References <e1e8c3a2-5d8d-4aae-9a5d-82af79be8c4c@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.8447.1395663507.18130.python-list@python.org> (permalink)

Show all headers | View raw


 Wesley <nispray@gmail.com> Wrote in message:
> Hi all,
>   I am trying to use gdb debug python script.
> I am using gdb7.7 and python2.7.6, here is my simple test script: 
> import time
> 
> def next(i):
>     time.sleep(10)
>     i = 1 - i
> 
> i = 1
> while True:
>     next(i)
> When this script running, gdb attach to it, and here is snippet:
> 

I cannot help with gdb, but I can point out that you have two
 separate variables here. Decrement ing the local has no effect on
 the global value.

The preferred way is to return any values from the function that
 you want to use after it exits. 
def next(i):
     time.sleep(10)
     i = 1 - i
     return i

i = 1
while True:
    i =next(i)

Another possibility,  generally a bad idea,  is declaring i global
 in the function. 

-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

gdb python how to output integer for examine memory Wesley <nispray@gmail.com> - 2014-03-24 03:20 -0700
  Re:gdb python how to output integer for examine memory Dave Angel <davea@davea.name> - 2014-03-24 08:22 -0400
    Re: gdb python how to output integer for examine memory Wesley <nispray@gmail.com> - 2014-03-24 06:37 -0700
  Re: gdb python how to output integer for examine memory dieter <dieter@handshake.de> - 2014-03-25 08:49 +0100
    Re: gdb python how to output integer for examine memory Wesley <nispray@gmail.com> - 2014-03-25 01:07 -0700
      Re: gdb python how to output integer for examine memory dieter <dieter@handshake.de> - 2014-03-26 08:10 +0100
        Re: gdb python how to output integer for examine memory Wesley <nispray@gmail.com> - 2014-03-26 18:04 -0700

csiph-web