From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75463 invoked by alias); 7 Apr 2015 17:44:35 -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 75427 invoked by uid 89); 7 Apr 2015 17:44:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-pa0-f73.google.com Received: from mail-pa0-f73.google.com (HELO mail-pa0-f73.google.com) (209.85.220.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 07 Apr 2015 17:44:32 +0000 Received: by pablj1 with SMTP id lj1so5131840pab.0 for ; Tue, 07 Apr 2015 10:44:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:mime-version:content-type :content-transfer-encoding:message-id:date:to:cc:subject:in-reply-to :references; bh=70fDa+FlwgDqhIDY3Z5v/LuLesNBOrNn/1PBN+5wJQw=; b=lpVXLBpSsTDznGEOtiXW2it0ncA11r5jSRzaaV7d6J29rVpvpD2TmBBoBfsnVXNJ2c PJZaqZHlT8fS/Pxbzp8XGKNPufVrxi7FHxWsOkb+obKL7mpdmeLTMOmEVGIwWz/6BA3O rla3IvQcExF1e/6jOPKhY3JWhb6R5/0L6e2VMzn5VbMJecdkUjd6iLpki0+1hV1Z20w2 gX7bLB+nx+DPvduysRJ9TeGxIg1PG+/IaapvCCASstI7t6lEHos2/7ft8BIACQwt8L9s lABprs45ZDPQIob5axoY11Zhn68nxM1GhGw1GRCZeBfg+q6uac1cW6BrpE56IY9HeHRU O/vQ== X-Gm-Message-State: ALoCoQmJ4cEf1kaoseaS3Rf4Fg+oOBGrwlYXEHjsITZ2/jbqzgg4mE3ePmhK2UHtnq0UTX1bJg/yeweZOcHw+sQ1xjg/+1pqP60aj7H5jG0eN0QcnIGJhVya/zFxcIarWBnVQYeW6vOtLn+gUgxE4OfOqvtMRoJRN+M0uBDe7Ihdzht88rYu4/A= X-Received: by 10.70.45.135 with SMTP id n7mr24777067pdm.9.1428428670685; Tue, 07 Apr 2015 10:44:30 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id t22si378531yho.2.2015.04.07.10.44.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 10:44:30 -0700 (PDT) Received: from ruffy2.mtv.corp.google.com ([172.17.128.107]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id xnxUW6eN.1; Tue, 07 Apr 2015 10:44:30 -0700 From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <21796.6013.264282.101943@ruffy2.mtv.corp.google.com> Date: Tue, 07 Apr 2015 17:44:00 -0000 To: Alexander Smundak Cc: gdb-patches Subject: Re: RFC: Python gdb.Type method returning optimized out gdb.Value In-Reply-To: References: X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00241.txt.bz2 Alexander Smundak writes: > Provide the ability for a a Python frame decorator to indicate that > a value is not available. > > doc/ChangeLog: > > 2015-04-03 Sasha Smundak > > * python.texi:New method documented. > > gdb/ChangeLog: > > 2015-04-03 Sasha Smundak > > * python/py-type.c (typy_create_optimized_out): New function. > > testsuite/ChangeLog: > > 2015-04-03 Sasha Smundak > > * gdb.python/py-type.exp: New test. Hi. A few of nits. The terms "unavailable" and "optimized out" have different meanings in gdb. See their definitions at the top of value.h. Also see the comments for struct value.{unavailable,optimized_out} in value.c. I don't know if python frame decorators would want to specify a value as being unavailable (in gdb parlance), but don't use "unavailable" in the documentation of "optimized out". The "create_" in "create_optimized_out" is incongruous with the rest of gdb.Type methods. E.g., we have "array" not "create_array", "vector" not "create_vector", "const" not "create_const", and so on. Does "optimized_out" read well to you? A NEWS entry is needed. > > diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi > index 098d718..7c2d0bc 100644 > --- a/gdb/doc/python.texi > +++ b/gdb/doc/python.texi > @@ -1060,6 +1060,11 @@ If @var{block} is given, then @var{name} is > looked up in that scope. > Otherwise, it is searched for globally. > @end defun > > +@defun Type.create_optimized_out () > +Return @code{gdb.Value} instance of this type whose value is optimized > +out. Allows a frame decorator to indicate that an argument or local > +variable value is unavailable. > +@end defun > > Each type has a code, which indicates what category this type falls > into. The available type categories are represented by constants > diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c > index 39376a1..186cc19 100644 > --- a/gdb/python/py-type.c > +++ b/gdb/python/py-type.c > @@ -1181,6 +1181,14 @@ typy_nonzero (PyObject *self) > return 1; > } > > +/* Return optimized out value of this type. */ blank line > +static PyObject * > +typy_create_optimized_out (PyObject *self, PyObject *args) > +{ > + struct type *type = ((type_object *) self)->type; > + return value_to_value_object (allocate_optimized_out_value (type)); > +} > + > /* Return a gdb.Field object for the field named by the argument. */ > > static PyObject * > @@ -1493,6 +1501,8 @@ They are first class values." }, > { "const", typy_const, METH_NOARGS, > "const () -> Type\n\ > Return a const variant of this type." }, > + { "create_optimized_out", typy_create_optimized_out, METH_NOARGS, > +"create_optimized_out() -> Value\nReturn optimized out value of this type." }, > { "fields", typy_fields, METH_NOARGS, > "fields () -> list\n\ > Return a list holding all the fields of this type.\n\ > diff --git a/gdb/testsuite/gdb.python/py-type.exp > b/gdb/testsuite/gdb.python/py-type.exp > index c4c8d9f..c73f831 100644 > --- a/gdb/testsuite/gdb.python/py-type.exp > +++ b/gdb/testsuite/gdb.python/py-type.exp > @@ -253,6 +253,9 @@ gdb_test "python print > gdb.lookup_type('char').array(1, 0)" \ > gdb_test "python print gdb.lookup_type('char').array(1, -1)" \ > "Array length must not be negative.*" > > +gdb_test "python print gdb.lookup_type('int').create_optimized_out()" \ > + "" > + > with_test_prefix "lang_c" { > runto_bp "break to inspect struct and array." > test_fields "c" -- /dje