[v12,09/32] Change sysroot to ":target:"

Message ID 20150821212118.6673.6454.stgit@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil Aug. 21, 2015, 9:21 p.m. UTC
  Hi,

that is try "" first and "target:" second.

Various performance problems should be fixed by trying to look up the remote
file first on local filesystem.  Thanks to build-ids it is quick and safe to
verify both files are the same build.


Jan


gdb/ChangeLog
2015-08-18  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* NEWS (Changes since GDB 7.10): Mention sysroot.
	* main.c (captured_main): Initialize new gdb_sysroot.

gdb/testsuite/ChangeLog

	* gdb.base/attach.exp (do_attach_tests): Update sysroot parsing.
	* gdb.base/break-probes.exp: Likewise.
---
 gdb/testsuite/gdb.base/attach.exp       |    7 +++++--
 gdb/testsuite/gdb.base/break-probes.exp |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gdb/NEWS b/gdb/NEWS
index f5a01e8..a45aaa6 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -38,6 +38,9 @@  show debug bfd-cache
 * The "set sysroot" (and "show sysroot") commands now permit multiple
   directory paths.
 
+* Default sysroot has changed to ":target:", that is first host files
+  and then target files are tried.
+
 * New options
 
 set validate-build-id (on|off)
diff --git a/gdb/main.c b/gdb/main.c
index aecd60a..a17ee34 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -548,7 +548,11 @@  captured_main (void *data)
   if (gdb_sysroot == NULL || *gdb_sysroot == '\0')
     {
       xfree (gdb_sysroot);
-      gdb_sysroot = xstrdup (TARGET_SYSROOT_PREFIX);
+      
+      /* Try first the local filesystem,
+         TARGET_SYSROOT_PREFIX is a fallback.  */
+      gdb_sysroot = xstrprintf ("%c%s", DIRNAME_SEPARATOR,
+				TARGET_SYSROOT_PREFIX);
     }
 
   debug_file_directory = relocate_gdb_directory (DEBUGDIR,
diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
index bf0d84e..a879e33 100644
--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -67,7 +67,7 @@  proc do_attach_tests {} {
     global timeout
     
     # Figure out a regular expression that will match the sysroot,
-    # noting that the default sysroot is "target:", and also noting
+    # noting that the default sysroot is ":target:", and also noting
     # that GDB will strip "target:" from the start of filenames when
     # operating on the local filesystem
     set sysroot ""
@@ -77,7 +77,10 @@  proc do_attach_tests {} {
 	    set sysroot $expect_out(1,string)
 	}
     }
-    regsub "^target:" "$sysroot" "(target:)?" sysroot
+    # Use only the first element of $sysroot which will hopefully
+    # successfully match the filename.
+    regsub "^target:(\[^:\]*):.*$" "$sysroot" "" sysroot
+    regsub "^(?!target:)(\[^:\]*):.*$" "$sysroot" "" sysroot
 
     # Start the program running and then wait for a bit, to be sure
     # that it can be attached to.
diff --git a/gdb/testsuite/gdb.base/break-probes.exp b/gdb/testsuite/gdb.base/break-probes.exp
index 00ca458..0431aa3 100644
--- a/gdb/testsuite/gdb.base/break-probes.exp
+++ b/gdb/testsuite/gdb.base/break-probes.exp
@@ -67,8 +67,11 @@  if { $using_probes } {
     }
 
     # GDB strips "target:" from the start of filenames
-    # when operating on the local filesystem
-    regsub "^target:" "$sysroot" "(target:)?" sysroot
+    # when operating on the local filesystem.
+    # Also use only the first element of $sysroot which will hopefully
+    # successfully match the filename.
+    regsub "^target:(\[^:\]*):.*$" "$sysroot" "" sysroot
+    regsub "^(?!target:)(\[^:\]*):.*$" "$sysroot" "" sysroot
 
     # Run til it loads our library
     set test "run til our library loads"