;; Fix comma handling in paths. ;; (Keith Seitz, RH BZ 1779246) *** gdb-7.6.1.orig/gdb/linespec.c 2020-05-06 17:02:38.202690042 -0400 --- gdb-7.6.1/gdb/linespec.c 2020-05-07 16:22:23.959113669 -0400 *************** canonicalize_linespec (struct linespec_s *** 1770,1776 **** --- 1770,1782 ---- buf = mem_fileopen (); if (ls->source_filename) { + int needs_quote = strchr (ls->source_filename, ',') != NULL; + + if (needs_quote) + fputc_unfiltered ('\"', buf); fputs_unfiltered (ls->source_filename, buf); + if (needs_quote) + fputc_unfiltered ('\"', buf); need_colon = 1; } *** gdb-7.6.1.orig/gdb/testsuite/gdb.linespec/commas.exp 1969-12-31 19:00:00.000000000 -0500 --- gdb-7.6.1/gdb/testsuite/gdb.linespec/commas.exp 2020-05-07 15:20:35.398286038 -0400 *************** *** 0 **** --- 1,61 ---- + # Copyright 2020 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 the use of commas in filenames. + # One simple rule to keep in mind regarding commas in filenames: + # they MUST be quote-enclosed. Commas are used by dprintf to + # separate location, format string, and args. Linespec also uses + # commas to separate locations for ranged breakpoints. + + set one foozle,barzle/one.cc + set two foozle,barzle/barzle,bazzle/onezle,twozle.cc + standard_testfile $one + + if {[skip_cplus_tests]} { + unsupported commas.exp + return + } + + if {[prepare_for_testing ${testfile}.exp $testfile [list $one $two] \ + {debug nowarnings c++}]} { + return -1 + } + + # Turn off pending breakpoints to facilitate testing invalid linespecs. + gdb_test_no_output "set breakpoint pending off" + + # The expected error message from GDB when an unquoted linespec + # is given which contains commas. + set unquoted_comma "Function \"[lindex [split $one ,] 0]\" not defined." + + # Test that the default symtab is usable. + # We cannot runto main here -- that defeats the purpose of the test. + set first_line [gdb_get_line_number "break here" $one] + runto $first_line message + + # Test directories with commas. + gdb_test "break $one:$first_line" $unquoted_comma \ + "breakpoint at one:first_line" + runto "\"$one\":$first_line" message + gdb_test "list $one:0" $unquoted_comma + gdb_test "list \"$one\":0" "This testcase is part of GDB.*" + + # Test filenames with commas. + set marker1 [gdb_get_line_number "marker 1" $two] + gdb_test "break $two:$marker1" $unquoted_comma \ + "breakpoint at two:marker1" + runto "\"$two\":$marker1" message + gdb_test "list $two:0" $unquoted_comma + gdb_test "list \"$two\":0" "This testcase is part of GDB.*" *** gdb-7.6.1.orig/gdb/testsuite/gdb.linespec/foozle,barzle/one.cc 1969-12-31 19:00:00.000000000 -0500 --- gdb-7.6.1/gdb/testsuite/gdb.linespec/foozle,barzle/one.cc 2020-05-07 13:23:52.293146501 -0400 *************** *** 0 **** --- 1,26 ---- + /* This testcase is part of GDB, the GNU debugger. + + Copyright 2020 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 . */ + + extern int onetwo (int); + + int + main () + { + int i = 1; // break here + + return onetwo (++i); + } *** gdb-7.6.1.orig/gdb/testsuite/gdb.linespec/foozle,barzle/barzle,bazzle/onezle,twozle.cc 1969-12-31 19:00:00.000000000 -0500 --- gdb-7.6.1/gdb/testsuite/gdb.linespec/foozle,barzle/barzle,bazzle/onezle,twozle.cc 2020-05-07 13:58:41.720152058 -0400 *************** *** 0 **** --- 1,22 ---- + /* This testcase is part of GDB, the GNU debugger. + + Copyright 2020 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 . */ + + int + onetwo (int i) + { + return i + 12; // marker 1 + }