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 #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 . + +# 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."