Add gdb.Type.optimized_out method.
authorSasha Smundak <asmundak@google.com>
Wed, 29 Apr 2015 00:41:09 +0000 (17:41 -0700)
committerDoug Evans <dje@google.com>
Wed, 29 Apr 2015 00:41:09 +0000 (17:41 -0700)
gdb/ChangeLog:

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

gdb/doc/ChangeLog:

* python.texi: New method documented.

gdb/testsuite/ChangeLog:

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

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/python.texi
gdb/python/py-type.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-type.exp

index 721346a7b6464756f14c8016fa0ac9f8e56ebf2e..4e78d395a19a48772575edd0bdd3070e3fe08aca 100644 (file)
@@ -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>.
index b711553df5a4e89d4b2bb0c1c20faf039d6d2fd5..d463b52393383dcc27438afe815549822dc60483 100644 (file)
--- 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
 
index 5da994333fc2f3fb9a23c6126eb2d9aef334db76..13ca87b33e6c4a68135cf272ee3b874bc0322a28 100644 (file)
@@ -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
index 448fa8b2ec9bdb817a9b5399e7ad7f13bd04a580..12d2b71d040e214438ebf701e5b68907a8f53a04 100644 (file)
@@ -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
index 39376a126f2a5bb23e76bbcfffce5611c04c4e63..648d8c8e1787519a8736249b3bf639c4f7b4be5b 100644 (file)
@@ -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\
index 1967acae1495240e1cbd3adcd6d6644a6c83a5bc..80d88cfed94cf49e1bb018524e15ddfd875732a5 100644 (file)
@@ -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:
index 9e522f23221d5d80518c53fc6f521c94d2ca9280..58a2394da70ccba3909f6231600ef758b0bf40f7 100644 (file)
@@ -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"
This page took 0.042855 seconds and 4 git commands to generate.