2011-03-17 Phil Muldoon <pmuldoon@redhat.com>
[deliverable/binutils-gdb.git] / gdb / python / py-inferior.c
index ee41ea77555be310292db063b368cc014ae3f70b..b9df394cc9c26eea71c36a7fd49a56ab88787c2a 100644 (file)
@@ -606,6 +606,20 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
     Py_RETURN_NONE;
 }
 
+/* Implementation of gdb.Inferior.is_valid (self) -> Boolean.
+   Returns True if this inferior object still exists in GDB.  */
+
+static PyObject *
+infpy_is_valid (PyObject *self, PyObject *args)
+{
+  inferior_object *inf = (inferior_object *) self;
+
+  if (! inf->inferior)
+    Py_RETURN_FALSE;
+
+  Py_RETURN_TRUE;
+}
+
 
 /* Clear the INFERIOR pointer in an Inferior object and clear the
    thread list.  */
@@ -676,6 +690,9 @@ static PyGetSetDef inferior_object_getset[] =
 
 static PyMethodDef inferior_object_methods[] =
 {
+  { "is_valid", infpy_is_valid, METH_NOARGS,
+    "is_valid () -> Boolean.\n\
+Return true if this inferior is valid, false if not." },
   { "threads", infpy_threads, METH_NOARGS,
     "Return all the threads of this inferior." },
   { "read_memory", (PyCFunction) infpy_read_memory,
This page took 0.025067 seconds and 4 git commands to generate.