This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Python enabled gdb: accessing local variables


Hi!
I have some problems.

First, I can't access local variables using 'python' command -- for
example, "python print i" returns an error "NameError: name 'i' is not
defined". But if I access this variable from convenience function,
everything goes right (Also, I'm even not sure that gdb sees debug
symbols -- "python print gdb.current_objfile" returns None). And is
there any difference between running python code from scripts and from
interpreter?

Second, gdb gets segfault if I eval 'source -p somefile' more than one time.

And the last question. I'm trying to add command that compares
buffers. But when calling it from gdb shell, I get one error for any
combination of arguments (including empty) -- "TypeError: invoke()
takes exactly 4 arguments (3 given)". I understand, that it's somehow
related to self parameter, but i don't know how can 3 arguments be
passed with empy arguments list. Below is the declaration part of the
command:

class DiffBuffers(gdb.Command):
ÂÂÂ "Compare two buffers"

ÂÂÂ def __init__(self):
ÂÂÂÂÂÂÂ super(DiffBuffers,self).__init__("bufcmp",gdb.COMMAND_NONE)

ÂÂÂ def invoke(self,first,second,len):


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]