Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Brendan Kehoe <brendan@zen.org>
To: gdb-gnats@sources.redhat.com, nobody@sources.redhat.com,
		harada@esd.spr.epson.co.jp, gdb-prs@sources.redhat.com,
		gdb-patches@sources.redhat.com
Subject: Re: remote/1832: spaces in directory names
Date: Mon, 13 Feb 2006 17:46:00 -0000	[thread overview]
Message-ID: <43F0C5C9.5010906@zen.org> (raw)

This change makes GDB a little more willing to debug an application on a
remote target when the file or its path happens to have one or more
spaces in it.  Among other things, this makes paths like
   C:/Documents and Settings/Joe Smith/My Documents/hack/mytest
usable when you want to debug mytest on a remote target via 'load'.

Two bits I'll try to bring up elsewhere but want to write down here:
  - I think it'd be better to pass the ARGS part of the on_load callback
function as an array of pointers similar to ARGV, so you don't have to
try to tokenize in places it might matter; and
  - I'm curious about the mystical second argument to the LOAD command
in GDB; it's only mentioned in the docs related to the Sparlet, and even
then only in passing.

Hope this helps,
B

2006-02-13  Brendan Kehoe  <brendan@zen.org>

    * symfile.c (generic_load): Adjust the handling of finding any
    second/offset argument so we can properly use filenames and paths
    that use spaces, like "/home/foo/my hacks/code".  Since the
    LOAD_OFFSET is already initialized to 0 at the beginning, we
    don't need an else stmt.


--- gdb/symfile.c.~1~    2005-08-31 22:07:33.000000000 +0100
+++ gdb/symfile.c    2006-02-13 17:21:16.000000000 +0000
@@ -1626,6 +1626,23 @@ generic_load (char *args, int from_tty)
   old_cleanups = make_cleanup (xfree, filename);
   strcpy (filename, args);
-  offptr = strchr (filename, ' ');
+  offptr = strrchr (filename, ' '); /* find the last space char */
   if (offptr != NULL)
+  {
+    /* Note where the space was, since that's effectively the end
+       of the filename if we have to insert the null char.
+       This implies we won't grok filenames that end in a space. :) */
+    char* end_of_filename = offptr++;
+
+    /* As per ISO 9899 (C99) $7.20.1.4/3 and POSIX 1003.1-2001,
+       strtoul expects a string meeting this sort of expression
+       for an integer-constant:
+          [\s]*[+\-]?(0[xX][0-9a-fA-F]*|[0-9]*)
+       This will be true when its third argument, BASE, is zero.
+       So having skipped the whitespace, we either have to have
+       a '+' or '-', or a valid digit character.  Anything else
+       has to be considered part of the filename.
+     */
+    if ((offptr[0] == '+' || offptr[0] == '-')
+    || (isdigit (offptr[0])))
     {
       char *endptr;
@@ -1634,8 +1651,7 @@ generic_load (char *args, int from_tty)
       if (offptr == endptr)
     error (_("Invalid download offset:%s."), offptr);
-      *offptr = '\0';
+      *end_of_filename = '\0';
     }
-  else
-    cbdata.load_offset = 0;
+  }
 
   /* Open the file for loading. */


             reply	other threads:[~2006-02-13 17:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-13 17:46 Brendan Kehoe [this message]
2006-02-14 10:08 ` Andrew STUBBS
2006-03-01 23:55 ` Michael Snyder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43F0C5C9.5010906@zen.org \
    --to=brendan@zen.org \
    --cc=gdb-gnats@sources.redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=gdb-prs@sources.redhat.com \
    --cc=harada@esd.spr.epson.co.jp \
    --cc=nobody@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox