public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* RFC: Python gdb.Type method returning optimized out gdb.Value
@ 2015-04-03 20:33 Alexander Smundak
  2015-04-07 17:44 ` Doug Evans
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Smundak @ 2015-04-03 20:33 UTC (permalink / raw)
  To: gdb-patches

Provide the ability for a a Python frame decorator to indicate that
a value is not available.

doc/ChangeLog:

2015-04-03  Sasha Smundak  <asmundak@google.com>

    * python.texi:New method documented.

gdb/ChangeLog:

2015-04-03  Sasha Smundak  <asmundak@google.com>

   * python/py-type.c (typy_create_optimized_out): New function.

testsuite/ChangeLog:

2015-04-03  Sasha Smundak  <asmundak@google.com>

   * gdb.python/py-type.exp: New test.

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.  */
+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()" \
+    "<optimized out>"
+
 with_test_prefix "lang_c" {
     runto_bp "break to inspect struct and array."
     test_fields "c"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: Python gdb.Type method returning optimized out gdb.Value
  2015-04-03 20:33 RFC: Python gdb.Type method returning optimized out gdb.Value Alexander Smundak
@ 2015-04-07 17:44 ` Doug Evans
  2015-04-07 21:23   ` Alexander Smundak
  0 siblings, 1 reply; 7+ messages in thread
From: Doug Evans @ 2015-04-07 17:44 UTC (permalink / raw)
  To: Alexander Smundak; +Cc: gdb-patches

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  <asmundak@google.com>
 > 
 >     * python.texi:New method documented.
 > 
 > gdb/ChangeLog:
 > 
 > 2015-04-03  Sasha Smundak  <asmundak@google.com>
 > 
 >    * python/py-type.c (typy_create_optimized_out): New function.
 > 
 > testsuite/ChangeLog:
 > 
 > 2015-04-03  Sasha Smundak  <asmundak@google.com>
 > 
 >    * 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()" \
 > +    "<optimized out>"
 > +
 >  with_test_prefix "lang_c" {
 >      runto_bp "break to inspect struct and array."
 >      test_fields "c"

-- 
/dje

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: Python gdb.Type method returning optimized out gdb.Value
  2015-04-07 17:44 ` Doug Evans
@ 2015-04-07 21:23   ` Alexander Smundak
  2015-04-12 16:48     ` Doug Evans
  2015-04-29  5:20     ` Doug Evans
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Smundak @ 2015-04-07 21:23 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

Thank you for the quick review.
Edited NEWS, renamed `create_optimized_out' to `optimized_out',
elided 'unavailable' from description, added blank line.
PTAL.

gdb/doc/ChangeLog:

2015-04-07  Sasha Smundak  <asmundak@google.com>

    * python.texi: New method documented.

gdb/ChangeLog:

2015-04-07  Sasha Smundak  <asmundak@google.com>

    * NEWS: Mention gdb.Type.optimized_out method.
    * python/py-type.c (typy_optimized_out):  New function.

gdb/testsuite/ChangeLog:

2015-04-07  Sasha Smundak  <asmundak@google.com>

    * gdb.python/py-type.exp: New test.

diff --git a/gdb/NEWS b/gdb/NEWS
index 884c381..ebb573a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -37,6 +37,8 @@
      which is the name of the objfile as specified by the user,
      without, for example, resolving symlinks.
   ** You can now write frame unwinders in Python.
+  ** gdb.Type objects have a new method "optimized_out",
+     returning optimized out gdb.Value instance of this type.

 * New commands

diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 098d718..091521c6 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.optimized_out ()
+Return @code{gdb.Value} instance of this type whose value is optimized
+out.  This allows a frame decorator to indicate that the value of an
+argument or a local variable is not known.
+@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..0461b26 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -1181,6 +1181,15 @@ typy_nonzero (PyObject *self)
   return 1;
 }

+/* Return optimized out value of this type.  */
+
+static PyObject *
+typy_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 +1502,8 @@ They are first class values." },
   { "const", typy_const, METH_NOARGS,
     "const () -> Type\n\
 Return a const variant of this type." },
