From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20784 invoked by alias); 17 Jun 2006 16:23:09 -0000 Received: (qmail 20774 invoked by uid 22791); 17 Jun 2006 16:23:08 -0000 X-Spam-Check-By: sourceware.org Received: from mailout08.sul.t-online.com (HELO mailout08.sul.t-online.com) (194.25.134.20) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 17 Jun 2006 16:23:06 +0000 Received: from fwd33.aul.t-online.de by mailout08.sul.t-online.com with smtp id 1FrdZf-0003sX-00; Sat, 17 Jun 2006 18:23:03 +0200 Received: from merlin (E2s8XZZLoeX4ncW-LLaYYhF+lhjioXSRFhH0eC-90cgOQyrfssWWEe@[84.138.89.117]) by fwd33.sul.t-online.de with esmtp id 1FrdZa-1kfcKO0; Sat, 17 Jun 2006 18:22:58 +0200 From: "Michael Fischer" To: Subject: [PATCH] source.s: Fix problem handling windows like path with MinGW Date: Sat, 17 Jun 2006 16:23:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-ID: E2s8XZZLoeX4ncW-LLaYYhF+lhjioXSRFhH0eC-90cgOQyrfssWWEe X-TOI-MSGID: 513dc077-4a74-4121-a31b-6bdc934c312d X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00243.txt.bz2 Hello, the patch below will fix the problem if an application sends path information like "d:\foo1\foo2" instead of "/d/foo1/foo2" I has some problem to get Eclipse running with a MinGW based arm toolchain. The debugger could not find the source information. I have change the openp function which try to find a file given by string and searching in path. Here are some examples how the path could look like: 1. "D:\Projekte\Eclipse\Test:$cwd" 2. "D:\Projekte\Eclipse\Test:D:\Projekte\Eclipse\Test\src:D:\Projekte\Eclipse\T est\inc:$cwd" The problem is, that the DIRNAME_SEPARATOR is used to separate path part-one from path part-two and so on. In case #1 "D:\Projekte\Eclipse\STR7Test" from "$cwd". At the same time DIRNAME_SEPARATOR is used to separate the drive from the path itself :. If the application send only path information like: 3. "/D/Projekte/Eclipse/Test:$cwd" 4. "/D/Projekte/Eclipse/Test:/D/Projekte/Eclipse/Test/src:/D/Projekte/Eclipse/T est/inc:$cwd" the old implementation is working, here we can use the DIRNAME_SEPARATOR to separate each path from another. But for #1 we got "\Projekte\Eclipse\Test", the drive information is missing here. The additional code should handle the problem. I have done the diff against gdb-6.5.50.20060615.tar.bz2, sorry I do not know how can I make a diff against the cvs tree. Please check it, specially if it is allowed to use alloca more than one time. Can someone take it to the CVS if this patch is axactable? Best regards, Michael PS: This is my first patch here, therefore I could use the wrong style for it. Please correct me. diff -Naur gdb-6.5.50.20060615/gdb/source.c gdb-6.5.50.20060615-arm/gdb/source.c --- gdb-6.5.50.20060615/gdb/source.c Mon May 15 15:50:13 2006 +++ gdb-6.5.50.20060615-arm/gdb/source.c Sat Jun 17 15:56:11 2006 @@ -721,6 +721,109 @@ /* ./foo => foo */ while (string[0] == '.' && IS_DIR_SEPARATOR (string[1])) string += 2; + +#ifdef __MINGW32__ + alloclen = strlen (path) + strlen (string) + 2; + filename = alloca (alloclen); + fd = -1; + + /* + * Special handling for a windows path. + * Here are some examples how the path could look like: + * + * 1. "D:\Projekte\Eclipse\Test:$cwd" + * 2. "D:\Projekte\Eclipse\Test:D:\Projekte\Eclipse\Test\src:D:\Projekte\Eclipse\T est\inc:$cwd" + * + * The problem is, that the DIRNAME_SEPARATOR is used to separate + * path one from path two and so on. In case #1 "D:\Projekte\Eclipse\STR7Test" + * from "$cwd". At the same time DIRNAME_SEPARATOR is used to separate + * the drive from the path itself :. + * + * If the application send only path information like: + * + * 3. "/D/Projekte/Eclipse/Test:$cwd" + * 4. "/D/Projekte/Eclipse/Test:/D/Projekte/Eclipse/Test/src:/D/Projekte/Eclipse/T est/inc:$cwd" + * + * the old implementation is working, here we can use the DIRNAME_SEPARATOR + * to separate each path from another. But for #1 we got "\Projekte\Eclipse\Test", the drive + * information is missing here. The additional code should handle the problem. + */ + p = path; + while (*p != 0) + { + if (IS_ABSOLUTE_PATH(p)) + { + /* Start to extract the path */ + + /* Copy the and DIRNAME_SEPARATOR */ + strncpy(filename, path, 2); + p = p + 2; + len = 2; + + /* Copy the rest up to the next DIRNAME_SEPARATOR */ + while ((*p != DIRNAME_SEPARATOR) && (len < alloclen)) + { + filename[len++] = *p++; + } + filename[len] = 0; + + /* At this point we have the path + information and can add the string */ + strcat (filename, SLASH_STRING); + strcat (filename, string); + + /* Jump over the ":", + for the next round */ + p++; + } + else + { + /* No absolute path found, this could be the current dir + or a mix of windows style and the other one */ + len = strlen (p); + if (len == 4 && p[0] == '$' && p[1] == 'c' && p[2] == 'w' && p[3] == 'd') + { + /* Name is $cwd -- insert current directory name instead. */ + int newlen; + + /* First, realloc the filename buffer if too short. */ + len = strlen (current_directory); + newlen = len + strlen (string) + 2; + if (newlen > alloclen) + { + alloclen = newlen; + filename = alloca (alloclen); + } + strcpy (filename, current_directory); + strcat (filename, SLASH_STRING); + strcat (filename, string); + + /* Jump over the $cwd, p should no point to the + end (*p==0), and we will leave the loop after + the last filename check */ + p += 4; + } + else + { + /* It was not the $cwd, we does not handle this + situation, leave the loop */ + break; + } + } /* end if (IS_ABSOLUTE_PATH(p))*/ + + /* We have a filename and can check it */ + if (is_regular_file (filename)) + { + fd = open (filename, mode); + if (fd >= 0) + { + /* We have found the file */ + goto done; + } + } + + } /* while (*p != 0) */ +#endif /* __MINGW32__ */ alloclen = strlen (path) + strlen (string) + 2; filename = alloca (alloclen);