From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12033 invoked by alias); 5 Dec 2005 19:23:09 -0000 Received: (qmail 12026 invoked by uid 22791); 5 Dec 2005 19:23:08 -0000 X-Spam-Check-By: sourceware.org Received: from lon-del-04.spheriq.net (HELO lon-del-04.spheriq.net) (195.46.50.101) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 05 Dec 2005 19:23:05 +0000 Received: from lon-out-03.spheriq.net ([195.46.50.131]) by lon-del-04.spheriq.net with ESMTP id jB5JN2NH002074 for ; Mon, 5 Dec 2005 19:23:02 GMT Received: from lon-cus-01.spheriq.net (lon-cus-01.spheriq.net [195.46.50.37]) by lon-out-03.spheriq.net with ESMTP id jB5JN18Q005999 for ; Mon, 5 Dec 2005 19:23:01 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by lon-cus-01.spheriq.net with ESMTP id jB5JN0vt020943 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Mon, 5 Dec 2005 19:23:00 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 17B4DDA42 for ; Mon, 5 Dec 2005 19:23:00 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id 5A02E4757A; Mon, 5 Dec 2005 19:26:07 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0736575995 for ; Mon, 5 Dec 2005 19:26:06 +0000 (UTC) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 85CFF4745F for ; Mon, 5 Dec 2005 19:26:06 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CHA74014 (AUTH "andrew stubbs"); Mon, 5 Dec 2005 19:22:58 GMT Message-ID: <43949300.1040203@st.com> Date: Tue, 06 Dec 2005 17:06:00 -0000 From: Andrew STUBBS User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) MIME-Version: 1.0 To: GDB Patches Subject: [PATCH] Allow spaces in filenames to load command Content-Type: multipart/mixed; boundary="------------080905090300020404080107" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.2.0 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: 2005-12/txt/msg00106.txt.bz2 This is a multi-part message in MIME format. --------------080905090300020404080107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 582 Hi, I have been having trouble using GDB when there are spaces in the executable filename (including in parent directories). This is quite common on Windows. The load command attempts to interpret everything after the first space as a load offset - a number - and rejects the command of it won't parse. This even happens when the filename is passed on the GDB command line. The attached patch used buildargv() and tilde_expand() to give this filename the same treatment as exec_file and symbol_file. A quick search of gnats shows that this is bug #535. OK? Andrew Stubbs --------------080905090300020404080107 Content-Type: text/plain; name="load.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="load.patch" Content-length: 2320 2005-12-05 Andrew Stubbs * symfile.c (generic_load): Use buildargv and tilde_expand to parse file names with quoting, spaces and tildes properly. Index: src/gdb/symfile.c =================================================================== --- src.orig/gdb/symfile.c 2005-12-02 16:15:22.000000000 +0000 +++ src/gdb/symfile.c 2005-12-05 18:46:48.000000000 +0000 @@ -1615,8 +1615,7 @@ generic_load (char *args, int from_tty) bfd *loadfile_bfd; struct timeval start_time, end_time; char *filename; - struct cleanup *old_cleanups; - char *offptr; + struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0); struct load_section_data cbdata; CORE_ADDR entry; @@ -1625,23 +1624,36 @@ generic_load (char *args, int from_tty) cbdata.data_count = 0; /* Number of bytes written to target memory. */ cbdata.total_size = 0; /* Total size of all bfd sectors. */ - /* Parse the input argument - the user can specify a load offset as - a second argument. */ - filename = xmalloc (strlen (args) + 1); - old_cleanups = make_cleanup (xfree, filename); - strcpy (filename, args); - offptr = strchr (filename, ' '); - if (offptr != NULL) - { - char *endptr; - - cbdata.load_offset = strtoul (offptr, &endptr, 0); - if (offptr == endptr) - error (_("Invalid download offset:%s."), offptr); - *offptr = '\0'; - } + /* Do we have args from the user or from the default? */ + if (exec_bfd && args == get_exec_file (1)) + /* The string is ONLY the file name. */ + filename = args; else - cbdata.load_offset = 0; + { + /* We have args from the user so the filename may be quoted + and there may be an offset argument. */ + char **argv = buildargv (args); + + if (argv == NULL) + nomem(0); + + make_cleanup_freeargv (argv); + + filename = tilde_expand (argv[0]); + make_cleanup (xfree, filename); + + if (argv[1] != NULL) + { + char *endptr; + + cbdata.load_offset = strtoul (argv[1], &endptr, 0); + + /* If the last word was not a valid number then + treat it as a file name with spaces in. */ + if (argv[1] == endptr) + error (_("Invalid download offset:%s."), argv[1]); + } + } /* Open the file for loading. */ loadfile_bfd = bfd_openr (filename, gnutarget); --------------080905090300020404080107--