This is the mail archive of the
mailing list for the GDB project.
Re: [RFC] A new command 'explore'
- From: Tom Tromey <tromey at redhat dot com>
- To: Siva Chandra <sivachandra at google dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 21 Dec 2011 11:17:49 -0700
- Subject: Re: [RFC] A new command 'explore'
- References: <CAGyQ6gyAwr2zuv3NYpdk09vPyYpuFkyiErEhw-vws-WfuLDxiw@mail.gmail.com> <CAGyQ6gw4_-Z-vpAeC_AHF=Ou=PDazUjTXQYLGx1Qj+ABrX0KnA@mail.gmail.com>
>>>>> "Siva" == Siva Chandra <firstname.lastname@example.org> writes:
Siva> Attached is a patch which implements a new command 'explore' using the
Siva> GDB Python API.
It seems like a nice addition to me.
It would have helped a little if you had included a sample session in
I read the patch, though not in an extremely deep way.
Siva> + """Internel class which invokes other explorers."""
Siva> + raw_input("\nPress enter to return to parent value...")
The explorer seems to require a lot of enter-pressing.
To me it seems like this would get in the way.
I did not actually try it out, though.
Siva> + try:
Siva> + deref_value = value.dereference()
Siva> + except RuntimeError:
I think that it should be possible to catch gdb.MemoryError here.
That would be more precise.
I didn't notice a way to explore a pointer that is really a decayed
Siva> + array_range = value.type.range()
Siva> + if index < array_range or index > array_range:
I am not sure this will always do the right thing.
It seems possible to me for an array not to have a valid range.
Siva> + @staticmethod
Siva> + def get_type_from_str(type_str):
Siva> + try:
Siva> + # Assume the current language to be C/C++ and make a try.
Siva> + return gdb.parse_and_eval("(%s *)0" % type_str).type.target()
This is a nice trick.
If you have time, it would be nice to extend the API so that this trick
isn't needed. I think a type-parsing method would be useful.
Siva> + raise gdb.GdbError(
Siva> + ("ERROR: \'%s\' neither evaluates to a value nor is a type "
No need for "ERROR: ", I think.