@xref{Compunits In Python}.
@end defun
+@defun Objfile.unlink ()
+Remove this objfile. This should be used only on objfiles created by
+Python (see @code{Objfile.__init__} above) but @code{Objfile.unlink} does
+not make any checks.
+@end defun
+
@node Frames In Python
@subsubsection Accessing inferior stack frames from Python
Py_RETURN_NONE;
}
+/* Implementation of gdb.Objfile.unlink (). */
+
+static PyObject *
+objfpy_unlink (PyObject *self, PyObject *args)
+{
+ objfile_object *obj = (objfile_object *) self;
+
+ OBJFPY_REQUIRE_VALID (obj);
+
+ obj->objfile->unlink();
+
+ Py_RETURN_NONE;
+}
+
/* Implement repr() for gdb.Objfile. */
static PyObject *
"compunits () -> List.\n\
Return a sequence of compunits associated to this objfile." },
+ { "unlink", objfpy_unlink, METH_NOARGS,
+ "unlink ().\n\
+Remove this objfile." },
+
{ NULL }
};
gdb_test "python print( gdb.Objfile(\"Test objfile 5\", gdb.selected_inferior(), gdb.selected_inferior()))" \
"TypeError.*:.*" \
"create objfile with valid inferior but invalid arch"
+
+gdb_test "python print(objfile.unlink())" \
+ "None" \
+ "remove (dynamic) objfile"
+
+gdb_test "python print(objfile in gdb.objfiles())" \
+ "False" \
+ "removed (dynamic) objfile no longer in gdb.objfiles()"
+
+gdb_test "python print(objfile.is_valid())" \
+ "False" \
+ "removes (dynamic) objfile is no longer valid"