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


Groups > comp.lang.python > #68994

Re: gdb python how to output integer for examine memory

From dieter <dieter@handshake.de>
Subject Re: gdb python how to output integer for examine memory
Date 2014-03-25 08:49 +0100
References <e1e8c3a2-5d8d-4aae-9a5d-82af79be8c4c@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.8505.1395733762.18130.python-list@python.org> (permalink)

Show all headers | View raw


Wesley <nispray@gmail.com> writes:

>   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:
>
> ...
> (gdb) frame 5
> #5  0x00000000004d01a7 in PyEval_EvalFrameEx (f=Frame 0x201e130, for file test.py, line 6, in next (i=1), throwflag=0) at Python/ceval.c:2666
> 2666                x = call_function(&sp, oparg);
> (gdb) py-locals
> i = 1
> (gdb) pyo i
> No symbol "i" in current context.

Quite a lot of time has passed since I last had to debug Python
processes at C level -- thus, my memory may be unreliable.

When I remember right, then "pyo" is used to interprete
a C level variable as a Python object (and print it) -- not
a Python level variable. In your case, "i" is a Python level variable.

You must carefully distinguish between the C level and the Python level.
Some commands expect C level names/objects;
others may expect Python level names/objects.

To learn how you can obtain the value of a Python variable,
I see two approaches: look through the list of provided commands
(and their documentation) and try to figure out which might be applicable
and then may some tests; or look at the implementation of "py-locals"
and use this knowledge to define you own command (for this,
you will also need to understand the gdb language to define commands).

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