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 - Python Scripting] New method gdb.Architecture.disassemble


On Wed, Feb 6, 2013 at 3:18 PM, Siva Chandra <sivachandra@google.com> wrote:
> Based on what Matt says in his comments, it seems like a leaf row can
> look like one of these 3 possibilities:
>
> 1. [1, 2, 3]
> 2. ['a' : 1, 'b': 2, 'c': 3]
> 3. ['a': 1, 'a': 2, 'a': 3]
>
> 1 and 2 can be encapsulated with fundamental Python data structures. I
> am not aware of any fundamental Python data structure which can
> capture 3. So, is using a helper class called LabelValuePair a good
> idea? With this, all leaf rows can be lists whose elements are either
> all values, or are all LabelValuePairs: [value, value, value] or
> [LabelValuePair, LabelValuePair, LabelValuePair]. Does this sound
> reasonable? We can always go in for a list of single element dicts,
> but I think that kind of makes it ugly. LabelValuePair can look like
> this (in its Python form):
>
> class LabelValuePair(object):
>   def __init__(self, label, value):
>     self.label = label # not a writable attribute
>     self.value = value # not a writable attribute

Or, could it be a named tuple:
http://docs.python.org/2.7/library/collections.html#collections.namedtuple
The down side is that they are available only on Python 2.4 and higher.


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