Skip to content

Commit 8e58f43

Browse files
committed
py-objfile: add has_symbols() method
When loading objfile files, it's useful to determine whether the caller needs to locate and load separate debuginfo. Inside gdb, this is keyed off of has_symbols(), so let's export that via Python. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
1 parent 33b1554 commit 8e58f43

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

gdb/python/py-objfile.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,26 @@ objfpy_is_valid (PyObject *self, PyObject *args)
424424
Py_RETURN_TRUE;
425425
}
426426

427+
/* Implementation of gdb.Objfile.is_has_symbols (self) -> Boolean.
428+
Returns True if this object file has even partial symbols available. */
429+
430+
static PyObject *
431+
objfpy_has_symbols (PyObject *self, PyObject *args)
432+
{
433+
objfile_object *obj = (objfile_object *) self;
434+
435+
if (! obj->objfile)
436+
Py_RETURN_FALSE;
437+
438+
if (objfile_has_symbols (obj->objfile))
439+
{
440+
Py_RETURN_TRUE;
441+
}
442+
443+
Py_RETURN_FALSE;
444+
}
445+
446+
427447
struct objfile *
428448
objfpy_object_to_objfile(PyObject *self)
429449
{
@@ -673,6 +693,9 @@ static PyMethodDef objfile_object_methods[] =
673693
{ "is_valid", objfpy_is_valid, METH_NOARGS,
674694
"is_valid () -> Boolean.\n\
675695
Return true if this object file is valid, false if not." },
696+
{ "has_symbols", objfpy_has_symbols, METH_NOARGS,
697+
"has_symbols () -> Boolean.\n\
698+
Return true if this object file has symbols associated with it." },
676699

677700
{ "add_separate_debug_file", (PyCFunction) objfpy_add_separate_debug_file,
678701
METH_VARARGS | METH_KEYWORDS,

0 commit comments

Comments
 (0)