aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-breakpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-breakpoint.c')
-rw-r--r--gdb/python/py-breakpoint.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 75f50e1..9ce8671 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -1,6 +1,6 @@
/* Python interface to breakpoints
- Copyright (C) 2008-2024 Free Software Foundation, Inc.
+ Copyright (C) 2008-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -17,6 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "source.h"
#include "value.h"
#include "python-internal.h"
#include "python.h"
@@ -947,7 +948,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
else
{
PyErr_SetString (PyExc_RuntimeError,
- _("Line keyword should be an integer or a string. "));
+ _("Line keyword should be an integer or a string."));
return -1;
}
}
@@ -1536,9 +1537,7 @@ PyTypeObject breakpoint_object_type =
0, /* tp_alloc */
};
-void _initialize_py_breakpoint ();
-void
-_initialize_py_breakpoint ()
+INIT_GDB_FILE (py_breakpoint)
{
add_setshow_boolean_cmd
("py-breakpoint", class_maintenance, &pybp_debug,
@@ -1629,6 +1628,26 @@ bplocpy_get_owner (PyObject *py_self, void *closure)
return (PyObject *) self->owner;
}
+/* Attempt to get fully resolved file path for symtab. */
+
+static gdbpy_ref<>
+bploc_filepath (struct symtab *bploc_symtab)
+{
+ /* The exception is not ours to handle. We should always
+ return some string value and filename is never null. */
+ try
+ {
+ const char *full = symtab_to_fullname (bploc_symtab);
+ if (full)
+ return host_string_to_python_string (full);
+ }
+ catch (const gdb_exception &except)
+ {
+ }
+
+ return host_string_to_python_string (bploc_symtab->filename);
+}
+
/* Python function to get the source file name path and line number
where this breakpoint location was set. */
@@ -1643,9 +1662,7 @@ bplocpy_get_source_location (PyObject *py_self, void *closure)
gdbpy_ref<> tup (PyTuple_New (2));
if (tup == nullptr)
return nullptr;
- /* symtab->filename is never NULL. */
- gdbpy_ref<> filename
- = host_string_to_python_string (self->bp_loc->symtab->filename);
+ gdbpy_ref<> filename = bploc_filepath (self->bp_loc->symtab);
if (filename == nullptr)
return nullptr;
auto line = gdb_py_object_from_ulongest (self->bp_loc->line_number);