gdb python how to output integer for examine memory

Wesley nispray at gmail.com
Mon Mar 24 09:37:31 EDT 2014


Hi Dave,
  Thanks for your response.
It's just a simple script for test:-)
My concern is use gdb to monitor variable in memory within python process.
For details, in my origin post, just wanna why cannot output interger value from the address.

Maybe here is not right for gdb python question..but seems I cannot post question at another gdb group.

So, post here, since it's also related to python,in case anyone knowns this.
Sorry for that.

Wesley

在 2014年3月24日星期一UTC+8下午8时22分59秒,Dave Angel写道:
> 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