+  { "optimized_out", typy_optimized_out, METH_NOARGS,
+"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..2edbfe3 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').optimized_out()" \
+    "<optimized out>"
+
 with_test_prefix "lang_c" {
     runto_bp "break to inspect struct and array."
     test_fields "c"

On Tue, Apr 7, 2015 at 10:44 AM, Doug Evans <dje@google.com> wrote:
> 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  <asmundak@google.com>
>  >
>  >     * python.texi:New method documented.
>  >
>  > gdb/ChangeLog:
>  >
>  > 2015-04-03  Sasha Smundak  <asmundak@google.com>
>  >
>  >    * python/py-type.c (typy_create_optimized_out): New function.
>  >
>  > testsuite/ChangeLog:
>  >
>  > 2015-04-03  Sasha Smundak  <asmundak@google.com>
>  >
>  >    * 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()" \
>  > +    "<optimized out>"
>  > +
>  >  with_test_prefix "lang_c" {
>  >      runto_bp "break to inspect struct and array."
>  >      test_fields "c"
>
> --
> /dje

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: Python gdb.Type method returning optimized out gdb.Value
  2015-04-07 21:23   ` Alexander Smundak
@ 2015-04-12 16:48     ` Doug Evans
  2015-04-13 23:57       ` Doug Evans
  2015-04-29  5:20     ` Doug Evans
  1 sibling, 1 reply; 7+ messages in thread
From: Doug Evans @ 2015-04-12 16:48 UTC (permalink / raw)
  To: Alexander Smundak; +Cc: gdb-patches

On Tue, Apr 7, 2015 at 2:23 PM, Alexander Smundak <asmundak@google.com> wrote:
> Thank you for the quick review.
> Edited NEWS, renamed `create_optimized_out' to `optimized_out',
> elided 'unavailable' from description, added blank line.
> PTAL.
>
> gdb/doc/ChangeLog:
>
> 2015-04-07  Sasha Smundak  <asmundak@google.com>
>
>     * python.texi: New method documented.
>
> gdb/ChangeLog:
>
> 2015-04-07  Sasha Smundak  <asmundak@google.com>
>
>     * NEWS: Mention gdb.Type.optimized_out method.
>     * python/py-type.c (typy_optimized_out):  New function.
>
> gdb/testsuite/ChangeLog:
>
> 2015-04-07  Sasha Smundak  <asmundak@google.com>
>
>     * gdb.python/py-type.exp: New test.

LGTM with one nit below.
[no need to resubmit another patch]

> diff --git a/gdb/NEWS b/gdb/NEWS
> index 884c381..ebb573a 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -37,6 +37,8 @@
>       which is the name of the objfile as specified by the user,
>       without, for example, resolving symlinks.
>    ** You can now write frame unwinders in Python.
> +  ** gdb.Type objects have a new method "optimized_out",
> +     returning optimized out gdb.Value instance of this type.
>
>  * New commands
>
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index 098d718..091521c6 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.optimized_out ()
> +Return @code{gdb.Value} instance of this type whose value is optimized
> +out.  This allows a frame decorator to indicate that the value of an
> +argument or a local variable is not known.
> +@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..0461b26 100644
> --- a/gdb/python/py-type.c
> +++ b/gdb/python/py-type.c
> @@ -1181,6 +1181,15 @@ typy_nonzero (PyObject *self)
>    return 1;
>  }
>
> +/* Return optimized out value of this type.  */
> +
> +static PyObject *
> +typy_optimized_out (PyObject *self, PyObject *args)
> +{
> +  struct type *type = ((type_object *) self)->type;

Style rules require a blank line here.
Sorry for not catching this earlier.

> +  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 +1502,8 @@ They are first class values." },
>    { "const", typy_const, METH_NOARGS,
>      "const () -> Type\n\
>  Return a const variant of this type." },
> +  { "optimized_out", typy_optimized_out, METH_NOARGS,
> +"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..2edbfe3 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').optimized_out()" \
> +    "<optimized out>"
> +
>  with_test_prefix "lang_c" {
>      runto_bp "break to inspect struct and array."
>      test_fields "c"
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: Python gdb.Type method returning optimized out gdb.Value
  2015-04-12 16:48     ` Doug Evans
@ 2015-04-13 23:57       ` Doug Evans
  2015-04-14  2:43         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Doug Evans @ 2015-04-13 23:57 UTC (permalink / raw)
  To: eliz; +Cc: Alexander Smundak, gdb-patches

Doug Evans writes:
 > On Tue, Apr 7, 2015 at 2:23 PM, Alexander Smundak <asmundak@google.com> wrote:
 > > Thank you for the quick review.
 > > Edited NEWS, renamed `create_optimized_out' to `optimized_out',
 > > elided 'unavailable' from description, added blank line.
 > > PTAL.
 > >
 > > gdb/doc/ChangeLog:
 > >
 > > 2015-04-07  Sasha Smundak  <asmundak@google.com>
 > >
 > >     * python.texi: New method documented.
 > >
 > > gdb/ChangeLog:
 > >
 > > 2015-04-07  Sasha Smundak  <asmundak@google.com>
 > >
 > >     * NEWS: Mention gdb.Type.optimized_out method.
 > >     * python/py-type.c (typy_optimized_out):  New function.
 > >
 > > gdb/testsuite/ChangeLog:
 > >
 > > 2015-04-07  Sasha Smundak  <asmundak@google.com>
 > >
 > >     * gdb.python/py-type.exp: New test.

Hi.
Just need a doc approval.

 > 
 > LGTM with one nit below.
 > [no need to resubmit another patch]
 > 
 > > diff --git a/gdb/NEWS b/gdb/NEWS
 > > index 884c381..ebb573a 100644
 > > --- a/gdb/NEWS
 > > +++ b/gdb/NEWS
 > > @@ -37,6 +37,8 @@
 > >       which is the name of the objfile as specified by the user,
 > >       without, for example, resolving symlinks.
 > >    ** You can now write frame unwinders in Python.
 > > +  ** gdb.Type objects have a new method "optimized_out",
 > > +     returning optimized out gdb.Value instance of this type.
 > >
 > >  * New commands
 > >
 > > diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
 > > index 098d718..091521c6 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.optimized_out ()
 > > +Return @code{gdb.Value} instance of this type whose value is optimized
 > > +out.  This allows a frame decorator to indicate that the value of an
 > > +argument or a local variable is not known.
 > > +@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..0461b26 100644
 > > --- a/gdb/python/py-type.c
 > > +++ b/gdb/python/py-type.c
 > > @@ -1181,6 +1181,15 @@ typy_nonzero (PyObject *self)
 > >    return 1;
 > >  }
 > >
 > > +/* Return optimized out value of this type.  */
 > > +
 > > +static PyObject *
 > > +typy_optimized_out (PyObject *self, PyObject *args)
 > > +{
 > > +  struct type *type = ((type_object *) self)->type;
 > 
 > Style rules require a blank line here.
 > Sorry for not catching this earlier.
 > 
 > > +  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 +1502,8 @@ They are first class values." },
 > >    { "const", typy_const, METH_NOARGS,
 > >      "const () -> Type\n\
 > >  Return a const variant of this type." },
 > > +  { "optimized_out", typy_optimized_out, METH_NOARGS,
 > > +"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..2edbfe3 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').optimized_out()" \
 > > +    "<optimized out>"
 > > +
 > >  with_test_prefix "lang_c" {
 > >      runto_bp "break to inspect struct and array."
 > >      test_fields "c"
 > >

-- 
/dje

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: Python gdb.Type method returning optimized out gdb.Value
  2015-04-13 23:57       ` Doug Evans
@ 2015-04-14  2:43         ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2015-04-14  2:43 UTC (permalink / raw)
  To: Doug Evans; +Cc: asmundak, gdb-patches

> From: Doug Evans <dje@google.com>
> Date: Mon, 13 Apr 2015 16:57:04 -0700
> Cc: Alexander Smundak <asmundak@google.com>,
>     gdb-patches <gdb-patches@sourceware.org>
> 
> Doug Evans writes:
>  > On Tue, Apr 7, 2015 at 2:23 PM, Alexander Smundak <asmundak@google.com> wrote:
>  > > Thank you for the quick review.
>  > > Edited NEWS, renamed `create_optimized_out' to `optimized_out',
>  > > elided 'unavailable' from description, added blank line.
>  > > PTAL.
>  > >
>  > > gdb/doc/ChangeLog:
>  > >
>  > > 2015-04-07  Sasha Smundak  <asmundak@google.com>
>  > >
>  > >     * python.texi: New method documented.
>  > >
>  > > gdb/ChangeLog:
>  > >
>  > > 2015-04-07  Sasha Smundak  <asmundak@google.com>
>  > >
>  > >     * NEWS: Mention gdb.Type.optimized_out method.
>  > >     * python/py-type.c (typy_optimized_out):  New function.
>  > >
>  > > gdb/testsuite/ChangeLog:
>  > >
>  > > 2015-04-07  Sasha Smundak  <asmundak@google.com>
>  > >
>  > >     * gdb.python/py-type.exp: New test.
> 
> Hi.
> Just need a doc approval.

You've got it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: Python gdb.Type method returning optimized out gdb.Value
  2015-04-07 21:23   ` Alexander Smundak
  2015-04-12 16:48     ` Doug Evans
@ 2015-04-29  5:20     ` Doug Evans
  1 sibling, 0 replies; 7+ messages in thread
From: Doug Evans @ 2015-04-29  5:20 UTC (permalink / raw)
  To: Alexander Smundak; +Cc: gdb-patches

Alexander Smundak writes:
 > Thank you for the quick review.
 > Edited NEWS, renamed `create_optimized_out' to `optimized_out',
 > elided 'unavailable' from description, added blank line.
 > PTAL.
 > 

Hi.

Here is what I committed.
I found a few more nits.

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 721346a..4e78d39 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2015-04-28  Sasha Smundak  <asmundak@google.com>
+
+	* NEWS: Mention gdb.Type.optimized_out method.
+	* python/py-type.c (typy_optimized_out):  New function.
+
 2015-04-28  John Baldwin  <jhb@FreeBSD.org>
 
 	* fbsd-nat.c: Include "gdb_wait.h" instead of <sys/wait.h>.
diff --git a/gdb/NEWS b/gdb/NEWS
index b711553..d463b52 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -52,6 +52,8 @@
      which is the name of the objfile as specified by the user,
      without, for example, resolving symlinks.
   ** You can now write frame unwinders in Python.
+  ** gdb.Type objects have a new method "optimized_out",
+     returning optimized out gdb.Value instance of this type.
 
 * New commands
 
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 5da9943..13ca87b 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2015-04-28  Sasha Smundak  <asmundak@google.com>
+
+	* python.texi: New method documented.
+
 2015-04-24  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* gdb.texinfo (Dump/Restore Files): Add detail about verilog dump
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 448fa8b2..12d2b71 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.optimized_out ()
+Return @code{gdb.Value} instance of this type whose value is optimized
+out.  This allows a frame decorator to indicate that the value of an
+argument or a local variable is not known.
+@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..648d8c8 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -1181,6 +1181,16 @@ typy_nonzero (PyObject *self)
   return 1;
 }
 
+/* Return optimized out value of this type.  */
+
+static PyObject *
+typy_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 +1503,9 @@ They are first class values." },
   { "const", typy_const, METH_NOARGS,
     "const () -> Type\n\
 Return a const variant of this type." },
+  { "optimized_out", typy_optimized_out, METH_NOARGS,
+    "optimized_out() -> Value\n\
+Return 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/ChangeLog b/gdb/testsuite/ChangeLog
index 1967aca..80d88cf 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-04-28  Sasha Smundak  <asmundak@google.com>
+
+	* gdb.python/py-type.exp: New test.
+
 2015-04-28  Andy Wingo  <wingo@igalia.com>
 
 	* gdb.python/py-parameter.exp:
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index 9e522f2..58a2394 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').optimized_out())" \
+    "<optimized out>"
+
 with_test_prefix "lang_c" {
     runto_bp "break to inspect struct and array."
     test_fields "c"

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-04-29  0:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-03 20:33 RFC: Python gdb.Type method returning optimized out gdb.Value Alexander Smundak
2015-04-07 17:44 ` Doug Evans
2015-04-07 21:23   ` Alexander Smundak
2015-04-12 16:48     ` Doug Evans
2015-04-13 23:57       ` Doug Evans
2015-04-14  2:43         ` Eli Zaretskii
2015-04-29  5:20     ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).