gdb python how to output integer for examine memory
Dave Angel
davea at davea.name
Mon Mar 24 08:22:59 EDT 2014
Wesley <nispray at 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
More information about the Python-list
mailing list