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