|
|
8bcabb |
commit bb995d00b3eef2f48d0be895c3509a7ddd8280a1
|
|
|
8bcabb |
Author: Keith Seitz <keiths@redhat.com>
|
|
|
8bcabb |
Date: Fri Feb 22 09:39:35 2019 -0800
|
|
|
8bcabb |
|
|
|
8bcabb |
Fix symtab/23853: symlinked default symtab
|
|
|
8bcabb |
|
|
|
8bcabb |
This patch attempts to fix a bug dealing with setting breakpoints
|
|
|
8bcabb |
in default symtabs that are symlinks. For example:
|
|
|
8bcabb |
|
|
|
8bcabb |
(gdb) list
|
|
|
8bcabb |
11 GNU General Public License for more details.
|
|
|
8bcabb |
12
|
|
|
8bcabb |
13 You should have received a copy of the GNU General Public License
|
|
|
8bcabb |
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
8bcabb |
15
|
|
|
8bcabb |
16 static int
|
|
|
8bcabb |
17 foo (void)
|
|
|
8bcabb |
18 {
|
|
|
8bcabb |
19 return 0; /* break here */
|
|
|
8bcabb |
20 }
|
|
|
8bcabb |
(gdb)
|
|
|
8bcabb |
21
|
|
|
8bcabb |
22 int
|
|
|
8bcabb |
23 main (void)
|
|
|
8bcabb |
24 {
|
|
|
8bcabb |
25 return foo ();
|
|
|
8bcabb |
26 }
|
|
|
8bcabb |
(gdb) b 19
|
|
|
8bcabb |
No line 19 in the current file.
|
|
|
8bcabb |
Make breakpoint pending on future shared library load? (y or [n])
|
|
|
8bcabb |
|
|
|
8bcabb |
The problem here is that when create_sals_line_offset sets the default
|
|
|
8bcabb |
symtab, it immediately calls symtab_to_fullname, passing that fullname
|
|
|
8bcabb |
to collect_symtabs_from_filename to find all matching symtabs. This
|
|
|
8bcabb |
fails because we end up looking for a symtab with the name of the
|
|
|
8bcabb |
actual file on disk (which is different in this case because of the
|
|
|
8bcabb |
symlink) instead of the one stored in the debug info.
|
|
|
8bcabb |
|
|
|
8bcabb |
Since we already have the lookup name of the default symtab, use it
|
|
|
8bcabb |
instead of the fullname. [This fullname thing was originally added
|
|
|
8bcabb |
in 2007 in a series dealing with *displaying* absolute file names.
|
|
|
8bcabb |
Clearly, this instance has nothing to do with the display of file names.]
|
|
|
8bcabb |
|
|
|
8bcabb |
gdb/ChangeLog
|
|
|
8bcabb |
|
|
|
8bcabb |
PR symtab/23853
|
|
|
8bcabb |
* linespec.c (create_sals_line_offset): Search for the default
|
|
|
8bcabb |
symtab's filename instead of its fullname.
|
|
|
8bcabb |
|
|
|
8bcabb |
gdb/testsuite/ChangeLog
|
|
|
8bcabb |
|
|
|
8bcabb |
PR symtab/23853
|
|
|
8bcabb |
* gdb.base/symlink-sourcefile.c: New file.
|
|
|
8bcabb |
* gdb.base/symlink-sourcefile.exp: New file.
|
|
|
8bcabb |
|
|
|
8bcabb |
Index: gdb-7.6.1/gdb/linespec.c
|
|
|
8bcabb |
===================================================================
|
|
|
8bcabb |
--- gdb-7.6.1.orig/gdb/linespec.c
|
|
|
8bcabb |
+++ gdb-7.6.1/gdb/linespec.c
|
|
|
8bcabb |
@@ -1844,17 +1844,15 @@ create_sals_line_offset (struct linespec
|
|
|
8bcabb |
if (VEC_length (symtab_p, ls->file_symtabs) == 1
|
|
|
8bcabb |
&& VEC_index (symtab_p, ls->file_symtabs, 0) == NULL)
|
|
|
8bcabb |
{
|
|
|
8bcabb |
- const char *fullname;
|
|
|
8bcabb |
-
|
|
|
8bcabb |
set_current_program_space (self->program_space);
|
|
|
8bcabb |
|
|
|
8bcabb |
/* Make sure we have at least a default source line. */
|
|
|
8bcabb |
set_default_source_symtab_and_line ();
|
|
|
8bcabb |
initialize_defaults (&self->default_symtab, &self->default_line);
|
|
|
8bcabb |
- fullname = symtab_to_fullname (self->default_symtab);
|
|
|
8bcabb |
VEC_pop (symtab_p, ls->file_symtabs);
|
|
|
8bcabb |
VEC_free (symtab_p, ls->file_symtabs);
|
|
|
8bcabb |
- ls->file_symtabs = collect_symtabs_from_filename (fullname);
|
|
|
8bcabb |
+ ls->file_symtabs
|
|
|
8bcabb |
+ = collect_symtabs_from_filename (self->default_symtab->filename);
|
|
|
8bcabb |
use_default = 1;
|
|
|
8bcabb |
}
|
|
|
8bcabb |
|
|
|
8bcabb |
Index: gdb-7.6.1/gdb/testsuite/gdb.base/symlink-sourcefile.c
|
|
|
8bcabb |
===================================================================
|
|
|
8bcabb |
--- /dev/null
|
|
|
8bcabb |
+++ gdb-7.6.1/gdb/testsuite/gdb.base/symlink-sourcefile.c
|
|
|
8bcabb |
@@ -0,0 +1,26 @@
|
|
|
8bcabb |
+/* Copyright 2019 Free Software Foundation, Inc.
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+ This program is free software; you can redistribute it and/or modify
|
|
|
8bcabb |
+ it under the terms of the GNU General Public License as published by
|
|
|
8bcabb |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
8bcabb |
+ (at your option) any later version.
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+ This program is distributed in the hope that it will be useful,
|
|
|
8bcabb |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8bcabb |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
8bcabb |
+ GNU General Public License for more details.
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+ You should have received a copy of the GNU General Public License
|
|
|
8bcabb |
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+static int
|
|
|
8bcabb |
+foo (void)
|
|
|
8bcabb |
+{
|
|
|
8bcabb |
+ return 0; /* break here */
|
|
|
8bcabb |
+}
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+int
|
|
|
8bcabb |
+main (void)
|
|
|
8bcabb |
+{
|
|
|
8bcabb |
+ return foo ();
|
|
|
8bcabb |
+}
|
|
|
8bcabb |
Index: gdb-7.6.1/gdb/testsuite/gdb.base/symlink-sourcefile.exp
|
|
|
8bcabb |
===================================================================
|
|
|
8bcabb |
--- /dev/null
|
|
|
8bcabb |
+++ gdb-7.6.1/gdb/testsuite/gdb.base/symlink-sourcefile.exp
|
|
|
8bcabb |
@@ -0,0 +1,46 @@
|
|
|
8bcabb |
+# Copyright 2019 Free Software Foundation, Inc.
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+# This program is free software; you can redistribute it and/or modify
|
|
|
8bcabb |
+# it under the terms of the GNU General Public License as published by
|
|
|
8bcabb |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
8bcabb |
+# (at your option) any later version.
|
|
|
8bcabb |
+#
|
|
|
8bcabb |
+# This program is distributed in the hope that it will be useful,
|
|
|
8bcabb |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8bcabb |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
8bcabb |
+# GNU General Public License for more details.
|
|
|
8bcabb |
+#
|
|
|
8bcabb |
+# You should have received a copy of the GNU General Public License
|
|
|
8bcabb |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+# Test that GDB can find the default symtab when it is a symbolic link.
|
|
|
8bcabb |
+standard_testfile
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+set test "file symbolic link name"
|
|
|
8bcabb |
+set srcdirabs [file join [pwd] $srcdir]
|
|
|
8bcabb |
+set linksrc "link-${srcfile}"
|
|
|
8bcabb |
+set srcfilelink [standard_output_file $linksrc]
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+# Remove any existing symlink and build executable using a
|
|
|
8bcabb |
+# symbolic link to the actual source file.
|
|
|
8bcabb |
+remote_file host delete $srcfilelink
|
|
|
8bcabb |
+set status [remote_exec host \
|
|
|
8bcabb |
+ "ln -sf $srcdirabs/$subdir/$srcfile $srcfilelink"]
|
|
|
8bcabb |
+if {[lindex $status 0] != 0} {
|
|
|
8bcabb |
+ unsupported "$test (host does not support symbolic links)"
|
|
|
8bcabb |
+ return 0
|
|
|
8bcabb |
+}
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+if {[prepare_for_testing $testfile $testfile $srcfilelink]} {
|
|
|
8bcabb |
+ return -1
|
|
|
8bcabb |
+}
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+if {![runto_main]} {
|
|
|
8bcabb |
+ untested "could not run to main"
|
|
|
8bcabb |
+ return -1
|
|
|
8bcabb |
+}
|
|
|
8bcabb |
+
|
|
|
8bcabb |
+# Using a line number ensures that the default symtab is used.
|
|
|
8bcabb |
+gdb_breakpoint [gdb_get_line_number "break here" $srcfile] message
|
|
|
8bcabb |
+gdb_continue_to_breakpoint "run to breakpoint marker"
|
|
|
8bcabb |
Index: gdb-7.6.1/gdb/testsuite/lib/gdb.exp
|
|
|
8bcabb |
===================================================================
|
|
|
8bcabb |
--- gdb-7.6.1.orig/gdb/testsuite/lib/gdb.exp
|
|
|
8bcabb |
+++ gdb-7.6.1/gdb/testsuite/lib/gdb.exp
|
|
|
8bcabb |
@@ -4062,7 +4062,10 @@ proc build_executable_from_specs {testna
|
|
|
8bcabb |
set objects {}
|
|
|
8bcabb |
set i 0
|
|
|
8bcabb |
foreach {s local_options} $args {
|
|
|
8bcabb |
- if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } {
|
|
|
8bcabb |
+ if {! [regexp "^/" "$s"] } then {
|
|
|
8bcabb |
+ set s "$srcdir/$subdir/$s"
|
|
|
8bcabb |
+ }
|
|
|
8bcabb |
+ if { [gdb_compile "${s}" "${binfile}${i}.o" object $local_options] != "" } {
|
|
|
8bcabb |
untested $testname
|
|
|
8bcabb |
return -1
|
|
|
8bcabb |
}
|