diff options
author | Tom Tromey <tromey@adacore.com> | 2022-06-20 12:32:52 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-07-05 11:22:20 -0600 |
commit | 99298c958c5393402cd2bc2885c195838a9dd363 (patch) | |
tree | dd05d620651f849488132ef02898f96318ec518e /gdb/python/py-objfile.c | |
parent | 3acd9a692ddaf8f24d6d34cb5ccb7c26d057e9b3 (diff) | |
download | fsf-binutils-gdb-99298c958c5393402cd2bc2885c195838a9dd363.zip fsf-binutils-gdb-99298c958c5393402cd2bc2885c195838a9dd363.tar.gz fsf-binutils-gdb-99298c958c5393402cd2bc2885c195838a9dd363.tar.bz2 |
Add gdb.Objfile.is_file attribute
Sometimes an objfile comes from memory and not from a file. It can be
useful to be able to check this from Python, so this patch adds a new
"is_file" attribute.
Diffstat (limited to 'gdb/python/py-objfile.c')
-rw-r--r-- | gdb/python/py-objfile.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 3e3270e..298f3f2 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -101,6 +101,18 @@ objfpy_get_username (PyObject *self, void *closure) 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. */ @@ -762,6 +774,8 @@ static gdb_PyGetSetDef objfile_getset[] = "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 } }; |