Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] 12843
@ 2011-08-25 21:59 Keith Seitz
  2011-08-26 18:23 ` Tom Tromey
  0 siblings, 1 reply; 28+ messages in thread
From: Keith Seitz @ 2011-08-25 21:59 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1515 bytes --]

Hi,

A long time ago, some linespec hacking that I did broke the ability to 
use drive letters on Windows. This turned out especially bad since 
linespec canonicalization could unexpectedly (to the user) include them. 
As a result, gdb was/is unable to re-set some breakpoints on Windows hosts.

This is a pretty simple patch to workaround this problem. It is not 
perfect, but implementing something "proper" would be very involved, and 
I am not quite sure I want to commit to hacking more of linespec.c 
without rewriting the whole thing (which would certainly interfer with 
Tom's ambiguous linespec work).

So I'm not sure whether this should be an RFC or and RFA, but I've 
decided the later.

This patch checks if ':' is followed by '/' and/or '\\' (depending on 
definition of IS_DIR_SEPARATOR). If it is, we keep looking for the next 
terminal in the string. This is problematic for filenames with ":\\" or 
"://" in them, but locate_first_half has gotten those wrong for a long, 
long time (in fact, any filename at all with a colon(s) in it).

In any case, this patch will allow Windows hosts to function properly 
again, and causes no regressions on x86_64-linux and i686-pc-cygwin32.

Keith

ChangeLog
2011-08-25  Keith Seitz  <keiths@redhat.com>

	PR gdb/12843
	* linespec.c (locate_first_half): Do not stop on a colon
	if the next character is a directory separator character.

testsuite/ChangeLog
2011-08-25  Keith Seitz  <keiths@redhat.com>

	PR gdb/12843
	* gdb.base/ls-driveletter.exp: New file.

[-- Attachment #2: 12843.patch --]
[-- Type: text/plain, Size: 2399 bytes --]

diff --git a/gdb/linespec.c b/gdb/linespec.c
index b96c79f..b35ac6a 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -43,6 +43,7 @@
 #include "arch-utils.h"
 #include <ctype.h>
 #include "cli/cli-utils.h"
+#include "filenames.h"
 
 /* Prototypes for local functions.  */
 
@@ -1216,10 +1217,16 @@ locate_first_half (char **argptr, int *is_quote_enclosed)
 	}
       /* Check for the end of the first half of the linespec.  End of
          line, a tab, a colon or a space.  But if enclosed in double
-	 quotes we do not break on enclosed spaces.  */
+	 quotes we do not break on enclosed spaces.
+
+	 Colons are especially problematic, since we don't really want to stop
+	 if the colon is part of a filename.  The simple heuristic used here
+	 is to keep going if the colon is followed by a directory separator.
+	 This will capture drive letters on Windows, but it will (still) fail
+	 for any filename containing ":", "::", ":/", or ":\\".  */
       if (!*p
 	  || p[0] == '\t'
-	  || (p[0] == ':')
+	  || (p[0] == ':' && !IS_DIR_SEPARATOR (p[1]))
 	  || ((p[0] == ' ') && !*is_quote_enclosed))
 	break;
       if (p[0] == '.' && strchr (p, ':') == NULL)
diff --git a/gdb/testsuite/gdb.base/ls-driveletter.exp b/gdb/testsuite/gdb.base/ls-driveletter.exp
new file mode 100644
index 0000000..66efd1f
--- /dev/null
+++ b/gdb/testsuite/gdb.base/ls-driveletter.exp
@@ -0,0 +1,26 @@
+# Copyright 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test linespecs containing drive letters.
+# PR gdb/12843
+
+# We don't actually need our own test case to test this, so grab
+# another one.
+
+if {[prepare_for_testing ls-driveletter.exp memattr memattr.c {debug}]} {
+  return -1
+}
+
+gdb_test "list c:/foo/bar/baz.c:1" "No source file named c:/foo/bar/baz.c."

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2011-09-02 14:31 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25 21:59 [RFA] 12843 Keith Seitz
2011-08-26 18:23 ` Tom Tromey
2011-08-26 18:46   ` Keith Seitz
2011-08-26 19:07     ` Tom Tromey
2011-08-27  8:45       ` Eli Zaretskii
2011-08-27 13:17         ` asmwarrior
2011-08-29 19:18         ` Tom Tromey
2011-08-29  7:19       ` André Pönitz
2011-08-29 10:13         ` Pedro Alves
2011-08-29 12:06           ` Matt Rice
2011-08-29 12:15           ` André Pönitz
2011-08-29 13:53             ` Pedro Alves
2011-08-29 19:21             ` Jan Kratochvil
2011-08-30  8:19               ` André Pönitz
2011-08-30  9:21                 ` Jan Kratochvil
2011-08-30 15:02                 ` Tom Tromey
2011-08-30 16:34                   ` André Pönitz
2011-08-30 17:21                     ` Tom Tromey
2011-08-31  8:54                       ` André Pönitz
2011-08-29 19:46         ` Tom Tromey
2011-08-29 21:13           ` Keith Seitz
2011-08-30  2:35             ` Daniel Jacobowitz
2011-08-30 15:00             ` Tom Tromey
2011-08-30 17:24               ` Tom Tromey
2011-08-31 18:17   ` Keith Seitz
2011-08-31 18:23     ` Jan Kratochvil
2011-08-31 18:52     ` Tom Tromey
2011-09-02 16:04     ` asmwarrior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox