summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSasha Smundak <asmundak@google.com>2015-04-28 17:41:09 -0700
committerDoug Evans <dje@google.com>2015-04-28 17:41:09 -0700
commit59fb7612ddee9219817a0c33b7d533b3d1c2aa41 (patch)
tree242ca16dfed9cf2a96d4bc17f863912d06d556cf
parent521f2feb982e5e0b7065f5096590c3a92c7c9ec0 (diff)
downloadbinutils-gdb-59fb7612ddee9219817a0c33b7d533b3d1c2aa41.tar.gz
Add gdb.Type.optimized_out method.
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.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/NEWS2
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/python.texi5
-rw-r--r--gdb/python/py-type.c13
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.python/py-type.exp3
7 files changed, 36 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 721346a7b64..4e78d395a19 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 b711553df5a..d463b523933 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 5da994333fc..13ca87b33e6 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 448fa8b2ec9..12d2b71d040 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 39376a126f2..648d8c8e178 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 1967acae149..80d88cfed94 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 9e522f23221..58a2394da70 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"