Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Allow spaces in filename to add-symbol-file command
@ 2005-12-06 22:14 Andrew STUBBS
  2006-02-20 17:15 ` Daniel Jacobowitz
  2006-02-21 19:41 ` Jim Blandy
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew STUBBS @ 2005-12-06 22:14 UTC (permalink / raw)
  To: GDB Patches

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

Hi,

The war against missing space support continues!

I have altered add_symbol_file_command() to use buildargv() instead of 
parsing the arguments itself. This should allow quoting and hence spaces 
in the filename.

Additionally, I have reordered the help message so that 'help files' 
uses the right part of the message and updated the testsuite to match.

OK?

Andrew Stubbs

[-- Attachment #2: add-symbol-file.patch --]
[-- Type: text/plain, Size: 4358 bytes --]

2005-12-06  Andrew Stubbs  <andrew.stubbs@st.com>

	* symfile.c (add_symbol_file_command): Use buildargv(), instead of
	hand decoding the command line, to allow use of quotes and spaces.
	(_initialize_symfile): Reorganize the help message for add-symbol-file
	such that 'help files' shows a better message.

testsuite/
	* gdb.base/help.exp (help add-symbol-file): Update.

Index: src/gdb/symfile.c
===================================================================
--- src.orig/gdb/symfile.c	2005-12-05 19:02:38.000000000 +0000
+++ src/gdb/symfile.c	2005-12-06 16:32:28.000000000 +0000
@@ -1782,6 +1782,7 @@ add_symbol_file_command (char *args, int
   int i;
   int expecting_sec_name = 0;
   int expecting_sec_addr = 0;
+  char **argv;
 
   struct sect_opt
   {
@@ -1803,28 +1804,15 @@ add_symbol_file_command (char *args, int
   if (args == NULL)
     error (_("add-symbol-file takes a file name and an address"));
 
-  /* Make a copy of the string that we can safely write into. */
-  args = xstrdup (args);
+  argv = buildargv (args);
+  make_cleanup_freeargv (argv);
 
-  while (*args != '\000')
-    {
-      /* Any leading spaces? */
-      while (isspace (*args))
-	args++;
-
-      /* Point arg to the beginning of the argument. */
-      arg = args;
-
-      /* Move args pointer over the argument. */
-      while ((*args != '\000') && !isspace (*args))
-	args++;
+  if (argv == NULL)
+    nomem (0);
 
-      /* If there are more arguments, terminate arg and
-         proceed past it. */
-      if (*args != '\000')
-	*args++ = '\000';
-
-      /* Now process the argument. */
+  for (arg = argv[0], argcnt = 0; arg != NULL; arg = argv[++argcnt])
+    {
+      /* Process the argument. */
       if (argcnt == 0)
 	{
 	  /* The first argument is the file name. */
@@ -1887,7 +1875,6 @@ add_symbol_file_command (char *args, int
 		    error (_("USAGE: add-symbol-file <filename> <textaddress> [-mapped] [-readnow] [-s <secname> <addr>]*"));
 	      }
 	  }
-      argcnt++;
     }
 
   /* Print the prompt for the query below. And save the arguments into
@@ -3710,8 +3697,8 @@ to execute."), &cmdlist);
   set_cmd_completer (c, filename_completer);
 
   c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command, _("\
+Load symbols from FILE, assuming FILE has been dynamically loaded.\n\
 Usage: add-symbol-file FILE ADDR [-s <SECT> <SECT_ADDR> -s <SECT> <SECT_ADDR> ...]\n\
-Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\
 ADDR is the starting address of the file's text.\n\
 The optional arguments are section-name section-address pairs and\n\
 should be specified if the data and bss segments are not contiguous\n\
Index: src/gdb/testsuite/gdb.base/help.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/help.exp	2005-12-02 16:15:21.000000000 +0000
+++ src/gdb/testsuite/gdb.base/help.exp	2005-12-06 17:03:18.000000000 +0000
@@ -35,7 +35,7 @@ gdb_test "set height 400" "" "test set h
 
 # use a larger expect input buffer for long help outputs.
 # test help add-symbol-file
-gdb_test "help add-symbol-file" "Usage: add-symbol-file FILE ADDR \\\[-s <SECT> <SECT_ADDR> -s <SECT> <SECT_ADDR> \.\.\.\\\]\[\r\n\]+Load the symbols from FILE, assuming FILE has been dynamically loaded\.\[\r\n\]+ADDR is the starting address of the file's text\.\[\r\n\]+The optional arguments are section-name section-address pairs and\[\r\n\]+should be specified if the data and bss segments are not contiguous\[\r\n\]+with the text\.  SECT is a section name to be loaded at SECT_ADDR\." "help add-symbol-file"
+gdb_test "help add-symbol-file" "Load symbols from FILE, assuming FILE has been dynamically loaded\.\[\r\n\]+Usage: add-symbol-file FILE ADDR \\\[-s <SECT> <SECT_ADDR> -s <SECT> <SECT_ADDR> \.\.\.\\\]\[\r\n\]+ADDR is the starting address of the file's text\.\[\r\n\]+The optional arguments are section-name section-address pairs and\[\r\n\]+should be specified if the data and bss segments are not contiguous\[\r\n\]+with the text\.  SECT is a section name to be loaded at SECT_ADDR\." "help add-symbol-file"
 # test help advance
 gdb_test "help advance" "Continue the program up to the given location \\(same form as args for break command\\)\.\[\r\n]+Execution will also stop upon exit from the current stack frame\." "help advance"
 # test help aliases

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Allow spaces in filename to add-symbol-file command
  2005-12-06 22:14 [PATCH] Allow spaces in filename to add-symbol-file command Andrew STUBBS
@ 2006-02-20 17:15 ` Daniel Jacobowitz
  2006-02-21 19:23   ` Andrew STUBBS
  2006-02-21 19:41 ` Jim Blandy
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2006-02-20 17:15 UTC (permalink / raw)
  To: Andrew STUBBS; +Cc: GDB Patches

On Tue, Dec 06, 2005 at 05:03:24PM +0000, Andrew STUBBS wrote:
> Hi,
> 
> The war against missing space support continues!
> 
> I have altered add_symbol_file_command() to use buildargv() instead of 
> parsing the arguments itself. This should allow quoting and hence spaces 
> in the filename.
> 
> Additionally, I have reordered the help message so that 'help files' 
> uses the right part of the message and updated the testsuite to match.
> 
> OK?

> 2005-12-06  Andrew Stubbs  <andrew.stubbs@st.com>
> 
> 	* symfile.c (add_symbol_file_command): Use buildargv(), instead of
> 	hand decoding the command line, to allow use of quotes and spaces.
> 	(_initialize_symfile): Reorganize the help message for add-symbol-file
> 	such that 'help files' shows a better message.
> 
> testsuite/
> 	* gdb.base/help.exp (help add-symbol-file): Update.

Yes, this is OK.  Thanks.

It is an incompatible change in one small corner-case - backslashes
will suddenly be escaped for files without spaces, while previously
they were not.  But, the most prevalent file-related command is
"file" (and "exec-file" and "symbol-file"), so I think following them
is a good choice.

Interestingly, var_filename calls tilde_expand, includes all remaining
text on the line ignoring whitespace, and doesn't handle quotes or
backslashes.  Ditto for var_optional_filename (which is used for
"set args" - what the heck?).

Do we need to clean this up? :-(

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Allow spaces in filename to add-symbol-file command
  2006-02-20 17:15 ` Daniel Jacobowitz
@ 2006-02-21 19:23   ` Andrew STUBBS
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew STUBBS @ 2006-02-21 19:23 UTC (permalink / raw)
  To: Andrew STUBBS, GDB Patches

Daniel Jacobowitz wrote:
> Yes, this is OK.  Thanks.

Committed.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Allow spaces in filename to add-symbol-file command
  2005-12-06 22:14 [PATCH] Allow spaces in filename to add-symbol-file command Andrew STUBBS
  2006-02-20 17:15 ` Daniel Jacobowitz
@ 2006-02-21 19:41 ` Jim Blandy
  2006-02-21 19:47   ` Andrew STUBBS
  1 sibling, 1 reply; 5+ messages in thread
From: Jim Blandy @ 2006-02-21 19:41 UTC (permalink / raw)
  To: Andrew STUBBS; +Cc: GDB Patches

On 12/6/05, Andrew STUBBS <andrew.stubbs@st.com> wrote:
> The war against missing space support continues!

Andrew can be GDB's official spaceman!  :)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Allow spaces in filename to add-symbol-file command
  2006-02-21 19:41 ` Jim Blandy
@ 2006-02-21 19:47   ` Andrew STUBBS
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew STUBBS @ 2006-02-21 19:47 UTC (permalink / raw)
  To: Jim Blandy; +Cc: GDB Patches

Jim Blandy wrote:
> On 12/6/05, Andrew STUBBS <andrew.stubbs@st.com> wrote:
>> The war against missing space support continues!
> 
> Andrew can be GDB's official spaceman!  :)

Well, you do have to wonder ... what _is_ holding space up there?


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-02-21 19:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-06 22:14 [PATCH] Allow spaces in filename to add-symbol-file command Andrew STUBBS
2006-02-20 17:15 ` Daniel Jacobowitz
2006-02-21 19:23   ` Andrew STUBBS
2006-02-21 19:41 ` Jim Blandy
2006-02-21 19:47   ` Andrew STUBBS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox