public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/linespec.c: Fix missing source file during breakpoint re-set
@ 2023-01-10 1:13 Aaron Merey
0 siblings, 0 replies; only message in thread
From: Aaron Merey @ 2023-01-10 1:13 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7dd38e31d67c2548b52bea313ab18e40824c05da
commit 7dd38e31d67c2548b52bea313ab18e40824c05da
Author: Aaron Merey <amerey@redhat.com>
Date: Fri Jan 6 18:45:27 2023 -0500
gdb/linespec.c: Fix missing source file during breakpoint re-set
During breakpoint re-setting, the source_filename of an
explicit_location_spec is used to lookup the symtabs associated with
the breakpoint being re-set. This source_filename is compared with each
known symtab filename in order to retrieve the breakpoint's symtabs.
However the source_filename may have been originally copied from a
symtab's fullname (the path where GDB found the source file) when the
breakpoint was first created. If a breakpoint symtab's filename and
fullname differ and there is no substitute-path rule that converts the
fullname to the filename, this will cause a NOT_FOUND_ERROR to be thrown
during re-setting.
Fix this by using a symtab's filename to set the explicit_location_spec
source_filename instead of the symtab's fullname.
Diff:
---
gdb/linespec.c | 4 ++--
gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gdb/linespec.c b/gdb/linespec.c
index b8c77541a29..d3def7ae070 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2283,13 +2283,13 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
/* Make sure we have a filename for canonicalization. */
if (ls->explicit_loc.source_filename == NULL)
{
- const char *fullname = symtab_to_fullname (state->default_symtab);
+ const char *filename = state->default_symtab->filename;
/* It may be more appropriate to keep DEFAULT_SYMTAB in its symtab
form so that displaying SOURCE_FILENAME can follow the current
FILENAME_DISPLAY_STRING setting. But as it is used only rarely
it has been kept for code simplicity only in absolute form. */
- ls->explicit_loc.source_filename = xstrdup (fullname);
+ ls->explicit_loc.source_filename = xstrdup (filename);
}
}
else
diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
index 6d5af1370b0..bfe6e639e4f 100644
--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
@@ -224,6 +224,15 @@ proc_with_prefix local_url { } {
set lineno [gdb_get_line_number "Breakpoint here"]
gdb_test "list $lineno" "return 0;\[^\r\n\]+Breakpoint here\\. .*"
+ # Verify that a breakpoint re-sets correctly when the actual location
+ # of the source file in the debuginfod client cache differs from
+ # the contents of DW_AT_comp_dir and DW_AT_name.
+ gdb_test "set cwd $debugdir" "" "file [file tail $binfile] cwd"
+ gdb_test_no_output "del breakpoint 1"
+ gdb_test "break $lineno" "Breakpoint 2 at.*file.*"
+ gdb_test "run" "Breakpoint 2.*" \
+ "file [file tail $binfile] set breakpoint"
+
# GDB should now find the executable file.
clean_restart
gdb_test "core $::corefile" ".*return 0.*" "file [file tail $::corefile]" \
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-10 1:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 1:13 [binutils-gdb] gdb/linespec.c: Fix missing source file during breakpoint re-set Aaron Merey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).