This is the mail archive of the gdb-patches@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]

Re: [RFC] A new command 'explore'


Hello,

I have not yet seen anything about a policy on contributions
implemented in extension languages. However, I have now implemented
the 'explore' command in C. The patch is attached. I will add
documentation after the basics of this patch are approved.

2012-02-08 Siva Chandra <sivachandra@google.com>

? ? ? ? New command 'explore' which helps explore values in scope.
? ? ? ? * explore.c: Implemention of the 'explore' command.
? ? ? ? * Makefile.in: Add rules for compiling and linked explore.c.
? ? ? ? * testsuite/gdb.base/explore.c: C program used for testing
? ? ? ? the new 'explore' command.
? ? ? ? * testsuite/gdb.base/explore.exp: Tests for the new 'explore'
? ? ? ? command.
? ? ? ? * testsuite/gdb.base/Makefile.in: Add explore to EXECUTABLES

To recollect, the idea behind the 'explore' command is as follows:
Often, when exploring a new code base which has complicated data
structures, we would like to explore the data structure values
top-down. For example, if a struct is part of a struct/union is part
of another struct/union, then we typically explore the top-level
struct/union in the first pass. In subsequent passes, we might want to
go deeper by exploring the structs/unions embedded in the top level
struct. We might infact want to explore all the way up to the leaf
values. The ‘explore’ command enables a user to do such a top-down
exploration of data structures interactively. Not only values, even
types can be explored in a similar fashion.

Example of value exploration:
========================
(gdb) explore cs
The value of 'cs' is of type 'struct ComplexStruct' with the following fields:
   s = <Enter 0 to explore this field of type 'struct SimpleStruct'>
   u = <Enter 1 to explore this field of type 'union SimpleUnion'>
  sa = <Enter 2 to explore this field of type 'SS [10]'>

Enter the field number of choice: 2
'cs.sa' is an array of elements of type 'SS'.
Enter the index you want to explore in 'cs.sa': 1
The value of '(cs.sa)[1]' is of type 'SS' which is a typedef of type
'struct SimpleStruct'.
The value of '(cs.sa)[1]' is of type 'struct SimpleStruct' with the
following fields:
  a = 1 .. (Value of type 'int')
  d = 11.1 .. (Value of type 'double')

Press enter to return to parent value:

Returning to parent value...

'cs.sa' is an array of elements of type 'SS'.
Enter the index you want to explore in 'cs.sa':
Returning to parent value...
The value of 'cs' is of type 'struct ComplexStruct' with the following fields:
   s = <Enter 0 to explore this field of type 'struct SimpleStruct'>
   u = <Enter 1 to explore this field of type 'union SimpleUnion'>
  sa = <Enter 2 to explore this field of type 'SS [10]'>

Enter the field number of choice:
(gdb)

Example of type exploration:
========================
(gdb) explore struct SimpleStruct
'struct SimpleStruct' has the following fields:
  a = <Enter 0 to explore this field of type 'int'>
  d = <Enter 1 to explore this field of type 'double'>

Enter the field number of choice: 1
field 'd' of 'struct SimpleStruct' is of a scalar type 'double'.
Press enter to return to enclosing type:

Returning to parent type...
'struct SimpleStruct' has the following fields:
  a = <Enter 0 to explore this field of type 'int'>
  d = <Enter 1 to explore this field of type 'double'>

Enter the field number of choice:
(gdb)

Thanks,
Siva Chandra

Attachment: c_explore_command_patch_v1.txt
Description: Text document


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