to wrap the result of a call to a Disassembler. It has
read-only attributes 'length' and 'string'.
+ ** gdb.Objfile now has an attribute named "is_file". This is True
+ if the objfile comes from a file, and False otherwise.
+
* New features in the GDB remote stub, GDBserver
** GDBserver is now supported on LoongArch GNU/Linux.
See the @code{gdb.Objfile.is_valid} method, described below.
@end defvar
+@defvar Objfile.is_file
+An objfile often comes from an ordinary file, but in some cases it may
+be constructed from the contents of memory. This attribute is
+@code{True} for file-backed objfiles, and @code{False} for other
+kinds.
+@end defvar
+
@defvar Objfile.owner
For separate debug info objfiles this is the corresponding @code{gdb.Objfile}
object that debug info is being provided for.
Py_RETURN_NONE;
}
+/* Get the 'is_file' attribute. */
+
+static PyObject *
+objfpy_get_is_file (PyObject *o, void *ignore)
+{
+ objfile_object *self = (objfile_object *) o;
+
+ if (self->objfile != nullptr)
+ return PyBool_FromLong ((self->objfile->flags & OBJF_NOT_FILENAME) == 0);
+ Py_RETURN_NONE;
+}
+
/* If SELF is a separate debug-info file, return the "backlink" field.
Otherwise return None. */
"Type printers.", NULL },
{ "xmethods", objfpy_get_xmethods, NULL,
"Debug methods.", NULL },
+ { "is_file", objfpy_get_is_file, nullptr,
+ "Whether this objfile came from a file.", nullptr },
{ NULL }
};
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# Optionally test a Python API here as well.
+load_lib gdb-python.exp
+
standard_testfile jit-reader-host.c
if { (![istarget x86_64-*-*] && ![istarget i?86-*-*]) || ![is_lp64_target] } {
"#1 ${any} in main ${any}" \
]
}
+
+ if {![skip_python_tests]} {
+ gdb_test "python print(any(\[not x.is_file for x in gdb.objfiles()\]))" \
+ "True" \
+ "at least one non-file objfile"
+ gdb_test "python print(any(\[x.is_file for x in gdb.objfiles()\]))" \
+ "True" \
+ "at least one file-based objfile"
+ }
}
jit_reader_test