From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28061 invoked by alias); 12 Aug 2011 15:50:34 -0000 Received: (qmail 28051 invoked by uid 22791); 12 Aug 2011 15:50:33 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL,BAYES_20,MSGID_MULTIPLE_AT,TW_CP X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.154) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Aug 2011 15:50:17 +0000 Received: from md1.u-strasbg.fr (md1.u-strasbg.fr [IPv6:2001:660:2402::186]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id p7CFoE7w092736 for ; Fri, 12 Aug 2011 17:50:14 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms1.u-strasbg.fr [130.79.204.10]) by md1.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p7CFoD07077277 for ; Fri, 12 Aug 2011 17:50:14 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p7CFoDDe065175 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Fri, 12 Aug 2011 17:50:13 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: Subject: [RFC] Fix problems related to Mingw/DJGPP file names containing colons Date: Fri, 12 Aug 2011 15:50:00 -0000 Message-ID: <004901cc5907$85006320$8f012960$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-08/txt/msg00250.txt.bz2 Using current CVS source, I am unable to handle files having Dos style directory specifications inside the stabs debugging information (but I don't think that this is stabs specific). Release 7.3 has the same problem... The program test.exe below has been compiled with Free Pascal for win32 target (more or less mingw). When I try to insert a break point at a line of current file, the addr_string computed is "e:/pas/trunk/fpcsrc/ide/test.pas:166". But locate_first_half function stops at the first colon and GDB complains because file "e" is not found. I first tried to add double-quotes around the file name, but this was not enough... I suspect that the other changes below that I had to add are just errors in the current implementation... See below for submitted patch. Nevertheless, this implementation will probably fail miserably for file names containing double-quotes, not sure if this is allowed on some OS's or FileSystems... Comments most welcome Pierre Muller GDB pascal language maintainer >>>> GDB session illustrating the problem E:\pas\trunk\fpcsrc\ide>gdbcvsmult test GNU gdb (GDB) 7.3.50.20110805-cvs Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-mingw32". For bug reporting instructions, please see: ... Reading symbols from E:\pas\trunk\fpcsrc\ide/test.exe...done. (gdb) li main 157 end; 158 159 var i,j : longint; 160 Length : longint; 161 162 BEGIN 163 {$ifdef m68k} 164 asm 165 beq @L13 166 bhi @L13 (gdb) b 166 Breakpoint 1 at 0x40170d: file e:/pas/trunk/fpcsrc/ide/test.pas, line 166. (gdb) r Starting program: E:\pas\trunk\fpcsrc\ide/test.exe [New Thread 1116.0xe38] Error in re-setting breakpoint 1: No source file named e. Obj1.Z=1 Hello world! ParamCount = 0 Paramstr(0) = E:\pas\trunk\fpcsrc\ide\test.exe FALSE dummy for browser dummy for browser 0 [Inferior 1 (process 1116) exited with code 04] (gdb) 2011-08-12 Pierre Muller * linespec.c (build_canonical_line_spec): Handle Dos style filenames by adding double-quotes around the file name. (locate_first_half): Exit at the end of double-quoted part. Never stop inside double-quoted part. (symtab_from_filename): Move past the ending double-quote if IS_QUOTE_ENCLOSED is set. Index: src/gdb/linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.128 diff -u -p -r1.128 linespec.c --- src/gdb/linespec.c 5 Jul 2011 20:30:19 -0000 1.128 +++ src/gdb/linespec.c 12 Aug 2011 15:30:43 -0000 @@ -455,7 +455,11 @@ build_canonical_line_spec (struct symtab else { canonical_name = xmalloc (strlen (filename) + 30); - sprintf (canonical_name, "%s:%d", filename, sal->line); + /* Quote filenames containing ':' characters to avoid problems. */ + if (strchr (filename, ':') != NULL && filename[0] != '"') + sprintf (canonical_name, "\"%s\":%d", filename, sal->line); + else + sprintf (canonical_name, "%s:%d", filename, sal->line); } canonical_arr[0] = canonical_name; } @@ -1214,12 +1218,16 @@ locate_first_half (char **argptr, int *i { break; } + /* Consider a double quote to be the end of the first half. */ + if (*is_quote_enclosed && p[0] == '"') + return p; + /* 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, nor on colons. */ if (!*p || p[0] == '\t' - || (p[0] == ':') + || ((p[0] == ':') && !*is_quote_enclosed) || ((p[0] == ' ') && !*is_quote_enclosed)) break; if (p[0] == '.' && strchr (p, ':') == NULL) @@ -1796,12 +1804,10 @@ symtab_from_filename (char **argptr, cha char *p1; char *copy; struct symtab *file_symtab; - + p1 = p; while (p != *argptr && p[-1] == ' ') --p; - if ((*p == '"') && is_quote_enclosed) - --p; copy = (char *) alloca (p - *argptr + 1); memcpy (copy, *argptr, p - *argptr); /* It may have the ending quote right after the file name. */ @@ -1822,8 +1828,11 @@ symtab_from_filename (char **argptr, cha throw_error (NOT_FOUND_ERROR, _("No source file named %s."), copy); } + if (p1[0] == '"' && is_quote_enclosed) + p1++; /* Discard the file name from the arg. */ p = p1 + 1; + while (*p == ' ' || *p == '\t') p++; *argptr = p;