[prev in list] [next in list] [prev in thread] [next in thread]
List: gdb
Subject: Re: Python enabled gdb: accessing local variables
From: Tom Tromey <tromey () redhat ! com>
Date: 2009-07-21 15:56:38
Message-ID: m3r5waf2rt.fsf () fleche ! redhat ! com
[Download RAW message or body]
>>>>> "Alex" == Alex Presniakov <flagist0@gmail.com> writes:
Alex> First, I can't access local variables using 'python' command -- for
Alex> example, "python print i" returns an error "NameError: name 'i' is not
Alex> defined".
This accesses the Python variable 'i', not the variable 'i' in the
inferior.
You probably want gdb.parse_and_eval, but we haven't merged that yet.
Alex> But if I access this variable from convenience function,
Alex> everything goes right (Also, I'm even not sure that gdb sees debug
Alex> symbols -- "python print gdb.current_objfile" returns None).
The current objfile is usually None. It is only valid when debuginfo is
actually being read.
Alex> And is there any difference between running python code from
Alex> scripts and from interpreter?
Not really. There may be differences that are intrinsic to Python, like
if you use import the code is evalled in a module or whatever.
Alex> Second, gdb gets segfault if I eval 'source -p somefile' more than
Alex> one time.
Please file a bug report. Include a stack trace of gdb if you can. If
it is dependent on the contents of the file, then include the file as
well.
Alex> And the last question. I'm trying to add command that compares
Alex> buffers.
Alex> def invoke(self,first,second,len):
The arguments to invoke are supplied by gdb. You can't provide just any
function signature here, it has to be the one specified in the manual:
def invoke (self, arg, from_tty):
The meaning of the arguments is also described in the manual.
Tom
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic