From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11001 invoked by alias); 6 Feb 2013 23:19:01 -0000 Received: (qmail 10978 invoked by uid 22791); 6 Feb 2013 23:19:00 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ee0-f44.google.com (HELO mail-ee0-f44.google.com) (74.125.83.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Feb 2013 23:18:54 +0000 Received: by mail-ee0-f44.google.com with SMTP id l10so1069316eei.31 for ; Wed, 06 Feb 2013 15:18:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=hKic+g1bD4fioC2rcamNNsjirx7NwNww17+femEtyN0=; b=CkDbJjZ8jrSz5E0BKOE4god8kFHHDcvgpMcGJyvtSpHytR2c7y+L7ZjM5KoREr4clw T5euiS9Q6aUhhhHc8TjCygXA93PvbKpgWPNTprL+TeO+FgHnULtIj76hume1XHLyKSoc k48t/DTit0Og96WhIVgWDedeVzf21NkLYlUaUECYMnmtFp8Rp23AMcPJLu/ef3pftcc1 qBqx+6etbBj3+Qaqgdti120mDGYCXbfwOh42RYbV2N0b1+2UFLECII3BV6Hl1XHMFm8d OQVcIhDHlLDgZ7kUX9l7OYQOMebfsMBfk8vfsy2FnhJ7AZbJmgwrN1STnBek5izOIdaV 1rjg== MIME-Version: 1.0 X-Received: by 10.14.199.135 with SMTP id x7mr1998448een.18.1360192733000; Wed, 06 Feb 2013 15:18:53 -0800 (PST) Received: by 10.14.100.200 with HTTP; Wed, 6 Feb 2013 15:18:52 -0800 (PST) In-Reply-To: References: <87y5f1w6xc.fsf@fleche.redhat.com> Date: Wed, 06 Feb 2013 23:19:00 -0000 Message-ID: Subject: Re: [RFC - Python Scripting] New method gdb.Architecture.disassemble From: Siva Chandra To: Matt Rice Cc: Tom Tromey , gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkzcDZWTsR/xFvyt2hf0l6baL053Q4VbdQ87BONbRxTEYo+Q7pmAly37faDFAxrVz5PAanzEbPtMdpRmuH9+lAd7y4RjgFK4jn2YfTggZJKEoiGNiRH3DwV74Cm2TO9Ku1lwrzUYenCNLVPq5hVMPsRDW3vMsJVUZGk4VOPC8BqYjczWZBWQeda+MtHjaVyAb4p757RJQdbb0+nYaQp8F62QEqW9g== X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-02/txt/msg00171.txt.bz2 On Wed, Feb 6, 2013 at 2:31 PM, Matt Rice wrote: > so, list can look like: > [1, 2, 3] or ["a" = 1, "b" = 2, "c" = 3] > > both are created with a ui_out_type_list > thus we don't know if to create a python dict or list, until something is > added, > and the existence of a fldname > > then a 2nd issue entirely separate is that: > ["a" = 1, "a" = 2, "a" = 3] is also valid and seen in practice > > so sanely working around those issues is where the thoughts on adding > new uiout types comes from. Firstly, thanks a lot to everyone for the feedback. Due to my limited knowledge of GDB and its internals, my patch implements a Python ui_out which I reversed engineered based on how gdb_disassembly works and what I could understand from ui-out.c. I was hoping to get this this kind of feedback, and I have now got it :) 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 About table headers; are they relevant when ui_out is not for display? That is, is it necessary to provision for them in the Python ui_out object? Thanks, Siva Chandra