diff options
author | Doug Evans <dje@google.com> | 2015-01-27 10:13:52 -0800 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2015-01-27 10:13:52 -0800 |
commit | 3a8b707add581af37804947536025dd3e7fc1a33 (patch) | |
tree | 20c64055757dbd442dd4188b7d00d204fd719685 /gdb/python | |
parent | 1b5493961ab1f65a3336b2178ba3d035a130f9f6 (diff) | |
download | gdb-3a8b707add581af37804947536025dd3e7fc1a33.zip gdb-3a8b707add581af37804947536025dd3e7fc1a33.tar.gz gdb-3a8b707add581af37804947536025dd3e7fc1a33.tar.bz2 |
Add gdb.Objfile.username.
gdb/ChangeLog:
* NEWS: Mention gdb.Objfile.username.
* python/py-objfile.c (objfpy_get_username): New function.
(objfile_getset): Add "username".
gdb/doc/ChangeLog:
* python.texi (Objfiles In Python): Document Objfile.username.
gdb/testsuite/ChangeLog:
* gdb.python/py-objfile.exp: Add tests for objfile.username.
Add test for objfile.filename, objfile.username after objfile
has been unloaded.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-objfile.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 378db58..0aecaf6 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -81,6 +81,25 @@ objfpy_get_filename (PyObject *self, void *closure) Py_RETURN_NONE; } +/* An Objfile method which returns the objfile's file name, as specified + by the user, or None. */ + +static PyObject * +objfpy_get_username (PyObject *self, void *closure) +{ + objfile_object *obj = (objfile_object *) self; + + if (obj->objfile) + { + const char *username = obj->objfile->original_name; + + return PyString_Decode (username, strlen (username), + host_charset (), NULL); + } + + Py_RETURN_NONE; +} + /* If SELF is a separate debug-info file, return the "backlink" field. Otherwise return None. */ @@ -613,6 +632,8 @@ static PyGetSetDef objfile_getset[] = "The __dict__ for this objfile.", &objfile_object_type }, { "filename", objfpy_get_filename, NULL, "The objfile's filename, or None.", NULL }, + { "username", objfpy_get_username, NULL, + "The name of the objfile as provided by the user, or None.", NULL }, { "owner", objfpy_get_owner, NULL, "The objfile owner of separate debug info objfiles, or None.", NULL }, |