From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5765 invoked by alias); 12 Dec 2013 19:36:06 -0000 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 Received: (qmail 5754 invoked by uid 89); 12 Dec 2013 19:36:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ea0-f177.google.com Received: from mail-ea0-f177.google.com (HELO mail-ea0-f177.google.com) (209.85.215.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 12 Dec 2013 19:36:04 +0000 Received: by mail-ea0-f177.google.com with SMTP id n15so455455ead.22 for ; Thu, 12 Dec 2013 11:36:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=7HK9JJj9MYkax9PUdfy9Cla0N8KeNoohLjAwDFz70GM=; b=DJmYdv2C7gTQ1mmL3JmLFvF9lhIMlBBZZy8Fdaosf5DyhlfFIK3IcOgIF4CRa7Y1Jy AXdHOotQz/mTcc2palcTgZGQlMNs8h/icYwNqTvlTZNTAfjfmcq416ZahzZ80BUouUH4 n4KX7tE29l5eW1+LdvH9LMwLXWgra3Rq5WvmmG+9GiYB7ZEec8ytlTd5Ne+J6q8orc0B yG1sinPHtXet+bc2Wi0PvWoEYbrUDRuDERlJ4rnIuONcfjKXu1kO5dn9cp5TEyFMQ4QY 9K4Up+XWxuWnxh12hxMVsMt0v6FxkQfbnohWU5T093b2g7n/3pJmJC8NgXyvi5Tl0UE/ YOdw== X-Gm-Message-State: ALoCoQm8FZjMsLaEHqK8k2w+2xH8E3Xv2CBNG95TkpVlw4Oy0fqCPNNIK5e1vEg46DgDMcYTs5RqKiVqNMVTUhFO/18XpJKMwJtMgqZ6OM+TBqoUVo5blmZsmIdLdFdWRzBAST5l0coNpiGW+HZuRRw6n+Yf69znZXExh3OKi5mz1wqkcZGco2RieoJHfEk9u2TPqG9ScYD7Yt/HCfytxgmPmZv1le23Ug== MIME-Version: 1.0 X-Received: by 10.15.61.134 with SMTP id i6mr9840508eex.48.1386876961731; Thu, 12 Dec 2013 11:36:01 -0800 (PST) Received: by 10.14.151.72 with HTTP; Thu, 12 Dec 2013 11:36:01 -0800 (PST) In-Reply-To: References: Date: Thu, 12 Dec 2013 19:36:00 -0000 Message-ID: Subject: Re: [RFC/Patch v3] PR 16113: Allow gdb.Field objects as subscripts on gdb.Value objects From: Siva Chandra To: gdb-patches Cc: Eli Zaretskii Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00511.txt.bz2 This requires a doc review as there is small addition to NEWS and gdb.texinfo after Eli approved the changes last. On Wed, Dec 11, 2013 at 3:23 PM, Siva Chandra wrote: > The attached patch addresses all of Tom's comments except two for > which I have responses below: > > Tom> What about TYPE_CODE_UNION and TYPE_CODE_RANGE? > Tom> Offhand I don't recall if other types present "fields". > Tom> Maybe TYPE_CODE_FUNC? TYPE_CODE_COMPLEX? > > I missed TYPE_CODE_UNION so I have added it in the attached patch. The > other types do not support the "fields" method. [But, is it a mistake > that we do not support fields for other methods? The documentation > does talk about ranges, functions and methods. At this point, I am > tempted to ask as to why we should "overload" the method "fields" to > return function/method args? Can we bring in a class hierarchy of > types where in gdb.Type exists as a base class, and gdb.TypeStruct, > gdb.TypeFunction etc. are derived from it. That way, we can add > relevant methods to the respective classes. For example, > gdb.TypeFunction will have "args" as a method and not "fields". I > understand the notion of fields is overloaded internally, but we could > make the Python API clearer.] > > Siva> + arg = type_to_type_object (type); > Siva> + if (arg == NULL) > Siva> + goto fail; > > Tom> I think if TYPE is not a gdb.Type then this will return -1 without > Tom> setting the Python exception. > > The above comment is for the change in py-type.c. The variable TYPE in > question here is "struct type" and not gdb.Type. I think > type_to_type_object would return NULL only if PyObject_New called in > it fails. Is an exception not set by PyObject_New on failure? > > 2013-12-11 Siva Chandra Reddy > > PR 16113: Allow gdb.Field objects with the subscript operator on > gdb.Value objects of struct/class values. > * NEWS (Python Scripting): Add entry for the new feature and the > new attribute of gdb.Field objects. > * python/py-type.c (gdbpy_is_field): New function > (convert_field): Add 'parent_type' attribute to gdb.Field > objects. > * python/py-value.c (valpy_getitem): Allow subscript value to be > a gdb.Field object. > (value_has_field): New function > (get_field_flag): New function > * python/python-internal.h (gdbpy_is_field): Add declaration. > > testsuite/ > * gdb.python/py-value-cc.cc: Improve test case. > * gdb.python/py-value-cc.exp: Add new tests. > > doc/ > * gdb.texinfo (Values From Inferior): Add a note about using > gdb.Field objects as subscripts on gdb.Value objects. > (Types In Python): Add description about the new attribute of > gdb.Field objects.