* Proposed patch for gdb/mi 741
@ 2002-10-09 12:50 J. Johnston
2002-10-09 23:03 ` Eli Zaretskii
2002-10-22 9:08 ` Elena Zannoni
0 siblings, 2 replies; 17+ messages in thread
From: J. Johnston @ 2002-10-09 12:50 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2251 bytes --]
The following solves a number of problems with the mi -environment commands.
For starters, each command now has an mi cmd wrapper so arguments may use the
syntax of adding double-quotes to handle extraneous characters such as spaces.
The -environment-pwd command now lists the output in mi syntax:
e.g.
-environment-pwd
^done,cwd="...."
The -environment-directory command has been changed to output in mi format.
It also has been changed to allow for no arguments being passed.
If no arguments are passed, it behaves like the gdb dir command and resets the
source search path to the default, however, no confirmation query is performed. If an empty
string "" is passed, it is ignored so this can be used to display the current
search path without modifying it.
e.g.
-environment-directory /usr/bin /usr/local/bin
^done,source-path="/usr/bin:/usr/local/bin:$cdir:$cwd"
The -environment-path command has been changed to output in mi format.
It also has been changed to allow for no arguments being passed. When
no arguments are passed, the current object search path is displayed.
e.g.
-environment-path
^done,path="....."
For mi1 or below, the previous behavior is preserved by rerouting the commands
to their old cli counterparts.
Eli, I have split the doc changes into 741doc.patch for your convenience. Let me know
if there are any problems.
gdb/mi/ChangeLog:
2002-10-09 Jeff Johnston <jjohnstn@redhat.com>
* mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
(-environment-cd): Change to use mi_cmd_env_cd,.
(-environment-pwd): Change to use mi_cmd_env_pwd.
(-environment-path): Change to use mi_cmd_env_path.
* mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
(mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
* mi-cmd-env.c: New file. Part of fix for PR gdb/741.
* gdbmi.texinfo (environment-cd): Update output and example.
(environment-pwd): Ditto.
(environment-dir): Update output, description, and examples.
(environment-path): Ditto.
gdb/testsuite/gdb.mi/ChangeLog:
2002-10-09 Jeff Johnston <jjohnstn@redhat.com>
* mi-basics.exp: Change tests for -environment-directory. Also add
tests for -environment-cd and -environment-pwd. Part of fix for
PR gdb/741.
Approved, comments?
-- Jeff J.
[-- Attachment #2: 741.patch --]
[-- Type: text/plain, Size: 10285 bytes --]
Index: mi/mi-cmd-env.c
===================================================================
RCS file: mi/mi-cmd-env.c
diff -N mi/mi-cmd-env.c
--- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
+++ mi/mi-cmd-env.c 9 Oct 2002 18:15:59 -0000
@@ -0,0 +1,320 @@
+/* MI Command Set - environment commands.
+ Copyright 2002 Free Software Foundation, Inc.
+ Contributed by Red Hat Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <string.h>
+#include <sys/stat.h>
+
+#include "defs.h"
+#include "target.h"
+#include "frame.h"
+#include "value.h"
+#include "mi-cmds.h"
+#include "mi-out.h"
+#include "ui-out.h"
+#include "symtab.h"
+#include "filenames.h"
+#include "environ.h"
+#include "command.h"
+#include "top.h"
+
+extern struct environ *inferior_environ;
+extern char *source_path;
+
+static void env_cli_command (const char *cli, char *args);
+static void env_mod_path (char *dirname, char **which_path);
+
+static const char path_var_name[] = "PATH";
+
+/* the following is copied from mi-main.c so for m1 and below we
+ can perform old behavior and use cli commands */
+static void
+env_execute_cli_command (const char *cli, char *args)
+{
+ if (cli != 0)
+ {
+ struct cleanup *old_cleanups;
+ char *run;
+ xasprintf (&run, cli, args);
+ old_cleanups = make_cleanup (xfree, run);
+ execute_command ( /*ui */ run, 0 /*from_tty */ );
+ do_cleanups (old_cleanups);
+ return;
+ }
+}
+
+
+/* Print working directory. */
+enum mi_cmd_result
+mi_cmd_env_pwd (char *command, char **argv, int argc)
+{
+ if (argc > 0)
+ error ("mi_cmd_env_pwd: No arguments required");
+
+ if (mi_version (uiout) < 2)
+ {
+ env_execute_cli_command ("pwd", NULL);
+ return MI_CMD_DONE;
+ }
+
+ /* otherwise mi level 2 or higher */
+
+ getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+ ui_out_field_string (uiout, "cwd", gdb_dirbuf);
+
+ return MI_CMD_DONE;
+}
+
+/* Change working directory. */
+enum mi_cmd_result
+mi_cmd_env_cd (char *command, char **argv, int argc)
+{
+ if (argc == 0 || argc > 1)
+ error ("mi_cmd_env_cd: Usage DIRECTORY");
+
+ env_execute_cli_command ("cd %s", argv[0]);
+
+ return MI_CMD_DONE;
+}
+
+static void
+env_mod_path (char *dirname, char **which_path)
+{
+ char *old = *which_path;
+ int prefix = 0;
+ char *name = dirname;
+ register char *p;
+ struct stat st;
+
+ if (dirname == 0 || dirname[0] == '\0')
+ return;
+
+ dirname = xstrdup (dirname);
+ make_cleanup (xfree, dirname);
+
+
+ p = dirname = name + strlen (name);
+
+ if (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ /* On MS-DOS and MS-Windows, h:\ is different from h: */
+ && !(p == name + 3 && name[1] == ':') /* "d:/" */
+#endif
+ && IS_DIR_SEPARATOR (p[-1]))
+ /* Sigh. "foo/" => "foo" */
+ --p;
+ *p = '\0';
+
+ while (p > name && p[-1] == '.')
+ {
+ if (p - name == 1)
+ {
+ /* "." => getwd (). */
+ name = current_directory;
+ goto append;
+ }
+ else if (p > name + 1 && IS_DIR_SEPARATOR (p[-2]))
+ {
+ if (p - name == 2)
+ {
+ /* "/." => "/". */
+ *--p = '\0';
+ goto append;
+ }
+ else
+ {
+ /* "...foo/." => "...foo". */
+ p -= 2;
+ *p = '\0';
+ continue;
+ }
+ }
+ else
+ break;
+ }
+
+ if (name[0] == '~')
+ name = tilde_expand (name);
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
+ name = concat (name, ".", NULL);
+#endif
+ else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
+ name = concat (current_directory, SLASH_STRING, name, NULL);
+ else
+ name = savestring (name, p - name);
+ make_cleanup (xfree, name);
+
+ /* Unless it's a variable, check existence. */
+ if (name[0] != '$')
+ {
+ /* These are warnings, not errors, since we don't want a
+ non-existent directory in a .gdbinit file to stop processing
+ of the .gdbinit file.
+
+ Whether they get added to the path is more debatable. Current
+ answer is yes, in case the user wants to go make the directory
+ or whatever. If the directory continues to not exist/not be
+ a directory/etc, then having them in the path should be
+ harmless. */
+ if (stat (name, &st) < 0)
+ {
+ int save_errno = errno;
+ fprintf_unfiltered (gdb_stderr, "Warning: ");
+ print_sys_errmsg (name, save_errno);
+ }
+ else if ((st.st_mode & S_IFMT) != S_IFDIR)
+ warning ("%s is not a directory.", name);
+ }
+
+ append:
+ {
+ register unsigned int len = strlen (name);
+
+ p = *which_path;
+ while (1)
+ {
+ /* FIXME: strncmp loses in interesting ways on MS-DOS and
+ MS-Windows because of case-insensitivity and two different
+ but functionally identical slash characters. We need a
+ special filesystem-dependent file-name comparison function.
+
+ Actually, even on Unix I would use realpath() or its work-
+ alike before comparing. Then all the code above which
+ removes excess slashes and dots could simply go away. */
+ if (!strncmp (p, name, len)
+ && (p[len] == '\0' || p[len] == DIRNAME_SEPARATOR))
+ {
+ /* Found it in the search path, remove old copy */
+ if (p > *which_path)
+ p--; /* Back over leading separator */
+ if (prefix > p - *which_path)
+ goto skip_dup; /* Same dir twice in one cmd */
+ strcpy (p, &p[len + 1]); /* Copy from next \0 or : */
+ }
+ p = strchr (p, DIRNAME_SEPARATOR);
+ if (p != 0)
+ ++p;
+ else
+ break;
+ }
+ if (p == 0)
+ {
+ char tinybuf[2];
+
+ tinybuf[0] = DIRNAME_SEPARATOR;
+ tinybuf[1] = '\0';
+
+ /* If we have already tacked on a name(s) in this command,
+ be sure they stay on the front as we tack on some more. */
+ if (prefix)
+ {
+ char *temp, c;
+
+ c = old[prefix];
+ old[prefix] = '\0';
+ temp = concat (old, tinybuf, name, NULL);
+ old[prefix] = c;
+ *which_path = concat (temp, "", &old[prefix], NULL);
+ prefix = strlen (temp);
+ xfree (temp);
+ }
+ else
+ {
+ *which_path = concat (name, (old[0] ? tinybuf : old), old, NULL);
+ prefix = strlen (name);
+ }
+ xfree (old);
+ old = *which_path;
+ }
+ }
+ skip_dup:;
+}
+
+/* Add one or more directories to start of executable search path */
+enum mi_cmd_result
+mi_cmd_env_path (char *command, char **argv, int argc)
+{
+ char *exec_path;
+ char *env;
+ int i;
+ if (argc == 0)
+ error ("mi_cmd_env_path: Usage [DIR1 DIR2 ... DIRn]");
+
+ if (mi_version (uiout) < 2)
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_execute_cli_command ("path %s", argv[i]);
+ return MI_CMD_DONE;
+ }
+
+ /* otherwise mi level 2 or higher */
+ dont_repeat ();
+ env = get_in_environ (inferior_environ, path_var_name);
+
+ /* Can be null if path is not set */
+ if (!env)
+ env = "";
+ exec_path = xstrdup (env);
+
+ for (i = argc - 1; i >= 0; --i)
+ env_mod_path (argv[i], &exec_path);
+
+ set_in_environ (inferior_environ, path_var_name, exec_path);
+ xfree (exec_path);
+ env = get_in_environ (inferior_environ, path_var_name);
+ ui_out_field_string (uiout, "path", env);
+
+ return MI_CMD_DONE;
+}
+
+/* Add zero or more directories to the front of the source path. */
+enum mi_cmd_result
+mi_cmd_env_dir (char *command, char **argv, int argc)
+{
+ int i;
+
+ dont_repeat ();
+
+ if (mi_version (uiout) < 2)
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_execute_cli_command ("dir %s", argv[i]);
+ return MI_CMD_DONE;
+ }
+
+ /* otherwise mi 2 or higher */
+ if (argc == 0)
+ {
+ /* no args implies reset to default path */
+ xfree (source_path);
+ init_source_path ();
+ }
+ else
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_mod_path (argv[i], &source_path);
+ init_last_source_visited ();
+ }
+
+ ui_out_field_string (uiout, "source-path", source_path);
+ forget_cached_source_info ();
+}
+
Index: mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.8
diff -u -r1.8 mi-cmds.c
--- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
+++ mi/mi-cmds.c 9 Oct 2002 18:15:59 -0000
@@ -56,10 +56,10 @@
{"display-enable", 0, 0},
{"display-insert", 0, 0},
{"display-list", 0, 0},
- {"environment-cd", "cd %s", 0},
- {"environment-directory", "dir %s", 0},
- {"environment-path", "path %s", 0},
- {"environment-pwd", "pwd", 0},
+ {"environment-cd", 0, 0, mi_cmd_env_cd},
+ {"environment-directory", 0, 0, mi_cmd_env_dir},
+ {"environment-path", 0, 0, mi_cmd_env_path},
+ {"environment-pwd", 0, 0, mi_cmd_env_pwd},
{"exec-abort", 0, 0},
{"exec-arguments", "set args %s", 0},
{"exec-continue", 0, mi_cmd_exec_continue},
Index: mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.5
diff -u -r1.5 mi-cmds.h
--- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
+++ mi/mi-cmds.h 9 Oct 2002 18:15:59 -0000
@@ -64,6 +64,10 @@
extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
+extern mi_cmd_argv_ftype mi_cmd_env_cd;
+extern mi_cmd_argv_ftype mi_cmd_env_dir;
+extern mi_cmd_argv_ftype mi_cmd_env_path;
+extern mi_cmd_argv_ftype mi_cmd_env_pwd;
extern mi_cmd_args_ftype mi_cmd_exec_continue;
extern mi_cmd_args_ftype mi_cmd_exec_finish;
extern mi_cmd_args_ftype mi_cmd_exec_next;
[-- Attachment #3: 741doc.patch --]
[-- Type: text/plain, Size: 2230 bytes --]
Index: mi/gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.29
diff -u -r1.29 gdbmi.texinfo
--- mi/gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
+++ mi/gdbmi.texinfo 9 Oct 2002 18:28:04 -0000
@@ -1665,10 +1665,12 @@
@subsubheading Synopsis
@example
- -environment-directory @var{pathdir}
+ -environment-directory [ @var{pathdir} ]+
@end example
-Add directory @var{pathdir} to beginning of search path for source files.
+Add directories @var{pathdir} to beginning of search path for source files.
+If no argument is given, reset search path to default. An empty string for
+@var{pathdir} is ignored so it may be used to display the current search path.
@subsubheading @value{GDBN} Command
@@ -1679,7 +1681,13 @@
@smallexample
(@value{GDBP})
-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
-^done
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory ""
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory
+^done,source-path="$cdir:$cwd"
(@value{GDBP})
@end smallexample
@@ -1690,10 +1698,12 @@
@subsubheading Synopsis
@example
- -environment-path ( @var{pathdir} )+
+ -environment-path [ @var{pathdir} ]+
@end example
Add directories @var{pathdir} to beginning of search path for object files.
+If no paths or an empty path is specified, the current object search path
+is displayed with no modification.
@subsubheading @value{GDBN} Command
@@ -1704,7 +1714,10 @@
@smallexample
(@value{GDBP})
-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
-^done
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
+(@value{GDBP})
+-environment-path
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
(@value{GDBP})
@end smallexample
@@ -1729,8 +1742,7 @@
@smallexample
(@value{GDBP})
-environment-pwd
-~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
-^done
+^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
(@value{GDBP})
@end smallexample
[-- Attachment #4: 741test.patch --]
[-- Type: text/plain, Size: 2085 bytes --]
Index: testsuite/gdb.mi/mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.6
diff -u -r1.6 mi-basics.exp
--- testsuite/gdb.mi/mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
+++ testsuite/gdb.mi/mi-basics.exp 9 Oct 2002 18:18:17 -0000
@@ -150,24 +150,50 @@
# Clear the search directories, then specify one to be searched
# Tests:
- # -environment-directory
# -environment-directory arg
+ # -environment-directory empty-string
+ # -environment-directory
#exp_internal 1
- mi_gdb_test "202-environment-directory" \
- "\\\^done" \
+ mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
+ "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
+ "environment-directory arg operation"
+
+ mi_gdb_test "203-environment-directory \"\"" \
+ "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
+ "environment-directory empty-string operation"
+
+ mi_gdb_test "204-environment-directory" \
+ "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
"environment-directory operation"
- mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
- "\\\^done" \
- "environment-directory arg operation"
#exp_internal 0
}
+proc test_cwd_specification {} {
+ global mi_gdb_prompt
+ global objdir
+ global subdir
+
+ # Change the working directory, then print the current working directory
+ # Tests:
+ # -environment-cd ${objdir}
+ # -environment-pwd
+
+ mi_gdb_test "205-environment-cd ${objdir}" \
+ "\\\^done" \
+ "environment-cd arg operation"
+
+ mi_gdb_test "206-environment-pwd" \
+ "\\\^done,cwd=\"${objdir}\"" \
+ "environment-pwd operation"
+}
+
if [test_mi_interpreter_selection] {
test_exec_and_symbol_mi_operatons
test_breakpoints_deletion
test_dir_specification
+ test_cwd_specification
}
mi_gdb_exit
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-10-09 12:50 Proposed patch for gdb/mi 741 J. Johnston
@ 2002-10-09 23:03 ` Eli Zaretskii
2002-10-22 9:08 ` Elena Zannoni
1 sibling, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2002-10-09 23:03 UTC (permalink / raw)
To: J. Johnston; +Cc: gdb-patches
On Wed, 9 Oct 2002, J. Johnston wrote:
> Eli, I have split the doc changes into 741doc.patch for your convenience. Let me know
> if there are any problems.
Thanks, approved. Please be sure to make a doc/ChangeLog entry when you
commit the changes.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-10-09 12:50 Proposed patch for gdb/mi 741 J. Johnston
2002-10-09 23:03 ` Eli Zaretskii
@ 2002-10-22 9:08 ` Elena Zannoni
2002-11-07 14:10 ` J. Johnston
1 sibling, 1 reply; 17+ messages in thread
From: Elena Zannoni @ 2002-10-22 9:08 UTC (permalink / raw)
To: J. Johnston; +Cc: gdb-patches
J. Johnston writes:
> The following solves a number of problems with the mi -environment commands.
> For starters, each command now has an mi cmd wrapper so arguments may use the
> syntax of adding double-quotes to handle extraneous characters such as spaces.
>
> The -environment-pwd command now lists the output in mi syntax:
>
> e.g.
> -environment-pwd
> ^done,cwd="...."
>
> The -environment-directory command has been changed to output in mi format.
> It also has been changed to allow for no arguments being passed.
> If no arguments are passed, it behaves like the gdb dir command and resets the
> source search path to the default, however, no confirmation query is performed. If an empty
> string "" is passed, it is ignored so this can be used to display the current
> search path without modifying it.
>
> e.g.
> -environment-directory /usr/bin /usr/local/bin
> ^done,source-path="/usr/bin:/usr/local/bin:$cdir:$cwd"
>
> The -environment-path command has been changed to output in mi format.
> It also has been changed to allow for no arguments being passed. When
> no arguments are passed, the current object search path is displayed.
>
> e.g.
> -environment-path
> ^done,path="....."
>
> For mi1 or below, the previous behavior is preserved by rerouting the commands
> to their old cli counterparts.
Hmmm, I think the testsuite changes are ok. Also the addition of the
new file is fine. However I don't think we should be duplicating the
mod_path() code. Would it be possible to maybe split mod_path() in 2
or more functions, and have MI call one of them?
I mean
mod_path()
{
do_cli_specific_stuff;
call add_path(args1);
....
}
mi_env_path()
{
do_mi_specific_stuff;
call add_path(args2);
.....
}
similarly for other code that may have been duplicated.
Thanks
Elena
>
> Eli, I have split the doc changes into 741doc.patch for your convenience. Let me know
> if there are any problems.
>
> gdb/mi/ChangeLog:
>
> 2002-10-09 Jeff Johnston <jjohnstn@redhat.com>
>
> * mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
> (-environment-cd): Change to use mi_cmd_env_cd,.
> (-environment-pwd): Change to use mi_cmd_env_pwd.
> (-environment-path): Change to use mi_cmd_env_path.
> * mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
> (mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
> * mi-cmd-env.c: New file. Part of fix for PR gdb/741.
> * gdbmi.texinfo (environment-cd): Update output and example.
> (environment-pwd): Ditto.
> (environment-dir): Update output, description, and examples.
> (environment-path): Ditto.
>
> gdb/testsuite/gdb.mi/ChangeLog:
>
> 2002-10-09 Jeff Johnston <jjohnstn@redhat.com>
>
> * mi-basics.exp: Change tests for -environment-directory. Also add
> tests for -environment-cd and -environment-pwd. Part of fix for
> PR gdb/741.
>
> Approved, comments?
>
> -- Jeff J.Index: mi/mi-cmd-env.c
> ===================================================================
> RCS file: mi/mi-cmd-env.c
> diff -N mi/mi-cmd-env.c
> --- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
> +++ mi/mi-cmd-env.c 9 Oct 2002 18:15:59 -0000
> @@ -0,0 +1,320 @@
> +/* MI Command Set - environment commands.
> + Copyright 2002 Free Software Foundation, Inc.
> + Contributed by Red Hat Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place - Suite 330,
> + Boston, MA 02111-1307, USA. */
> +
> +#include <string.h>
> +#include <sys/stat.h>
> +
> +#include "defs.h"
> +#include "target.h"
> +#include "frame.h"
> +#include "value.h"
> +#include "mi-cmds.h"
> +#include "mi-out.h"
> +#include "ui-out.h"
> +#include "symtab.h"
> +#include "filenames.h"
> +#include "environ.h"
> +#include "command.h"
> +#include "top.h"
> +
> +extern struct environ *inferior_environ;
> +extern char *source_path;
> +
> +static void env_cli_command (const char *cli, char *args);
> +static void env_mod_path (char *dirname, char **which_path);
> +
> +static const char path_var_name[] = "PATH";
> +
> +/* the following is copied from mi-main.c so for m1 and below we
> + can perform old behavior and use cli commands */
> +static void
> +env_execute_cli_command (const char *cli, char *args)
> +{
> + if (cli != 0)
> + {
> + struct cleanup *old_cleanups;
> + char *run;
> + xasprintf (&run, cli, args);
> + old_cleanups = make_cleanup (xfree, run);
> + execute_command ( /*ui */ run, 0 /*from_tty */ );
> + do_cleanups (old_cleanups);
> + return;
> + }
> +}
> +
> +
> +/* Print working directory. */
> +enum mi_cmd_result
> +mi_cmd_env_pwd (char *command, char **argv, int argc)
> +{
> + if (argc > 0)
> + error ("mi_cmd_env_pwd: No arguments required");
> +
> + if (mi_version (uiout) < 2)
> + {
> + env_execute_cli_command ("pwd", NULL);
> + return MI_CMD_DONE;
> + }
> +
> + /* otherwise mi level 2 or higher */
> +
> + getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
> + ui_out_field_string (uiout, "cwd", gdb_dirbuf);
> +
> + return MI_CMD_DONE;
> +}
> +
> +/* Change working directory. */
> +enum mi_cmd_result
> +mi_cmd_env_cd (char *command, char **argv, int argc)
> +{
> + if (argc == 0 || argc > 1)
> + error ("mi_cmd_env_cd: Usage DIRECTORY");
> +
> + env_execute_cli_command ("cd %s", argv[0]);
> +
> + return MI_CMD_DONE;
> +}
> +
> +static void
> +env_mod_path (char *dirname, char **which_path)
> +{
> + char *old = *which_path;
> + int prefix = 0;
> + char *name = dirname;
> + register char *p;
> + struct stat st;
> +
> + if (dirname == 0 || dirname[0] == '\0')
> + return;
> +
> + dirname = xstrdup (dirname);
> + make_cleanup (xfree, dirname);
> +
> +
> + p = dirname = name + strlen (name);
> +
> + if (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
> +#ifdef HAVE_DOS_BASED_FILE_SYSTEM
> + /* On MS-DOS and MS-Windows, h:\ is different from h: */
> + && !(p == name + 3 && name[1] == ':') /* "d:/" */
> +#endif
> + && IS_DIR_SEPARATOR (p[-1]))
> + /* Sigh. "foo/" => "foo" */
> + --p;
> + *p = '\0';
> +
> + while (p > name && p[-1] == '.')
> + {
> + if (p - name == 1)
> + {
> + /* "." => getwd (). */
> + name = current_directory;
> + goto append;
> + }
> + else if (p > name + 1 && IS_DIR_SEPARATOR (p[-2]))
> + {
> + if (p - name == 2)
> + {
> + /* "/." => "/". */
> + *--p = '\0';
> + goto append;
> + }
> + else
> + {
> + /* "...foo/." => "...foo". */
> + p -= 2;
> + *p = '\0';
> + continue;
> + }
> + }
> + else
> + break;
> + }
> +
> + if (name[0] == '~')
> + name = tilde_expand (name);
> +#ifdef HAVE_DOS_BASED_FILE_SYSTEM
> + else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
> + name = concat (name, ".", NULL);
> +#endif
> + else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
> + name = concat (current_directory, SLASH_STRING, name, NULL);
> + else
> + name = savestring (name, p - name);
> + make_cleanup (xfree, name);
> +
> + /* Unless it's a variable, check existence. */
> + if (name[0] != '$')
> + {
> + /* These are warnings, not errors, since we don't want a
> + non-existent directory in a .gdbinit file to stop processing
> + of the .gdbinit file.
> +
> + Whether they get added to the path is more debatable. Current
> + answer is yes, in case the user wants to go make the directory
> + or whatever. If the directory continues to not exist/not be
> + a directory/etc, then having them in the path should be
> + harmless. */
> + if (stat (name, &st) < 0)
> + {
> + int save_errno = errno;
> + fprintf_unfiltered (gdb_stderr, "Warning: ");
> + print_sys_errmsg (name, save_errno);
> + }
> + else if ((st.st_mode & S_IFMT) != S_IFDIR)
> + warning ("%s is not a directory.", name);
> + }
> +
> + append:
> + {
> + register unsigned int len = strlen (name);
> +
> + p = *which_path;
> + while (1)
> + {
> + /* FIXME: strncmp loses in interesting ways on MS-DOS and
> + MS-Windows because of case-insensitivity and two different
> + but functionally identical slash characters. We need a
> + special filesystem-dependent file-name comparison function.
> +
> + Actually, even on Unix I would use realpath() or its work-
> + alike before comparing. Then all the code above which
> + removes excess slashes and dots could simply go away. */
> + if (!strncmp (p, name, len)
> + && (p[len] == '\0' || p[len] == DIRNAME_SEPARATOR))
> + {
> + /* Found it in the search path, remove old copy */
> + if (p > *which_path)
> + p--; /* Back over leading separator */
> + if (prefix > p - *which_path)
> + goto skip_dup; /* Same dir twice in one cmd */
> + strcpy (p, &p[len + 1]); /* Copy from next \0 or : */
> + }
> + p = strchr (p, DIRNAME_SEPARATOR);
> + if (p != 0)
> + ++p;
> + else
> + break;
> + }
> + if (p == 0)
> + {
> + char tinybuf[2];
> +
> + tinybuf[0] = DIRNAME_SEPARATOR;
> + tinybuf[1] = '\0';
> +
> + /* If we have already tacked on a name(s) in this command,
> + be sure they stay on the front as we tack on some more. */
> + if (prefix)
> + {
> + char *temp, c;
> +
> + c = old[prefix];
> + old[prefix] = '\0';
> + temp = concat (old, tinybuf, name, NULL);
> + old[prefix] = c;
> + *which_path = concat (temp, "", &old[prefix], NULL);
> + prefix = strlen (temp);
> + xfree (temp);
> + }
> + else
> + {
> + *which_path = concat (name, (old[0] ? tinybuf : old), old, NULL);
> + prefix = strlen (name);
> + }
> + xfree (old);
> + old = *which_path;
> + }
> + }
> + skip_dup:;
> +}
> +
> +/* Add one or more directories to start of executable search path */
> +enum mi_cmd_result
> +mi_cmd_env_path (char *command, char **argv, int argc)
> +{
> + char *exec_path;
> + char *env;
> + int i;
> + if (argc == 0)
> + error ("mi_cmd_env_path: Usage [DIR1 DIR2 ... DIRn]");
> +
> + if (mi_version (uiout) < 2)
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_execute_cli_command ("path %s", argv[i]);
> + return MI_CMD_DONE;
> + }
> +
> + /* otherwise mi level 2 or higher */
> + dont_repeat ();
> + env = get_in_environ (inferior_environ, path_var_name);
> +
> + /* Can be null if path is not set */
> + if (!env)
> + env = "";
> + exec_path = xstrdup (env);
> +
> + for (i = argc - 1; i >= 0; --i)
> + env_mod_path (argv[i], &exec_path);
> +
> + set_in_environ (inferior_environ, path_var_name, exec_path);
> + xfree (exec_path);
> + env = get_in_environ (inferior_environ, path_var_name);
> + ui_out_field_string (uiout, "path", env);
> +
> + return MI_CMD_DONE;
> +}
> +
> +/* Add zero or more directories to the front of the source path. */
> +enum mi_cmd_result
> +mi_cmd_env_dir (char *command, char **argv, int argc)
> +{
> + int i;
> +
> + dont_repeat ();
> +
> + if (mi_version (uiout) < 2)
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_execute_cli_command ("dir %s", argv[i]);
> + return MI_CMD_DONE;
> + }
> +
> + /* otherwise mi 2 or higher */
> + if (argc == 0)
> + {
> + /* no args implies reset to default path */
> + xfree (source_path);
> + init_source_path ();
> + }
> + else
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_mod_path (argv[i], &source_path);
> + init_last_source_visited ();
> + }
> +
> + ui_out_field_string (uiout, "source-path", source_path);
> + forget_cached_source_info ();
> +}
> +
> Index: mi/mi-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> retrieving revision 1.8
> diff -u -r1.8 mi-cmds.c
> --- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
> +++ mi/mi-cmds.c 9 Oct 2002 18:15:59 -0000
> @@ -56,10 +56,10 @@
> {"display-enable", 0, 0},
> {"display-insert", 0, 0},
> {"display-list", 0, 0},
> - {"environment-cd", "cd %s", 0},
> - {"environment-directory", "dir %s", 0},
> - {"environment-path", "path %s", 0},
> - {"environment-pwd", "pwd", 0},
> + {"environment-cd", 0, 0, mi_cmd_env_cd},
> + {"environment-directory", 0, 0, mi_cmd_env_dir},
> + {"environment-path", 0, 0, mi_cmd_env_path},
> + {"environment-pwd", 0, 0, mi_cmd_env_pwd},
> {"exec-abort", 0, 0},
> {"exec-arguments", "set args %s", 0},
> {"exec-continue", 0, mi_cmd_exec_continue},
> Index: mi/mi-cmds.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> retrieving revision 1.5
> diff -u -r1.5 mi-cmds.h
> --- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
> +++ mi/mi-cmds.h 9 Oct 2002 18:15:59 -0000
> @@ -64,6 +64,10 @@
> extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
> extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
> extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
> +extern mi_cmd_argv_ftype mi_cmd_env_cd;
> +extern mi_cmd_argv_ftype mi_cmd_env_dir;
> +extern mi_cmd_argv_ftype mi_cmd_env_path;
> +extern mi_cmd_argv_ftype mi_cmd_env_pwd;
> extern mi_cmd_args_ftype mi_cmd_exec_continue;
> extern mi_cmd_args_ftype mi_cmd_exec_finish;
> extern mi_cmd_args_ftype mi_cmd_exec_next;
> Index: mi/gdbmi.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
> retrieving revision 1.29
> diff -u -r1.29 gdbmi.texinfo
> --- mi/gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
> +++ mi/gdbmi.texinfo 9 Oct 2002 18:28:04 -0000
> @@ -1665,10 +1665,12 @@
> @subsubheading Synopsis
>
> @example
> - -environment-directory @var{pathdir}
> + -environment-directory [ @var{pathdir} ]+
> @end example
>
> -Add directory @var{pathdir} to beginning of search path for source files.
> +Add directories @var{pathdir} to beginning of search path for source files.
> +If no argument is given, reset search path to default. An empty string for
> +@var{pathdir} is ignored so it may be used to display the current search path.
>
> @subsubheading @value{GDBN} Command
>
> @@ -1679,7 +1681,13 @@
> @smallexample
> (@value{GDBP})
> -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
> -^done
> +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory ""
> +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory
> +^done,source-path="$cdir:$cwd"
> (@value{GDBP})
> @end smallexample
>
> @@ -1690,10 +1698,12 @@
> @subsubheading Synopsis
>
> @example
> - -environment-path ( @var{pathdir} )+
> + -environment-path [ @var{pathdir} ]+
> @end example
>
> Add directories @var{pathdir} to beginning of search path for object files.
> +If no paths or an empty path is specified, the current object search path
> +is displayed with no modification.
>
> @subsubheading @value{GDBN} Command
>
> @@ -1704,7 +1714,10 @@
> @smallexample
> (@value{GDBP})
> -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
> -^done
> +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> +(@value{GDBP})
> +-environment-path
> +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> (@value{GDBP})
> @end smallexample
>
> @@ -1729,8 +1742,7 @@
> @smallexample
> (@value{GDBP})
> -environment-pwd
> -~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
> -^done
> +^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
> (@value{GDBP})
> @end smallexample
>
> Index: testsuite/gdb.mi/mi-basics.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
> retrieving revision 1.6
> diff -u -r1.6 mi-basics.exp
> --- testsuite/gdb.mi/mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
> +++ testsuite/gdb.mi/mi-basics.exp 9 Oct 2002 18:18:17 -0000
> @@ -150,24 +150,50 @@
>
> # Clear the search directories, then specify one to be searched
> # Tests:
> - # -environment-directory
> # -environment-directory arg
> + # -environment-directory empty-string
> + # -environment-directory
>
> #exp_internal 1
> - mi_gdb_test "202-environment-directory" \
> - "\\\^done" \
> + mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
> + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> + "environment-directory arg operation"
> +
> + mi_gdb_test "203-environment-directory \"\"" \
> + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> + "environment-directory empty-string operation"
> +
> + mi_gdb_test "204-environment-directory" \
> + "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
> "environment-directory operation"
>
> - mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
> - "\\\^done" \
> - "environment-directory arg operation"
> #exp_internal 0
> }
>
> +proc test_cwd_specification {} {
> + global mi_gdb_prompt
> + global objdir
> + global subdir
> +
> + # Change the working directory, then print the current working directory
> + # Tests:
> + # -environment-cd ${objdir}
> + # -environment-pwd
> +
> + mi_gdb_test "205-environment-cd ${objdir}" \
> + "\\\^done" \
> + "environment-cd arg operation"
> +
> + mi_gdb_test "206-environment-pwd" \
> + "\\\^done,cwd=\"${objdir}\"" \
> + "environment-pwd operation"
> +}
> +
> if [test_mi_interpreter_selection] {
> test_exec_and_symbol_mi_operatons
> test_breakpoints_deletion
> test_dir_specification
> + test_cwd_specification
> }
>
> mi_gdb_exit
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-10-22 9:08 ` Elena Zannoni
@ 2002-11-07 14:10 ` J. Johnston
2002-11-07 16:00 ` Elena Zannoni
2002-11-09 13:28 ` Eli Zaretskii
0 siblings, 2 replies; 17+ messages in thread
From: J. Johnston @ 2002-11-07 14:10 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 3931 bytes --]
Elena Zannoni wrote:
>
> J. Johnston writes:
> > The following solves a number of problems with the mi -environment commands.
> > For starters, each command now has an mi cmd wrapper so arguments may use the
> > syntax of adding double-quotes to handle extraneous characters such as spaces.
> >
> > The -environment-pwd command now lists the output in mi syntax:
> >
> > e.g.
> > -environment-pwd
> > ^done,cwd="...."
> >
> > The -environment-directory command has been changed to output in mi format.
> > It also has been changed to allow for no arguments being passed.
> > If no arguments are passed, it behaves like the gdb dir command and resets the
> > source search path to the default, however, no confirmation query is performed. If an empty
> > string "" is passed, it is ignored so this can be used to display the current
> > search path without modifying it.
> >
> > e.g.
> > -environment-directory /usr/bin /usr/local/bin
> > ^done,source-path="/usr/bin:/usr/local/bin:$cdir:$cwd"
> >
> > The -environment-path command has been changed to output in mi format.
> > It also has been changed to allow for no arguments being passed. When
> > no arguments are passed, the current object search path is displayed.
> >
> > e.g.
> > -environment-path
> > ^done,path="....."
> >
> > For mi1 or below, the previous behavior is preserved by rerouting the commands
> > to their old cli counterparts.
>
> Hmmm, I think the testsuite changes are ok. Also the addition of the
> new file is fine. However I don't think we should be duplicating the
> mod_path() code. Would it be possible to maybe split mod_path() in 2
> or more functions, and have MI call one of them?
> I mean
>
> mod_path()
> {
> do_cli_specific_stuff;
> call add_path(args1);
> ....
> }
>
> mi_env_path()
> {
> do_mi_specific_stuff;
> call add_path(args2);
> .....
> }
>
> similarly for other code that may have been duplicated.
>
> Thanks
> Elena
I have taken your advice and have added a new interface: add_path which takes
an additional argument. The mod_path() routine calls it one way, the mi code
calls it another. Of the other code I copied, there is no value add in trying
to make it common as I copied a few lines here and there.
I found I had to modify the tilde_expand() prototype in defs.h to get my
build working. I have a combined source tree and there was a conflict with
tilde.h found in the readline directory. The defs.h prototype was not
declaring the argument as const.
Ok to commit?
-- Jeff J.
gdb/ChangeLog:
2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
* defs.h (init_last_source_visited): New prototype.
(add_path): Ditto.
(tilde_expand): Change prototype to const char * to match readline.h.
* source.c (add_path): New function that adds to a specified path.
(mod_path): Change to call add_path.
(init_last_source_visited): New function to allow interfaces to
initialize static variable: last_source_visited.
gdb/mi/ChangeLog:
2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
* mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
(-environment-cd): Change to use mi_cmd_env_cd,.
(-environment-pwd): Change to use mi_cmd_env_pwd.
(-environment-path): Change to use mi_cmd_env_path.
* mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
(mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
* mi-cmd-env.c: New file. Part of fix for PR gdb/741.
* gdbmi.texinfo (environment-cd): Update output and example.
(environment-pwd): Ditto.
(environment-dir): Update output, description, and examples.
(environment-path): Ditto.
gdb/testsuite/gdb.mi/ChangeLog:
2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
* mi-basics.exp: Change tests for -environment-directory. Also add
tests for -environment-cd and -environment-pwd. Part of fix for
PR gdb/741.
[-- Attachment #2: 741.patch --]
[-- Type: text/plain, Size: 9073 bytes --]
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.102
diff -u -r1.102 defs.h
--- defs.h 15 Oct 2002 02:16:51 -0000 1.102
+++ defs.h 7 Nov 2002 21:47:03 -0000
@@ -572,10 +572,14 @@
extern void mod_path (char *, char **);
+extern void add_path (char *, char **, int);
+
extern void directory_command (char *, int);
extern void init_source_path (void);
+extern void init_last_source_visited (void);
+
extern char *symtab_to_filename (struct symtab *);
/* From exec.c */
@@ -616,7 +620,7 @@
/* From readline (but not in any readline .h files). */
-extern char *tilde_expand (char *);
+extern char *tilde_expand (const char *);
/* Control types for commands */
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.36
diff -u -r1.36 source.c
--- source.c 24 Oct 2002 21:02:53 -0000 1.36
+++ source.c 7 Nov 2002 21:47:03 -0000
@@ -357,6 +357,12 @@
forget_cached_source_info ();
}
+void
+init_last_source_visited (void)
+{
+ last_source_visited = NULL;
+}
+
/* Add zero or more directories to the front of the source path. */
void
@@ -387,6 +393,18 @@
void
mod_path (char *dirname, char **which_path)
{
+ add_path (dirname, which_path, 1);
+}
+
+/* Workhorse of mod_path. Takes an extra argument to determine
+ if dirname should be parsed for separators that indicate multiple
+ directories. This allows for interfaces that pre-parse the dirname
+ and allow specification of traditional separator characters such
+ as space or tab. */
+
+void
+add_path (char *dirname, char **which_path, int parse_separators)
+{
char *old = *which_path;
int prefix = 0;
@@ -403,9 +421,16 @@
struct stat st;
{
- char *separator = strchr (name, DIRNAME_SEPARATOR);
- char *space = strchr (name, ' ');
- char *tab = strchr (name, '\t');
+ char *separator = NULL;
+ char *space = NULL;
+ char *tab = NULL;
+
+ if (parse_separators)
+ {
+ separator = strchr (name, DIRNAME_SEPARATOR);
+ space = strchr (name, ' ');
+ tab = strchr (name, '\t');
+ }
if (separator == 0 && space == 0 && tab == 0)
p = dirname = name + strlen (name);
@@ -536,7 +561,8 @@
tinybuf[0] = DIRNAME_SEPARATOR;
tinybuf[1] = '\0';
- /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
+ /* If we have already tacked on a name(s) in this command, be sure they stay
+ on the front as we tack on some more. */
if (prefix)
{
char *temp, c;
Index: mi/mi-cmd-env.c
===================================================================
RCS file: mi/mi-cmd-env.c
diff -N mi/mi-cmd-env.c
--- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
+++ mi/mi-cmd-env.c 7 Nov 2002 21:47:04 -0000
@@ -0,0 +1,174 @@
+/* MI Command Set - environment commands.
+ Copyright 2002 Free Software Foundation, Inc.
+ Contributed by Red Hat Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <string.h>
+#include <sys/stat.h>
+
+#include "defs.h"
+#include "target.h"
+#include "frame.h"
+#include "value.h"
+#include "mi-cmds.h"
+#include "mi-out.h"
+#include "ui-out.h"
+#include "symtab.h"
+#include "filenames.h"
+#include "environ.h"
+#include "command.h"
+#include "top.h"
+
+extern struct environ *inferior_environ;
+extern char *source_path;
+
+static void env_cli_command (const char *cli, char *args);
+static void env_mod_path (char *dirname, char **which_path);
+
+static const char path_var_name[] = "PATH";
+
+/* the following is copied from mi-main.c so for m1 and below we
+ can perform old behavior and use cli commands */
+static void
+env_execute_cli_command (const char *cli, char *args)
+{
+ if (cli != 0)
+ {
+ struct cleanup *old_cleanups;
+ char *run;
+ xasprintf (&run, cli, args);
+ old_cleanups = make_cleanup (xfree, run);
+ execute_command ( /*ui */ run, 0 /*from_tty */ );
+ do_cleanups (old_cleanups);
+ return;
+ }
+}
+
+
+/* Print working directory. */
+enum mi_cmd_result
+mi_cmd_env_pwd (char *command, char **argv, int argc)
+{
+ if (argc > 0)
+ error ("mi_cmd_env_pwd: No arguments required");
+
+ if (mi_version (uiout) < 2)
+ {
+ env_execute_cli_command ("pwd", NULL);
+ return MI_CMD_DONE;
+ }
+
+ /* otherwise mi level 2 or higher */
+
+ getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+ ui_out_field_string (uiout, "cwd", gdb_dirbuf);
+
+ return MI_CMD_DONE;
+}
+
+/* Change working directory. */
+enum mi_cmd_result
+mi_cmd_env_cd (char *command, char **argv, int argc)
+{
+ if (argc == 0 || argc > 1)
+ error ("mi_cmd_env_cd: Usage DIRECTORY");
+
+ env_execute_cli_command ("cd %s", argv[0]);
+
+ return MI_CMD_DONE;
+}
+
+static void
+env_mod_path (char *dirname, char **which_path)
+{
+ if (dirname == 0 || dirname[0] == '\0')
+ return;
+
+ /* call add_path with last arg 0 to indicate not to parse for separator chars */
+ add_path (dirname, which_path, 0);
+}
+
+/* Add one or more directories to start of executable search path */
+enum mi_cmd_result
+mi_cmd_env_path (char *command, char **argv, int argc)
+{
+ char *exec_path;
+ char *env;
+ int i;
+
+ if (mi_version (uiout) < 2)
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_execute_cli_command ("path %s", argv[i]);
+ return MI_CMD_DONE;
+ }
+
+ /* otherwise mi level 2 or higher */
+ dont_repeat ();
+ env = get_in_environ (inferior_environ, path_var_name);
+
+ /* Can be null if path is not set */
+ if (!env)
+ env = "";
+ exec_path = xstrdup (env);
+
+ for (i = argc - 1; i >= 0; --i)
+ env_mod_path (argv[i], &exec_path);
+
+ set_in_environ (inferior_environ, path_var_name, exec_path);
+ xfree (exec_path);
+ env = get_in_environ (inferior_environ, path_var_name);
+ ui_out_field_string (uiout, "path", env);
+
+ return MI_CMD_DONE;
+}
+
+/* Add zero or more directories to the front of the source path. */
+enum mi_cmd_result
+mi_cmd_env_dir (char *command, char **argv, int argc)
+{
+ int i;
+
+ dont_repeat ();
+
+ if (mi_version (uiout) < 2)
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_execute_cli_command ("dir %s", argv[i]);
+ return MI_CMD_DONE;
+ }
+
+ /* otherwise mi 2 or higher */
+ if (argc == 0)
+ {
+ /* no args implies reset to default path */
+ xfree (source_path);
+ init_source_path ();
+ }
+ else
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_mod_path (argv[i], &source_path);
+ init_last_source_visited ();
+ }
+
+ ui_out_field_string (uiout, "source-path", source_path);
+ forget_cached_source_info ();
+}
+
Index: mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.8
diff -u -r1.8 mi-cmds.c
--- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
+++ mi/mi-cmds.c 7 Nov 2002 21:47:04 -0000
@@ -56,10 +56,10 @@
{"display-enable", 0, 0},
{"display-insert", 0, 0},
{"display-list", 0, 0},
- {"environment-cd", "cd %s", 0},
- {"environment-directory", "dir %s", 0},
- {"environment-path", "path %s", 0},
- {"environment-pwd", "pwd", 0},
+ {"environment-cd", 0, 0, mi_cmd_env_cd},
+ {"environment-directory", 0, 0, mi_cmd_env_dir},
+ {"environment-path", 0, 0, mi_cmd_env_path},
+ {"environment-pwd", 0, 0, mi_cmd_env_pwd},
{"exec-abort", 0, 0},
{"exec-arguments", "set args %s", 0},
{"exec-continue", 0, mi_cmd_exec_continue},
Index: mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.5
diff -u -r1.5 mi-cmds.h
--- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
+++ mi/mi-cmds.h 7 Nov 2002 21:47:04 -0000
@@ -64,6 +64,10 @@
extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
+extern mi_cmd_argv_ftype mi_cmd_env_cd;
+extern mi_cmd_argv_ftype mi_cmd_env_dir;
+extern mi_cmd_argv_ftype mi_cmd_env_path;
+extern mi_cmd_argv_ftype mi_cmd_env_pwd;
extern mi_cmd_args_ftype mi_cmd_exec_continue;
extern mi_cmd_args_ftype mi_cmd_exec_finish;
extern mi_cmd_args_ftype mi_cmd_exec_next;
[-- Attachment #3: 741.doc.patch --]
[-- Type: text/plain, Size: 2221 bytes --]
Index: gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.29
diff -u -r1.29 gdbmi.texinfo
--- gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
+++ gdbmi.texinfo 7 Nov 2002 21:55:40 -0000
@@ -1665,10 +1665,12 @@
@subsubheading Synopsis
@example
- -environment-directory @var{pathdir}
+ -environment-directory [ @var{pathdir} ]+
@end example
-Add directory @var{pathdir} to beginning of search path for source files.
+Add directories @var{pathdir} to beginning of search path for source files.
+If no argument is given, reset search path to default. An empty string for
+@var{pathdir} is ignored so it may be used to display the current search path.
@subsubheading @value{GDBN} Command
@@ -1679,7 +1681,13 @@
@smallexample
(@value{GDBP})
-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
-^done
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory ""
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory
+^done,source-path="$cdir:$cwd"
(@value{GDBP})
@end smallexample
@@ -1690,10 +1698,12 @@
@subsubheading Synopsis
@example
- -environment-path ( @var{pathdir} )+
+ -environment-path [ @var{pathdir} ]+
@end example
Add directories @var{pathdir} to beginning of search path for object files.
+If no paths or an empty path is specified, the current object search path
+is displayed with no modification.
@subsubheading @value{GDBN} Command
@@ -1704,7 +1714,10 @@
@smallexample
(@value{GDBP})
-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
-^done
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
+(@value{GDBP})
+-environment-path
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
(@value{GDBP})
@end smallexample
@@ -1729,8 +1742,7 @@
@smallexample
(@value{GDBP})
-environment-pwd
-~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
-^done
+^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
(@value{GDBP})
@end smallexample
[-- Attachment #4: 741.test.patch --]
[-- Type: text/plain, Size: 2034 bytes --]
Index: mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.6
diff -u -r1.6 mi-basics.exp
--- mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
+++ mi-basics.exp 7 Nov 2002 21:56:00 -0000
@@ -150,24 +150,50 @@
# Clear the search directories, then specify one to be searched
# Tests:
- # -environment-directory
# -environment-directory arg
+ # -environment-directory empty-string
+ # -environment-directory
#exp_internal 1
- mi_gdb_test "202-environment-directory" \
- "\\\^done" \
+ mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
+ "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
+ "environment-directory arg operation"
+
+ mi_gdb_test "203-environment-directory \"\"" \
+ "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
+ "environment-directory empty-string operation"
+
+ mi_gdb_test "204-environment-directory" \
+ "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
"environment-directory operation"
- mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
- "\\\^done" \
- "environment-directory arg operation"
#exp_internal 0
}
+proc test_cwd_specification {} {
+ global mi_gdb_prompt
+ global objdir
+ global subdir
+
+ # Change the working directory, then print the current working directory
+ # Tests:
+ # -environment-cd ${objdir}
+ # -environment-pwd
+
+ mi_gdb_test "205-environment-cd ${objdir}" \
+ "\\\^done" \
+ "environment-cd arg operation"
+
+ mi_gdb_test "206-environment-pwd" \
+ "\\\^done,cwd=\"${objdir}\"" \
+ "environment-pwd operation"
+}
+
if [test_mi_interpreter_selection] {
test_exec_and_symbol_mi_operatons
test_breakpoints_deletion
test_dir_specification
+ test_cwd_specification
}
mi_gdb_exit
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-11-07 14:10 ` J. Johnston
@ 2002-11-07 16:00 ` Elena Zannoni
2002-11-08 15:53 ` J. Johnston
2002-11-09 13:28 ` Eli Zaretskii
1 sibling, 1 reply; 17+ messages in thread
From: Elena Zannoni @ 2002-11-07 16:00 UTC (permalink / raw)
To: J. Johnston; +Cc: Elena Zannoni, gdb-patches
J. Johnston writes:
> Elena Zannoni wrote:
> >
> > J. Johnston writes:
> > > The following solves a number of problems with the mi -environment commands.
> > > For starters, each command now has an mi cmd wrapper so arguments may use the
> > > syntax of adding double-quotes to handle extraneous characters such as spaces.
> > >
> > > The -environment-pwd command now lists the output in mi syntax:
> > >
> > > e.g.
> > > -environment-pwd
> > > ^done,cwd="...."
> > >
> > > The -environment-directory command has been changed to output in mi format.
> > > It also has been changed to allow for no arguments being passed.
> > > If no arguments are passed, it behaves like the gdb dir command and resets the
> > > source search path to the default, however, no confirmation query is performed. If an empty
> > > string "" is passed, it is ignored so this can be used to display the current
> > > search path without modifying it.
> > >
> > > e.g.
> > > -environment-directory /usr/bin /usr/local/bin
> > > ^done,source-path="/usr/bin:/usr/local/bin:$cdir:$cwd"
> > >
> > > The -environment-path command has been changed to output in mi format.
> > > It also has been changed to allow for no arguments being passed. When
> > > no arguments are passed, the current object search path is displayed.
> > >
> > > e.g.
> > > -environment-path
> > > ^done,path="....."
> > >
> > > For mi1 or below, the previous behavior is preserved by rerouting the commands
> > > to their old cli counterparts.
> >
> > Hmmm, I think the testsuite changes are ok. Also the addition of the
> > new file is fine. However I don't think we should be duplicating the
> > mod_path() code. Would it be possible to maybe split mod_path() in 2
> > or more functions, and have MI call one of them?
> > I mean
> >
> > mod_path()
> > {
> > do_cli_specific_stuff;
> > call add_path(args1);
> > ....
> > }
> >
> > mi_env_path()
> > {
> > do_mi_specific_stuff;
> > call add_path(args2);
> > .....
> > }
> >
> > similarly for other code that may have been duplicated.
> >
> > Thanks
> > Elena
>
> I have taken your advice and have added a new interface: add_path which takes
> an additional argument. The mod_path() routine calls it one way, the mi code
> calls it another. Of the other code I copied, there is no value add in trying
> to make it common as I copied a few lines here and there.
>
> I found I had to modify the tilde_expand() prototype in defs.h to get my
> build working. I have a combined source tree and there was a conflict with
> tilde.h found in the readline directory. The defs.h prototype was not
> declaring the argument as const.
>
Ah, right. readline has changed tilde_expand. You must have a newer
version of realine installed? We cannot make that change yet, because
we need to build with the readline in our source tree, unfortunately.
But the upgrade of readline is coming soon. (which reminds me...)
I don't like one minor thing. The inconsistent meaning of the 'no argument'
for env-path and env-dir. I would think it would be more intuitive if both
would behave the same w/o argument: display the current values.
Maybe have a "--reset" or something like that to restore the defaults?
(suggestions welcome).
Otherwise the patch is ok, except for a couple of little things. The
comments. They need to start with a capital letter and end with a
period, and 2 spaces after periods. (I know, it's a pain) No externs
in .c files: include inferior.h (update Makefile) and add source_path
to defs.h.
(mention pr number in changelog)
oh, hum, who is responsible for source.c?
thanks
Elena
> Ok to commit?
>
> -- Jeff J.
>
> gdb/ChangeLog:
>
> 2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
>
> * defs.h (init_last_source_visited): New prototype.
> (add_path): Ditto.
> (tilde_expand): Change prototype to const char * to match readline.h.
> * source.c (add_path): New function that adds to a specified path.
> (mod_path): Change to call add_path.
> (init_last_source_visited): New function to allow interfaces to
> initialize static variable: last_source_visited.
>
> gdb/mi/ChangeLog:
>
> 2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
>
> * mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
> (-environment-cd): Change to use mi_cmd_env_cd,.
> (-environment-pwd): Change to use mi_cmd_env_pwd.
> (-environment-path): Change to use mi_cmd_env_path.
> * mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
> (mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
> * mi-cmd-env.c: New file. Part of fix for PR gdb/741.
> * gdbmi.texinfo (environment-cd): Update output and example.
> (environment-pwd): Ditto.
> (environment-dir): Update output, description, and examples.
> (environment-path): Ditto.
>
> gdb/testsuite/gdb.mi/ChangeLog:
>
> 2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
>
> * mi-basics.exp: Change tests for -environment-directory. Also add
> tests for -environment-cd and -environment-pwd. Part of fix for
> PR gdb/741.Index: defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.102
> diff -u -r1.102 defs.h
> --- defs.h 15 Oct 2002 02:16:51 -0000 1.102
> +++ defs.h 7 Nov 2002 21:47:03 -0000
> @@ -572,10 +572,14 @@
>
> extern void mod_path (char *, char **);
>
> +extern void add_path (char *, char **, int);
> +
> extern void directory_command (char *, int);
>
> extern void init_source_path (void);
>
> +extern void init_last_source_visited (void);
> +
> extern char *symtab_to_filename (struct symtab *);
>
> /* From exec.c */
> @@ -616,7 +620,7 @@
>
> /* From readline (but not in any readline .h files). */
>
> -extern char *tilde_expand (char *);
> +extern char *tilde_expand (const char *);
>
> /* Control types for commands */
>
> Index: source.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.36
> diff -u -r1.36 source.c
> --- source.c 24 Oct 2002 21:02:53 -0000 1.36
> +++ source.c 7 Nov 2002 21:47:03 -0000
> @@ -357,6 +357,12 @@
> forget_cached_source_info ();
> }
>
> +void
> +init_last_source_visited (void)
> +{
> + last_source_visited = NULL;
> +}
> +
> /* Add zero or more directories to the front of the source path. */
>
> void
> @@ -387,6 +393,18 @@
> void
> mod_path (char *dirname, char **which_path)
> {
> + add_path (dirname, which_path, 1);
> +}
> +
> +/* Workhorse of mod_path. Takes an extra argument to determine
> + if dirname should be parsed for separators that indicate multiple
> + directories. This allows for interfaces that pre-parse the dirname
> + and allow specification of traditional separator characters such
> + as space or tab. */
> +
> +void
> +add_path (char *dirname, char **which_path, int parse_separators)
> +{
> char *old = *which_path;
> int prefix = 0;
>
> @@ -403,9 +421,16 @@
> struct stat st;
>
> {
> - char *separator = strchr (name, DIRNAME_SEPARATOR);
> - char *space = strchr (name, ' ');
> - char *tab = strchr (name, '\t');
> + char *separator = NULL;
> + char *space = NULL;
> + char *tab = NULL;
> +
> + if (parse_separators)
> + {
> + separator = strchr (name, DIRNAME_SEPARATOR);
> + space = strchr (name, ' ');
> + tab = strchr (name, '\t');
> + }
>
> if (separator == 0 && space == 0 && tab == 0)
> p = dirname = name + strlen (name);
> @@ -536,7 +561,8 @@
> tinybuf[0] = DIRNAME_SEPARATOR;
> tinybuf[1] = '\0';
>
> - /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
> + /* If we have already tacked on a name(s) in this command, be sure they stay
> + on the front as we tack on some more. */
> if (prefix)
> {
> char *temp, c;
> Index: mi/mi-cmd-env.c
> ===================================================================
> RCS file: mi/mi-cmd-env.c
> diff -N mi/mi-cmd-env.c
> --- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
> +++ mi/mi-cmd-env.c 7 Nov 2002 21:47:04 -0000
> @@ -0,0 +1,174 @@
> +/* MI Command Set - environment commands.
> + Copyright 2002 Free Software Foundation, Inc.
> + Contributed by Red Hat Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place - Suite 330,
> + Boston, MA 02111-1307, USA. */
> +
> +#include <string.h>
> +#include <sys/stat.h>
> +
> +#include "defs.h"
> +#include "target.h"
> +#include "frame.h"
> +#include "value.h"
> +#include "mi-cmds.h"
> +#include "mi-out.h"
> +#include "ui-out.h"
> +#include "symtab.h"
> +#include "filenames.h"
> +#include "environ.h"
> +#include "command.h"
> +#include "top.h"
> +
> +extern struct environ *inferior_environ;
> +extern char *source_path;
> +
> +static void env_cli_command (const char *cli, char *args);
> +static void env_mod_path (char *dirname, char **which_path);
> +
> +static const char path_var_name[] = "PATH";
> +
> +/* the following is copied from mi-main.c so for m1 and below we
> + can perform old behavior and use cli commands */
> +static void
> +env_execute_cli_command (const char *cli, char *args)
> +{
> + if (cli != 0)
> + {
> + struct cleanup *old_cleanups;
> + char *run;
> + xasprintf (&run, cli, args);
> + old_cleanups = make_cleanup (xfree, run);
> + execute_command ( /*ui */ run, 0 /*from_tty */ );
> + do_cleanups (old_cleanups);
> + return;
> + }
> +}
> +
> +
> +/* Print working directory. */
> +enum mi_cmd_result
> +mi_cmd_env_pwd (char *command, char **argv, int argc)
> +{
> + if (argc > 0)
> + error ("mi_cmd_env_pwd: No arguments required");
> +
> + if (mi_version (uiout) < 2)
> + {
> + env_execute_cli_command ("pwd", NULL);
> + return MI_CMD_DONE;
> + }
> +
> + /* otherwise mi level 2 or higher */
> +
> + getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
> + ui_out_field_string (uiout, "cwd", gdb_dirbuf);
> +
> + return MI_CMD_DONE;
> +}
> +
> +/* Change working directory. */
> +enum mi_cmd_result
> +mi_cmd_env_cd (char *command, char **argv, int argc)
> +{
> + if (argc == 0 || argc > 1)
> + error ("mi_cmd_env_cd: Usage DIRECTORY");
> +
> + env_execute_cli_command ("cd %s", argv[0]);
> +
> + return MI_CMD_DONE;
> +}
> +
> +static void
> +env_mod_path (char *dirname, char **which_path)
> +{
> + if (dirname == 0 || dirname[0] == '\0')
> + return;
> +
> + /* call add_path with last arg 0 to indicate not to parse for separator chars */
> + add_path (dirname, which_path, 0);
> +}
> +
> +/* Add one or more directories to start of executable search path */
> +enum mi_cmd_result
> +mi_cmd_env_path (char *command, char **argv, int argc)
> +{
> + char *exec_path;
> + char *env;
> + int i;
> +
> + if (mi_version (uiout) < 2)
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_execute_cli_command ("path %s", argv[i]);
> + return MI_CMD_DONE;
> + }
> +
> + /* otherwise mi level 2 or higher */
> + dont_repeat ();
> + env = get_in_environ (inferior_environ, path_var_name);
> +
> + /* Can be null if path is not set */
> + if (!env)
> + env = "";
> + exec_path = xstrdup (env);
> +
> + for (i = argc - 1; i >= 0; --i)
> + env_mod_path (argv[i], &exec_path);
> +
> + set_in_environ (inferior_environ, path_var_name, exec_path);
> + xfree (exec_path);
> + env = get_in_environ (inferior_environ, path_var_name);
> + ui_out_field_string (uiout, "path", env);
> +
> + return MI_CMD_DONE;
> +}
> +
> +/* Add zero or more directories to the front of the source path. */
> +enum mi_cmd_result
> +mi_cmd_env_dir (char *command, char **argv, int argc)
> +{
> + int i;
> +
> + dont_repeat ();
> +
> + if (mi_version (uiout) < 2)
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_execute_cli_command ("dir %s", argv[i]);
> + return MI_CMD_DONE;
> + }
> +
> + /* otherwise mi 2 or higher */
> + if (argc == 0)
> + {
> + /* no args implies reset to default path */
> + xfree (source_path);
> + init_source_path ();
> + }
> + else
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_mod_path (argv[i], &source_path);
> + init_last_source_visited ();
> + }
> +
> + ui_out_field_string (uiout, "source-path", source_path);
> + forget_cached_source_info ();
> +}
> +
> Index: mi/mi-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> retrieving revision 1.8
> diff -u -r1.8 mi-cmds.c
> --- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
> +++ mi/mi-cmds.c 7 Nov 2002 21:47:04 -0000
> @@ -56,10 +56,10 @@
> {"display-enable", 0, 0},
> {"display-insert", 0, 0},
> {"display-list", 0, 0},
> - {"environment-cd", "cd %s", 0},
> - {"environment-directory", "dir %s", 0},
> - {"environment-path", "path %s", 0},
> - {"environment-pwd", "pwd", 0},
> + {"environment-cd", 0, 0, mi_cmd_env_cd},
> + {"environment-directory", 0, 0, mi_cmd_env_dir},
> + {"environment-path", 0, 0, mi_cmd_env_path},
> + {"environment-pwd", 0, 0, mi_cmd_env_pwd},
> {"exec-abort", 0, 0},
> {"exec-arguments", "set args %s", 0},
> {"exec-continue", 0, mi_cmd_exec_continue},
> Index: mi/mi-cmds.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> retrieving revision 1.5
> diff -u -r1.5 mi-cmds.h
> --- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
> +++ mi/mi-cmds.h 7 Nov 2002 21:47:04 -0000
> @@ -64,6 +64,10 @@
> extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
> extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
> extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
> +extern mi_cmd_argv_ftype mi_cmd_env_cd;
> +extern mi_cmd_argv_ftype mi_cmd_env_dir;
> +extern mi_cmd_argv_ftype mi_cmd_env_path;
> +extern mi_cmd_argv_ftype mi_cmd_env_pwd;
> extern mi_cmd_args_ftype mi_cmd_exec_continue;
> extern mi_cmd_args_ftype mi_cmd_exec_finish;
> extern mi_cmd_args_ftype mi_cmd_exec_next;
> Index: gdbmi.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
> retrieving revision 1.29
> diff -u -r1.29 gdbmi.texinfo
> --- gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
> +++ gdbmi.texinfo 7 Nov 2002 21:55:40 -0000
> @@ -1665,10 +1665,12 @@
> @subsubheading Synopsis
>
> @example
> - -environment-directory @var{pathdir}
> + -environment-directory [ @var{pathdir} ]+
> @end example
>
> -Add directory @var{pathdir} to beginning of search path for source files.
> +Add directories @var{pathdir} to beginning of search path for source files.
> +If no argument is given, reset search path to default. An empty string for
> +@var{pathdir} is ignored so it may be used to display the current search path.
>
> @subsubheading @value{GDBN} Command
>
> @@ -1679,7 +1681,13 @@
> @smallexample
> (@value{GDBP})
> -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
> -^done
> +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory ""
> +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory
> +^done,source-path="$cdir:$cwd"
> (@value{GDBP})
> @end smallexample
>
> @@ -1690,10 +1698,12 @@
> @subsubheading Synopsis
>
> @example
> - -environment-path ( @var{pathdir} )+
> + -environment-path [ @var{pathdir} ]+
> @end example
>
> Add directories @var{pathdir} to beginning of search path for object files.
> +If no paths or an empty path is specified, the current object search path
> +is displayed with no modification.
>
> @subsubheading @value{GDBN} Command
>
> @@ -1704,7 +1714,10 @@
> @smallexample
> (@value{GDBP})
> -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
> -^done
> +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> +(@value{GDBP})
> +-environment-path
> +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> (@value{GDBP})
> @end smallexample
>
> @@ -1729,8 +1742,7 @@
> @smallexample
> (@value{GDBP})
> -environment-pwd
> -~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
> -^done
> +^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
> (@value{GDBP})
> @end smallexample
>
> Index: mi-basics.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
> retrieving revision 1.6
> diff -u -r1.6 mi-basics.exp
> --- mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
> +++ mi-basics.exp 7 Nov 2002 21:56:00 -0000
> @@ -150,24 +150,50 @@
>
> # Clear the search directories, then specify one to be searched
> # Tests:
> - # -environment-directory
> # -environment-directory arg
> + # -environment-directory empty-string
> + # -environment-directory
>
> #exp_internal 1
> - mi_gdb_test "202-environment-directory" \
> - "\\\^done" \
> + mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
> + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> + "environment-directory arg operation"
> +
> + mi_gdb_test "203-environment-directory \"\"" \
> + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> + "environment-directory empty-string operation"
> +
> + mi_gdb_test "204-environment-directory" \
> + "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
> "environment-directory operation"
>
> - mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
> - "\\\^done" \
> - "environment-directory arg operation"
> #exp_internal 0
> }
>
> +proc test_cwd_specification {} {
> + global mi_gdb_prompt
> + global objdir
> + global subdir
> +
> + # Change the working directory, then print the current working directory
> + # Tests:
> + # -environment-cd ${objdir}
> + # -environment-pwd
> +
> + mi_gdb_test "205-environment-cd ${objdir}" \
> + "\\\^done" \
> + "environment-cd arg operation"
> +
> + mi_gdb_test "206-environment-pwd" \
> + "\\\^done,cwd=\"${objdir}\"" \
> + "environment-pwd operation"
> +}
> +
> if [test_mi_interpreter_selection] {
> test_exec_and_symbol_mi_operatons
> test_breakpoints_deletion
> test_dir_specification
> + test_cwd_specification
> }
>
> mi_gdb_exit
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-11-07 16:00 ` Elena Zannoni
@ 2002-11-08 15:53 ` J. Johnston
2002-11-11 17:15 ` J. Johnston
0 siblings, 1 reply; 17+ messages in thread
From: J. Johnston @ 2002-11-08 15:53 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches
Elena Zannoni wrote:
>
> J. Johnston writes:
> > Elena Zannoni wrote:
> > >
> > > J. Johnston writes:
> > > > The following solves a number of problems with the mi -environment commands.
> > > > For starters, each command now has an mi cmd wrapper so arguments may use the
> > > > syntax of adding double-quotes to handle extraneous characters such as spaces.
> > > >
> > > > The -environment-pwd command now lists the output in mi syntax:
> > > >
> > > > e.g.
> > > > -environment-pwd
> > > > ^done,cwd="...."
> > > >
> > > > The -environment-directory command has been changed to output in mi format.
> > > > It also has been changed to allow for no arguments being passed.
> > > > If no arguments are passed, it behaves like the gdb dir command and resets the
> > > > source search path to the default, however, no confirmation query is performed. If an empty
> > > > string "" is passed, it is ignored so this can be used to display the current
> > > > search path without modifying it.
> > > >
> > > > e.g.
> > > > -environment-directory /usr/bin /usr/local/bin
> > > > ^done,source-path="/usr/bin:/usr/local/bin:$cdir:$cwd"
> > > >
> > > > The -environment-path command has been changed to output in mi format.
> > > > It also has been changed to allow for no arguments being passed. When
> > > > no arguments are passed, the current object search path is displayed.
> > > >
> > > > e.g.
> > > > -environment-path
> > > > ^done,path="....."
> > > >
> > > > For mi1 or below, the previous behavior is preserved by rerouting the commands
> > > > to their old cli counterparts.
> > >
> > > Hmmm, I think the testsuite changes are ok. Also the addition of the
> > > new file is fine. However I don't think we should be duplicating the
> > > mod_path() code. Would it be possible to maybe split mod_path() in 2
> > > or more functions, and have MI call one of them?
> > > I mean
> > >
> > > mod_path()
> > > {
> > > do_cli_specific_stuff;
> > > call add_path(args1);
> > > ....
> > > }
> > >
> > > mi_env_path()
> > > {
> > > do_mi_specific_stuff;
> > > call add_path(args2);
> > > .....
> > > }
> > >
> > > similarly for other code that may have been duplicated.
> > >
> > > Thanks
> > > Elena
> >
> > I have taken your advice and have added a new interface: add_path which takes
> > an additional argument. The mod_path() routine calls it one way, the mi code
> > calls it another. Of the other code I copied, there is no value add in trying
> > to make it common as I copied a few lines here and there.
> >
> > I found I had to modify the tilde_expand() prototype in defs.h to get my
> > build working. I have a combined source tree and there was a conflict with
> > tilde.h found in the readline directory. The defs.h prototype was not
> > declaring the argument as const.
> >
>
> Ah, right. readline has changed tilde_expand. You must have a newer
> version of realine installed? We cannot make that change yet, because
> we need to build with the readline in our source tree, unfortunately.
> But the upgrade of readline is coming soon. (which reminds me...)
>
Ok, maybe I am bit confused. I thought the readline directory containing the
header file is from my latest sourceware gdb checkout.
> I don't like one minor thing. The inconsistent meaning of the 'no argument'
> for env-path and env-dir. I would think it would be more intuitive if both
> would behave the same w/o argument: display the current values.
> Maybe have a "--reset" or something like that to restore the defaults?
> (suggestions welcome).
>
The proposed behavior is mimicking the gdb command line which resets
when you do a dir with no arguments (sans prompt) and shows the current
path when you do a path with no arguments. I have no problem with
adding an option to the env-dir command to make it a more explicit operation.
> Otherwise the patch is ok, except for a couple of little things. The
> comments. They need to start with a capital letter and end with a
> period, and 2 spaces after periods. (I know, it's a pain) No externs
> in .c files: include inferior.h (update Makefile) and add source_path
> to defs.h.
>
Done. I will resubmit when I add the reset option and
yes, I will remember to put the PR number in the ChangeLogs.
> >
> > gdb/ChangeLog:
> >
> > 2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
> >
> > * defs.h (init_last_source_visited): New prototype.
> > (add_path): Ditto.
> > (tilde_expand): Change prototype to const char * to match readline.h.
> > * source.c (add_path): New function that adds to a specified path.
> > (mod_path): Change to call add_path.
> > (init_last_source_visited): New function to allow interfaces to
> > initialize static variable: last_source_visited.
> >
> > gdb/mi/ChangeLog:
> >
> > 2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
> >
> > * mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
> > (-environment-cd): Change to use mi_cmd_env_cd,.
> > (-environment-pwd): Change to use mi_cmd_env_pwd.
> > (-environment-path): Change to use mi_cmd_env_path.
> > * mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
> > (mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
> > * mi-cmd-env.c: New file. Part of fix for PR gdb/741.
> > * gdbmi.texinfo (environment-cd): Update output and example.
> > (environment-pwd): Ditto.
> > (environment-dir): Update output, description, and examples.
> > (environment-path): Ditto.
> >
> > gdb/testsuite/gdb.mi/ChangeLog:
> >
> > 2002-11-07 Jeff Johnston <jjohnstn@redhat.com>
> >
> > * mi-basics.exp: Change tests for -environment-directory. Also add
> > tests for -environment-cd and -environment-pwd. Part of fix for
> > PR gdb/741.Index: defs.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/defs.h,v
> > retrieving revision 1.102
> > diff -u -r1.102 defs.h
> > --- defs.h 15 Oct 2002 02:16:51 -0000 1.102
> > +++ defs.h 7 Nov 2002 21:47:03 -0000
> > @@ -572,10 +572,14 @@
> >
> > extern void mod_path (char *, char **);
> >
> > +extern void add_path (char *, char **, int);
> > +
> > extern void directory_command (char *, int);
> >
> > extern void init_source_path (void);
> >
> > +extern void init_last_source_visited (void);
> > +
> > extern char *symtab_to_filename (struct symtab *);
> >
> > /* From exec.c */
> > @@ -616,7 +620,7 @@
> >
> > /* From readline (but not in any readline .h files). */
> >
> > -extern char *tilde_expand (char *);
> > +extern char *tilde_expand (const char *);
> >
> > /* Control types for commands */
> >
> > Index: source.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/source.c,v
> > retrieving revision 1.36
> > diff -u -r1.36 source.c
> > --- source.c 24 Oct 2002 21:02:53 -0000 1.36
> > +++ source.c 7 Nov 2002 21:47:03 -0000
> > @@ -357,6 +357,12 @@
> > forget_cached_source_info ();
> > }
> >
> > +void
> > +init_last_source_visited (void)
> > +{
> > + last_source_visited = NULL;
> > +}
> > +
> > /* Add zero or more directories to the front of the source path. */
> >
> > void
> > @@ -387,6 +393,18 @@
> > void
> > mod_path (char *dirname, char **which_path)
> > {
> > + add_path (dirname, which_path, 1);
> > +}
> > +
> > +/* Workhorse of mod_path. Takes an extra argument to determine
> > + if dirname should be parsed for separators that indicate multiple
> > + directories. This allows for interfaces that pre-parse the dirname
> > + and allow specification of traditional separator characters such
> > + as space or tab. */
> > +
> > +void
> > +add_path (char *dirname, char **which_path, int parse_separators)
> > +{
> > char *old = *which_path;
> > int prefix = 0;
> >
> > @@ -403,9 +421,16 @@
> > struct stat st;
> >
> > {
> > - char *separator = strchr (name, DIRNAME_SEPARATOR);
> > - char *space = strchr (name, ' ');
> > - char *tab = strchr (name, '\t');
> > + char *separator = NULL;
> > + char *space = NULL;
> > + char *tab = NULL;
> > +
> > + if (parse_separators)
> > + {
> > + separator = strchr (name, DIRNAME_SEPARATOR);
> > + space = strchr (name, ' ');
> > + tab = strchr (name, '\t');
> > + }
> >
> > if (separator == 0 && space == 0 && tab == 0)
> > p = dirname = name + strlen (name);
> > @@ -536,7 +561,8 @@
> > tinybuf[0] = DIRNAME_SEPARATOR;
> > tinybuf[1] = '\0';
> >
> > - /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
> > + /* If we have already tacked on a name(s) in this command, be sure they stay
> > + on the front as we tack on some more. */
> > if (prefix)
> > {
> > char *temp, c;
> > Index: mi/mi-cmd-env.c
> > ===================================================================
> > RCS file: mi/mi-cmd-env.c
> > diff -N mi/mi-cmd-env.c
> > --- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
> > +++ mi/mi-cmd-env.c 7 Nov 2002 21:47:04 -0000
> > @@ -0,0 +1,174 @@
> > +/* MI Command Set - environment commands.
> > + Copyright 2002 Free Software Foundation, Inc.
> > + Contributed by Red Hat Inc.
> > +
> > + This file is part of GDB.
> > +
> > + This program is free software; you can redistribute it and/or modify
> > + it under the terms of the GNU General Public License as published by
> > + the Free Software Foundation; either version 2 of the License, or
> > + (at your option) any later version.
> > +
> > + This program is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + GNU General Public License for more details.
> > +
> > + You should have received a copy of the GNU General Public License
> > + along with this program; if not, write to the Free Software
> > + Foundation, Inc., 59 Temple Place - Suite 330,
> > + Boston, MA 02111-1307, USA. */
> > +
> > +#include <string.h>
> > +#include <sys/stat.h>
> > +
> > +#include "defs.h"
> > +#include "target.h"
> > +#include "frame.h"
> > +#include "value.h"
> > +#include "mi-cmds.h"
> > +#include "mi-out.h"
> > +#include "ui-out.h"
> > +#include "symtab.h"
> > +#include "filenames.h"
> > +#include "environ.h"
> > +#include "command.h"
> > +#include "top.h"
> > +
> > +extern struct environ *inferior_environ;
> > +extern char *source_path;
> > +
> > +static void env_cli_command (const char *cli, char *args);
> > +static void env_mod_path (char *dirname, char **which_path);
> > +
> > +static const char path_var_name[] = "PATH";
> > +
> > +/* the following is copied from mi-main.c so for m1 and below we
> > + can perform old behavior and use cli commands */
> > +static void
> > +env_execute_cli_command (const char *cli, char *args)
> > +{
> > + if (cli != 0)
> > + {
> > + struct cleanup *old_cleanups;
> > + char *run;
> > + xasprintf (&run, cli, args);
> > + old_cleanups = make_cleanup (xfree, run);
> > + execute_command ( /*ui */ run, 0 /*from_tty */ );
> > + do_cleanups (old_cleanups);
> > + return;
> > + }
> > +}
> > +
> > +
> > +/* Print working directory. */
> > +enum mi_cmd_result
> > +mi_cmd_env_pwd (char *command, char **argv, int argc)
> > +{
> > + if (argc > 0)
> > + error ("mi_cmd_env_pwd: No arguments required");
> > +
> > + if (mi_version (uiout) < 2)
> > + {
> > + env_execute_cli_command ("pwd", NULL);
> > + return MI_CMD_DONE;
> > + }
> > +
> > + /* otherwise mi level 2 or higher */
> > +
> > + getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
> > + ui_out_field_string (uiout, "cwd", gdb_dirbuf);
> > +
> > + return MI_CMD_DONE;
> > +}
> > +
> > +/* Change working directory. */
> > +enum mi_cmd_result
> > +mi_cmd_env_cd (char *command, char **argv, int argc)
> > +{
> > + if (argc == 0 || argc > 1)
> > + error ("mi_cmd_env_cd: Usage DIRECTORY");
> > +
> > + env_execute_cli_command ("cd %s", argv[0]);
> > +
> > + return MI_CMD_DONE;
> > +}
> > +
> > +static void
> > +env_mod_path (char *dirname, char **which_path)
> > +{
> > + if (dirname == 0 || dirname[0] == '\0')
> > + return;
> > +
> > + /* call add_path with last arg 0 to indicate not to parse for separator chars */
> > + add_path (dirname, which_path, 0);
> > +}
> > +
> > +/* Add one or more directories to start of executable search path */
> > +enum mi_cmd_result
> > +mi_cmd_env_path (char *command, char **argv, int argc)
> > +{
> > + char *exec_path;
> > + char *env;
> > + int i;
> > +
> > + if (mi_version (uiout) < 2)
> > + {
> > + for (i = argc - 1; i >= 0; --i)
> > + env_execute_cli_command ("path %s", argv[i]);
> > + return MI_CMD_DONE;
> > + }
> > +
> > + /* otherwise mi level 2 or higher */
> > + dont_repeat ();
> > + env = get_in_environ (inferior_environ, path_var_name);
> > +
> > + /* Can be null if path is not set */
> > + if (!env)
> > + env = "";
> > + exec_path = xstrdup (env);
> > +
> > + for (i = argc - 1; i >= 0; --i)
> > + env_mod_path (argv[i], &exec_path);
> > +
> > + set_in_environ (inferior_environ, path_var_name, exec_path);
> > + xfree (exec_path);
> > + env = get_in_environ (inferior_environ, path_var_name);
> > + ui_out_field_string (uiout, "path", env);
> > +
> > + return MI_CMD_DONE;
> > +}
> > +
> > +/* Add zero or more directories to the front of the source path. */
> > +enum mi_cmd_result
> > +mi_cmd_env_dir (char *command, char **argv, int argc)
> > +{
> > + int i;
> > +
> > + dont_repeat ();
> > +
> > + if (mi_version (uiout) < 2)
> > + {
> > + for (i = argc - 1; i >= 0; --i)
> > + env_execute_cli_command ("dir %s", argv[i]);
> > + return MI_CMD_DONE;
> > + }
> > +
> > + /* otherwise mi 2 or higher */
> > + if (argc == 0)
> > + {
> > + /* no args implies reset to default path */
> > + xfree (source_path);
> > + init_source_path ();
> > + }
> > + else
> > + {
> > + for (i = argc - 1; i >= 0; --i)
> > + env_mod_path (argv[i], &source_path);
> > + init_last_source_visited ();
> > + }
> > +
> > + ui_out_field_string (uiout, "source-path", source_path);
> > + forget_cached_source_info ();
> > +}
> > +
> > Index: mi/mi-cmds.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> > retrieving revision 1.8
> > diff -u -r1.8 mi-cmds.c
> > --- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
> > +++ mi/mi-cmds.c 7 Nov 2002 21:47:04 -0000
> > @@ -56,10 +56,10 @@
> > {"display-enable", 0, 0},
> > {"display-insert", 0, 0},
> > {"display-list", 0, 0},
> > - {"environment-cd", "cd %s", 0},
> > - {"environment-directory", "dir %s", 0},
> > - {"environment-path", "path %s", 0},
> > - {"environment-pwd", "pwd", 0},
> > + {"environment-cd", 0, 0, mi_cmd_env_cd},
> > + {"environment-directory", 0, 0, mi_cmd_env_dir},
> > + {"environment-path", 0, 0, mi_cmd_env_path},
> > + {"environment-pwd", 0, 0, mi_cmd_env_pwd},
> > {"exec-abort", 0, 0},
> > {"exec-arguments", "set args %s", 0},
> > {"exec-continue", 0, mi_cmd_exec_continue},
> > Index: mi/mi-cmds.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> > retrieving revision 1.5
> > diff -u -r1.5 mi-cmds.h
> > --- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
> > +++ mi/mi-cmds.h 7 Nov 2002 21:47:04 -0000
> > @@ -64,6 +64,10 @@
> > extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
> > extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
> > extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
> > +extern mi_cmd_argv_ftype mi_cmd_env_cd;
> > +extern mi_cmd_argv_ftype mi_cmd_env_dir;
> > +extern mi_cmd_argv_ftype mi_cmd_env_path;
> > +extern mi_cmd_argv_ftype mi_cmd_env_pwd;
> > extern mi_cmd_args_ftype mi_cmd_exec_continue;
> > extern mi_cmd_args_ftype mi_cmd_exec_finish;
> > extern mi_cmd_args_ftype mi_cmd_exec_next;
> > Index: gdbmi.texinfo
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
> > retrieving revision 1.29
> > diff -u -r1.29 gdbmi.texinfo
> > --- gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
> > +++ gdbmi.texinfo 7 Nov 2002 21:55:40 -0000
> > @@ -1665,10 +1665,12 @@
> > @subsubheading Synopsis
> >
> > @example
> > - -environment-directory @var{pathdir}
> > + -environment-directory [ @var{pathdir} ]+
> > @end example
> >
> > -Add directory @var{pathdir} to beginning of search path for source files.
> > +Add directories @var{pathdir} to beginning of search path for source files.
> > +If no argument is given, reset search path to default. An empty string for
> > +@var{pathdir} is ignored so it may be used to display the current search path.
> >
> > @subsubheading @value{GDBN} Command
> >
> > @@ -1679,7 +1681,13 @@
> > @smallexample
> > (@value{GDBP})
> > -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
> > -^done
> > +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> > +(@value{GDBP})
> > +-environment-directory ""
> > +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> > +(@value{GDBP})
> > +-environment-directory
> > +^done,source-path="$cdir:$cwd"
> > (@value{GDBP})
> > @end smallexample
> >
> > @@ -1690,10 +1698,12 @@
> > @subsubheading Synopsis
> >
> > @example
> > - -environment-path ( @var{pathdir} )+
> > + -environment-path [ @var{pathdir} ]+
> > @end example
> >
> > Add directories @var{pathdir} to beginning of search path for object files.
> > +If no paths or an empty path is specified, the current object search path
> > +is displayed with no modification.
> >
> > @subsubheading @value{GDBN} Command
> >
> > @@ -1704,7 +1714,10 @@
> > @smallexample
> > (@value{GDBP})
> > -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
> > -^done
> > +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> > +(@value{GDBP})
> > +-environment-path
> > +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> > (@value{GDBP})
> > @end smallexample
> >
> > @@ -1729,8 +1742,7 @@
> > @smallexample
> > (@value{GDBP})
> > -environment-pwd
> > -~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
> > -^done
> > +^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
> > (@value{GDBP})
> > @end smallexample
> >
> > Index: mi-basics.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
> > retrieving revision 1.6
> > diff -u -r1.6 mi-basics.exp
> > --- mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
> > +++ mi-basics.exp 7 Nov 2002 21:56:00 -0000
> > @@ -150,24 +150,50 @@
> >
> > # Clear the search directories, then specify one to be searched
> > # Tests:
> > - # -environment-directory
> > # -environment-directory arg
> > + # -environment-directory empty-string
> > + # -environment-directory
> >
> > #exp_internal 1
> > - mi_gdb_test "202-environment-directory" \
> > - "\\\^done" \
> > + mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
> > + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> > + "environment-directory arg operation"
> > +
> > + mi_gdb_test "203-environment-directory \"\"" \
> > + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> > + "environment-directory empty-string operation"
> > +
> > + mi_gdb_test "204-environment-directory" \
> > + "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
> > "environment-directory operation"
> >
> > - mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
> > - "\\\^done" \
> > - "environment-directory arg operation"
> > #exp_internal 0
> > }
> >
> > +proc test_cwd_specification {} {
> > + global mi_gdb_prompt
> > + global objdir
> > + global subdir
> > +
> > + # Change the working directory, then print the current working directory
> > + # Tests:
> > + # -environment-cd ${objdir}
> > + # -environment-pwd
> > +
> > + mi_gdb_test "205-environment-cd ${objdir}" \
> > + "\\\^done" \
> > + "environment-cd arg operation"
> > +
> > + mi_gdb_test "206-environment-pwd" \
> > + "\\\^done,cwd=\"${objdir}\"" \
> > + "environment-pwd operation"
> > +}
> > +
> > if [test_mi_interpreter_selection] {
> > test_exec_and_symbol_mi_operatons
> > test_breakpoints_deletion
> > test_dir_specification
> > + test_cwd_specification
> > }
> >
> > mi_gdb_exit
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-11-07 14:10 ` J. Johnston
2002-11-07 16:00 ` Elena Zannoni
@ 2002-11-09 13:28 ` Eli Zaretskii
1 sibling, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2002-11-09 13:28 UTC (permalink / raw)
To: jjohnstn; +Cc: ezannoni, gdb-patches
> Date: Thu, 07 Nov 2002 17:10:42 -0500
> From: "J. Johnston" <jjohnstn@redhat.com>
>
> I have taken your advice and have added a new interface: add_path which takes
> an additional argument.
The gdbmi.texinfo patch is approved.
Thanks!
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-11-08 15:53 ` J. Johnston
@ 2002-11-11 17:15 ` J. Johnston
2002-12-06 7:34 ` Elena Zannoni
0 siblings, 1 reply; 17+ messages in thread
From: J. Johnston @ 2002-11-11 17:15 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches, eliz
[-- Attachment #1: Type: text/plain, Size: 6129 bytes --]
"J. Johnston" wrote:
>
> Elena Zannoni wrote:
> >
> > J. Johnston writes:
> > > Elena Zannoni wrote:
> > > >
> > > > J. Johnston writes:
> > > > > The following solves a number of problems with the mi -environment commands.
> > > > > For starters, each command now has an mi cmd wrapper so arguments may use the
> > > > > syntax of adding double-quotes to handle extraneous characters such as spaces.
> > > > >
> > > > > The -environment-pwd command now lists the output in mi syntax:
> > > > >
> > > > > e.g.
> > > > > -environment-pwd
> > > > > ^done,cwd="...."
> > > > >
> > > > > The -environment-directory command has been changed to output in mi format.
> > > > > It also has been changed to allow for no arguments being passed.
> > > > > If no arguments are passed, it behaves like the gdb dir command and resets the
> > > > > source search path to the default, however, no confirmation query is performed. If an empty
> > > > > string "" is passed, it is ignored so this can be used to display the current
> > > > > search path without modifying it.
> > > > >
> > > > > e.g.
> > > > > -environment-directory /usr/bin /usr/local/bin
> > > > > ^done,source-path="/usr/bin:/usr/local/bin:$cdir:$cwd"
> > > > >
> > > > > The -environment-path command has been changed to output in mi format.
> > > > > It also has been changed to allow for no arguments being passed. When
> > > > > no arguments are passed, the current object search path is displayed.
> > > > >
> > > > > e.g.
> > > > > -environment-path
> > > > > ^done,path="....."
> > > > >
> > > > > For mi1 or below, the previous behavior is preserved by rerouting the commands
> > > > > to their old cli counterparts.
> > > >
> > > > Hmmm, I think the testsuite changes are ok. Also the addition of the
> > > > new file is fine. However I don't think we should be duplicating the
> > > > mod_path() code. Would it be possible to maybe split mod_path() in 2
> > > > or more functions, and have MI call one of them?
> > > > I mean
> > > >
> > > > mod_path()
> > > > {
> > > > do_cli_specific_stuff;
> > > > call add_path(args1);
> > > > ....
> > > > }
> > > >
> > > > mi_env_path()
> > > > {
> > > > do_mi_specific_stuff;
> > > > call add_path(args2);
> > > > .....
> > > > }
> > > >
> > > > similarly for other code that may have been duplicated.
> > > >
> > > > Thanks
> > > > Elena
> > >
> > > I have taken your advice and have added a new interface: add_path which takes
> > > an additional argument. The mod_path() routine calls it one way, the mi code
> > > calls it another. Of the other code I copied, there is no value add in trying
> > > to make it common as I copied a few lines here and there.
> > >
> > > I found I had to modify the tilde_expand() prototype in defs.h to get my
> > > build working. I have a combined source tree and there was a conflict with
> > > tilde.h found in the readline directory. The defs.h prototype was not
> > > declaring the argument as const.
> > >
> >
> > Ah, right. readline has changed tilde_expand. You must have a newer
> > version of realine installed? We cannot make that change yet, because
> > we need to build with the readline in our source tree, unfortunately.
> > But the upgrade of readline is coming soon. (which reminds me...)
> >
>
> Ok, maybe I am bit confused. I thought the readline directory containing the
> header file is from my latest sourceware gdb checkout.
>
> > I don't like one minor thing. The inconsistent meaning of the 'no argument'
> > for env-path and env-dir. I would think it would be more intuitive if both
> > would behave the same w/o argument: display the current values.
> > Maybe have a "--reset" or something like that to restore the defaults?
> > (suggestions welcome).
> >
>
> The proposed behavior is mimicking the gdb command line which resets
> when you do a dir with no arguments (sans prompt) and shows the current
> path when you do a path with no arguments. I have no problem with
> adding an option to the env-dir command to make it a more explicit operation.
>
> > Otherwise the patch is ok, except for a couple of little things. The
> > comments. They need to start with a capital letter and end with a
> > period, and 2 spaces after periods. (I know, it's a pain) No externs
> > in .c files: include inferior.h (update Makefile) and add source_path
> > to defs.h.
> >
>
> Done. I will resubmit when I add the reset option and
> yes, I will remember to put the PR number in the ChangeLogs.
>
Ok, hopefully the last iteration of this. Eli, the doc has changed because
of the new reset option.
gdb/ChangeLog:
2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
* defs.h (init_last_source_visited): New prototype.
(add_path): Ditto.
* source.c (add_path): New function that adds to a specified path.
(mod_path): Change to call add_path.
(init_last_source_visited): New function to allow interfaces to
initialize static variable: last_source_visited. Part of fix
for PR gdb/741.
* Makefile.in: Add support for mi/mi-cmd-env.c.
gdb/mi/ChangeLog:
2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
* mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
(-environment-cd): Change to use mi_cmd_env_cd,.
(-environment-pwd): Change to use mi_cmd_env_pwd.
(-environment-path): Change to use mi_cmd_env_path.
* mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
(mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
* mi-cmd-env.c: New file. Part of fix for PR gdb/741.
* gdbmi.texinfo (environment-cd): Update output and example.
(environment-pwd): Ditto.
(environment-dir): Update output, description, and examples.
(environment-path): Ditto.
gdb/testsuite/gdb.mi/ChangeLog:
2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
* mi-basics.exp: Change tests for -environment-directory. Also add
tests for -environment-cd and -environment-pwd. Part of fix for
PR gdb/741.
[-- Attachment #2: 741.patch --]
[-- Type: text/plain, Size: 10809 bytes --]
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.102
diff -u -r1.102 defs.h
--- defs.h 15 Oct 2002 02:16:51 -0000 1.102
+++ defs.h 9 Nov 2002 00:33:14 -0000
@@ -572,9 +572,15 @@
extern void mod_path (char *, char **);
+extern void add_path (char *, char **, int);
+
extern void directory_command (char *, int);
+extern char *source_path;
+
extern void init_source_path (void);
+
+extern void init_last_source_visited (void);
extern char *symtab_to_filename (struct symtab *);
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.36
diff -u -r1.36 source.c
--- source.c 24 Oct 2002 21:02:53 -0000 1.36
+++ source.c 9 Nov 2002 00:33:14 -0000
@@ -357,6 +357,12 @@
forget_cached_source_info ();
}
+void
+init_last_source_visited (void)
+{
+ last_source_visited = NULL;
+}
+
/* Add zero or more directories to the front of the source path. */
void
@@ -387,6 +393,18 @@
void
mod_path (char *dirname, char **which_path)
{
+ add_path (dirname, which_path, 1);
+}
+
+/* Workhorse of mod_path. Takes an extra argument to determine
+ if dirname should be parsed for separators that indicate multiple
+ directories. This allows for interfaces that pre-parse the dirname
+ and allow specification of traditional separator characters such
+ as space or tab. */
+
+void
+add_path (char *dirname, char **which_path, int parse_separators)
+{
char *old = *which_path;
int prefix = 0;
@@ -403,9 +421,16 @@
struct stat st;
{
- char *separator = strchr (name, DIRNAME_SEPARATOR);
- char *space = strchr (name, ' ');
- char *tab = strchr (name, '\t');
+ char *separator = NULL;
+ char *space = NULL;
+ char *tab = NULL;
+
+ if (parse_separators)
+ {
+ separator = strchr (name, DIRNAME_SEPARATOR);
+ space = strchr (name, ' ');
+ tab = strchr (name, '\t');
+ }
if (separator == 0 && space == 0 && tab == 0)
p = dirname = name + strlen (name);
@@ -536,7 +561,8 @@
tinybuf[0] = DIRNAME_SEPARATOR;
tinybuf[1] = '\0';
- /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
+ /* If we have already tacked on a name(s) in this command, be sure they stay
+ on the front as we tack on some more. */
if (prefix)
{
char *temp, c;
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.278
diff -u -r1.278 Makefile.in
--- Makefile.in 8 Nov 2002 20:48:54 -0000 1.278
+++ Makefile.in 9 Nov 2002 00:33:14 -0000
@@ -166,12 +166,12 @@
#
SUBDIR_MI_OBS = \
mi-out.o mi-console.o \
- mi-cmds.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
+ mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
mi-cmd-disas.o \
mi-main.o mi-parse.o mi-getopt.o
SUBDIR_MI_SRCS = \
mi/mi-out.c mi/mi-console.c \
- mi/mi-cmds.c \
+ mi/mi-cmds.c mi/mi-cmd-env.c \
mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
mi/mi-cmd-disas.c \
mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
@@ -2487,6 +2487,10 @@
mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
$(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h) $(disasm_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
+mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
+ $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(inferior.h) \
+ $(mi_getopt_h)
+ $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-env.c
mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
$(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
Index: mi/mi-cmd-env.c
===================================================================
RCS file: mi/mi-cmd-env.c
diff -N mi/mi-cmd-env.c
--- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
+++ mi/mi-cmd-env.c 9 Nov 2002 00:33:14 -0000
@@ -0,0 +1,202 @@
+/* MI Command Set - environment commands.
+ Copyright 2002 Free Software Foundation, Inc.
+ Contributed by Red Hat Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <string.h>
+#include <sys/stat.h>
+
+#include "defs.h"
+#include "target.h"
+#include "frame.h"
+#include "value.h"
+#include "mi-cmds.h"
+#include "mi-out.h"
+#include "mi-getopt.h"
+#include "ui-out.h"
+#include "symtab.h"
+#include "filenames.h"
+#include "environ.h"
+#include "command.h"
+#include "top.h"
+#include "inferior.h"
+
+static void env_cli_command (const char *cli, char *args);
+static void env_mod_path (char *dirname, char **which_path);
+
+static const char path_var_name[] = "PATH";
+
+/* The following is copied from mi-main.c so for m1 and below we
+ can perform old behavior and use cli commands. */
+static void
+env_execute_cli_command (const char *cli, char *args)
+{
+ if (cli != 0)
+ {
+ struct cleanup *old_cleanups;
+ char *run;
+ xasprintf (&run, cli, args);
+ old_cleanups = make_cleanup (xfree, run);
+ execute_command ( /*ui */ run, 0 /*from_tty */ );
+ do_cleanups (old_cleanups);
+ return;
+ }
+}
+
+
+/* Print working directory. */
+enum mi_cmd_result
+mi_cmd_env_pwd (char *command, char **argv, int argc)
+{
+ if (argc > 0)
+ error ("mi_cmd_env_pwd: No arguments required");
+
+ if (mi_version (uiout) < 2)
+ {
+ env_execute_cli_command ("pwd", NULL);
+ return MI_CMD_DONE;
+ }
+
+ /* Otherwise the mi level is 2 or higher. */
+
+ getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+ ui_out_field_string (uiout, "cwd", gdb_dirbuf);
+
+ return MI_CMD_DONE;
+}
+
+/* Change working directory. */
+enum mi_cmd_result
+mi_cmd_env_cd (char *command, char **argv, int argc)
+{
+ if (argc == 0 || argc > 1)
+ error ("mi_cmd_env_cd: Usage DIRECTORY");
+
+ env_execute_cli_command ("cd %s", argv[0]);
+
+ return MI_CMD_DONE;
+}
+
+static void
+env_mod_path (char *dirname, char **which_path)
+{
+ if (dirname == 0 || dirname[0] == '\0')
+ return;
+
+ /* Call add_path with last arg 0 to indicate not to parse for
+ separator characters. */
+ add_path (dirname, which_path, 0);
+}
+
+/* Add one or more directories to start of executable search path. */
+enum mi_cmd_result
+mi_cmd_env_path (char *command, char **argv, int argc)
+{
+ char *exec_path;
+ char *env;
+ int i;
+
+ if (mi_version (uiout) < 2)
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_execute_cli_command ("path %s", argv[i]);
+ return MI_CMD_DONE;
+ }
+
+ /* Otherwise the mi level is 2 or higher. */
+ dont_repeat ();
+ env = get_in_environ (inferior_environ, path_var_name);
+
+ /* Can be null if path is not set. */
+ if (!env)
+ env = "";
+ exec_path = xstrdup (env);
+
+ for (i = argc - 1; i >= 0; --i)
+ env_mod_path (argv[i], &exec_path);
+
+ set_in_environ (inferior_environ, path_var_name, exec_path);
+ xfree (exec_path);
+ env = get_in_environ (inferior_environ, path_var_name);
+ ui_out_field_string (uiout, "path", env);
+
+ return MI_CMD_DONE;
+}
+
+/* Add zero or more directories to the front of the source path. */
+enum mi_cmd_result
+mi_cmd_env_dir (char *command, char **argv, int argc)
+{
+ int i;
+ int optind = 0;
+ int reset = 0;
+ char *optarg;
+ enum opt
+ {
+ RESET_OPT
+ };
+ static struct mi_opt opts[] =
+ {
+ {"r", RESET_OPT, 0},
+ 0
+ };
+
+ dont_repeat ();
+
+ if (mi_version (uiout) < 2)
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_execute_cli_command ("dir %s", argv[i]);
+ return MI_CMD_DONE;
+ }
+
+ /* Otherwise mi level is 2 or higher. */
+ while (1)
+ {
+ int opt = mi_getopt ("mi_cmd_data_read_memory", argc, argv, opts,
+ &optind, &optarg);
+ if (opt < 0)
+ break;
+ switch ((enum opt) opt)
+ {
+ case RESET_OPT:
+ reset = 1;
+ break;
+ }
+ }
+ argv += optind;
+ argc -= optind;
+
+ if (reset)
+ {
+ /* No args implies reset to default path. */
+ xfree (source_path);
+ init_source_path ();
+ }
+
+ for (i = argc - 1; i >= 0; --i)
+ env_mod_path (argv[i], &source_path);
+ init_last_source_visited ();
+
+ ui_out_field_string (uiout, "source-path", source_path);
+ forget_cached_source_info ();
+
+ return MI_CMD_DONE;
+}
+
Index: mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.5
diff -u -r1.5 mi-cmds.h
--- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
+++ mi/mi-cmds.h 9 Nov 2002 00:33:14 -0000
@@ -64,6 +64,10 @@
extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
+extern mi_cmd_argv_ftype mi_cmd_env_cd;
+extern mi_cmd_argv_ftype mi_cmd_env_dir;
+extern mi_cmd_argv_ftype mi_cmd_env_path;
+extern mi_cmd_argv_ftype mi_cmd_env_pwd;
extern mi_cmd_args_ftype mi_cmd_exec_continue;
extern mi_cmd_args_ftype mi_cmd_exec_finish;
extern mi_cmd_args_ftype mi_cmd_exec_next;
Index: mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.8
diff -u -r1.8 mi-cmds.c
--- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
+++ mi/mi-cmds.c 9 Nov 2002 00:33:14 -0000
@@ -56,10 +56,10 @@
{"display-enable", 0, 0},
{"display-insert", 0, 0},
{"display-list", 0, 0},
- {"environment-cd", "cd %s", 0},
- {"environment-directory", "dir %s", 0},
- {"environment-path", "path %s", 0},
- {"environment-pwd", "pwd", 0},
+ {"environment-cd", 0, 0, mi_cmd_env_cd},
+ {"environment-directory", 0, 0, mi_cmd_env_dir},
+ {"environment-path", 0, 0, mi_cmd_env_path},
+ {"environment-pwd", 0, 0, mi_cmd_env_pwd},
{"exec-abort", 0, 0},
{"exec-arguments", "set args %s", 0},
{"exec-continue", 0, mi_cmd_exec_continue},
[-- Attachment #3: 741.doc.patch --]
[-- Type: text/plain, Size: 2683 bytes --]
Index: gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.29
diff -u -r1.29 gdbmi.texinfo
--- gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
+++ gdbmi.texinfo 9 Nov 2002 00:30:50 -0000
@@ -1665,10 +1665,18 @@
@subsubheading Synopsis
@example
- -environment-directory @var{pathdir}
+ -environment-directory [ -r ] [ @var{pathdir} ]+
@end example
-Add directory @var{pathdir} to beginning of search path for source files.
+Add directories @var{pathdir} to beginning of search path for source files.
+If the @samp{-r} option is used, the search path is reset to the default
+search path. If directories @var{pathdir} are supplied in addition to the
+@samp{-r} option, the search path is first reset and then addition
+occurs as normal.
+Specifying multiple directories in a single command
+results in the directories added to the beginning of the
+search path in the same order they were presented in the command.
+If no directories are specified, the current search path is displayed.
@subsubheading @value{GDBN} Command
@@ -1679,7 +1687,16 @@
@smallexample
(@value{GDBP})
-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
-^done
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory ""
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory -r /home/jjohnstn/src/gdb
+^done,source-path="/home/jjohnstn/src/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory -r
+^done,source-path="$cdir:$cwd"
(@value{GDBP})
@end smallexample
@@ -1690,10 +1707,12 @@
@subsubheading Synopsis
@example
- -environment-path ( @var{pathdir} )+
+ -environment-path [ @var{pathdir} ]+
@end example
Add directories @var{pathdir} to beginning of search path for object files.
+If no paths or an empty path is specified, the current object search path
+is displayed with no modification.
@subsubheading @value{GDBN} Command
@@ -1704,7 +1723,10 @@
@smallexample
(@value{GDBP})
-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
-^done
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
+(@value{GDBP})
+-environment-path
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
(@value{GDBP})
@end smallexample
@@ -1729,8 +1751,7 @@
@smallexample
(@value{GDBP})
-environment-pwd
-~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
-^done
+^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
(@value{GDBP})
@end smallexample
[-- Attachment #4: 741.test.patch --]
[-- Type: text/plain, Size: 2136 bytes --]
Index: mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.6
diff -u -r1.6 mi-basics.exp
--- mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
+++ mi-basics.exp 11 Nov 2002 21:11:07 -0000
@@ -148,26 +148,52 @@
global srcdir
global subdir
- # Clear the search directories, then specify one to be searched
+ # Add to the search directories, display, then reset back to default
# Tests:
- # -environment-directory
# -environment-directory arg
+ # -environment-directory
+ # -environment-directory -r
#exp_internal 1
- mi_gdb_test "202-environment-directory" \
- "\\\^done" \
+ mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
+ "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
+ "environment-directory arg operation"
+
+ mi_gdb_test "203-environment-directory" \
+ "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
+ "environment-directory empty-string operation"
+
+ mi_gdb_test "204-environment-directory -r" \
+ "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
"environment-directory operation"
- mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
- "\\\^done" \
- "environment-directory arg operation"
#exp_internal 0
}
+proc test_cwd_specification {} {
+ global mi_gdb_prompt
+ global objdir
+ global subdir
+
+ # Change the working directory, then print the current working directory
+ # Tests:
+ # -environment-cd ${objdir}
+ # -environment-pwd
+
+ mi_gdb_test "205-environment-cd ${objdir}" \
+ "\\\^done" \
+ "environment-cd arg operation"
+
+ mi_gdb_test "206-environment-pwd" \
+ "\\\^done,cwd=\"${objdir}\"" \
+ "environment-pwd operation"
+}
+
if [test_mi_interpreter_selection] {
test_exec_and_symbol_mi_operatons
test_breakpoints_deletion
test_dir_specification
+ test_cwd_specification
}
mi_gdb_exit
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-11-11 17:15 ` J. Johnston
@ 2002-12-06 7:34 ` Elena Zannoni
2002-12-09 17:05 ` J. Johnston
0 siblings, 1 reply; 17+ messages in thread
From: Elena Zannoni @ 2002-12-06 7:34 UTC (permalink / raw)
To: J. Johnston; +Cc: Elena Zannoni, gdb-patches, eliz
J. Johnston writes:
>
Ok I noticed a few more things in mi-cmd-env.c, the rest is ok.
Sorry, another iteration....
See below.
> gdb/ChangeLog:
>
> 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
>
> * defs.h (init_last_source_visited): New prototype.
> (add_path): Ditto.
> * source.c (add_path): New function that adds to a specified path.
> (mod_path): Change to call add_path.
> (init_last_source_visited): New function to allow interfaces to
> initialize static variable: last_source_visited. Part of fix
> for PR gdb/741.
> * Makefile.in: Add support for mi/mi-cmd-env.c.
>
> gdb/mi/ChangeLog:
>
> 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
>
> * mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
> (-environment-cd): Change to use mi_cmd_env_cd,.
> (-environment-pwd): Change to use mi_cmd_env_pwd.
> (-environment-path): Change to use mi_cmd_env_path.
> * mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
> (mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
> * mi-cmd-env.c: New file. Part of fix for PR gdb/741.
> * gdbmi.texinfo (environment-cd): Update output and example.
> (environment-pwd): Ditto.
> (environment-dir): Update output, description, and examples.
> (environment-path): Ditto.
>
> gdb/testsuite/gdb.mi/ChangeLog:
>
> 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
>
> * mi-basics.exp: Change tests for -environment-directory. Also add
> tests for -environment-cd and -environment-pwd. Part of fix for
> PR gdb/741.Index: defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.102
> diff -u -r1.102 defs.h
> --- defs.h 15 Oct 2002 02:16:51 -0000 1.102
> +++ defs.h 9 Nov 2002 00:33:14 -0000
> @@ -572,9 +572,15 @@
>
> extern void mod_path (char *, char **);
>
> +extern void add_path (char *, char **, int);
> +
> extern void directory_command (char *, int);
>
> +extern char *source_path;
> +
> extern void init_source_path (void);
> +
> +extern void init_last_source_visited (void);
>
> extern char *symtab_to_filename (struct symtab *);
>
> Index: source.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.36
> diff -u -r1.36 source.c
> --- source.c 24 Oct 2002 21:02:53 -0000 1.36
> +++ source.c 9 Nov 2002 00:33:14 -0000
> @@ -357,6 +357,12 @@
> forget_cached_source_info ();
> }
>
> +void
> +init_last_source_visited (void)
> +{
> + last_source_visited = NULL;
> +}
> +
> /* Add zero or more directories to the front of the source path. */
>
> void
> @@ -387,6 +393,18 @@
> void
> mod_path (char *dirname, char **which_path)
> {
> + add_path (dirname, which_path, 1);
> +}
> +
> +/* Workhorse of mod_path. Takes an extra argument to determine
> + if dirname should be parsed for separators that indicate multiple
> + directories. This allows for interfaces that pre-parse the dirname
> + and allow specification of traditional separator characters such
> + as space or tab. */
> +
> +void
> +add_path (char *dirname, char **which_path, int parse_separators)
> +{
> char *old = *which_path;
> int prefix = 0;
>
> @@ -403,9 +421,16 @@
> struct stat st;
>
> {
> - char *separator = strchr (name, DIRNAME_SEPARATOR);
> - char *space = strchr (name, ' ');
> - char *tab = strchr (name, '\t');
> + char *separator = NULL;
> + char *space = NULL;
> + char *tab = NULL;
> +
> + if (parse_separators)
> + {
> + separator = strchr (name, DIRNAME_SEPARATOR);
> + space = strchr (name, ' ');
> + tab = strchr (name, '\t');
> + }
>
> if (separator == 0 && space == 0 && tab == 0)
> p = dirname = name + strlen (name);
> @@ -536,7 +561,8 @@
> tinybuf[0] = DIRNAME_SEPARATOR;
> tinybuf[1] = '\0';
>
> - /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
> + /* If we have already tacked on a name(s) in this command, be sure they stay
> + on the front as we tack on some more. */
> if (prefix)
> {
> char *temp, c;
> Index: Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/Makefile.in,v
> retrieving revision 1.278
> diff -u -r1.278 Makefile.in
> --- Makefile.in 8 Nov 2002 20:48:54 -0000 1.278
> +++ Makefile.in 9 Nov 2002 00:33:14 -0000
> @@ -166,12 +166,12 @@
> #
> SUBDIR_MI_OBS = \
> mi-out.o mi-console.o \
> - mi-cmds.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
> + mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
> mi-cmd-disas.o \
> mi-main.o mi-parse.o mi-getopt.o
> SUBDIR_MI_SRCS = \
> mi/mi-out.c mi/mi-console.c \
> - mi/mi-cmds.c \
> + mi/mi-cmds.c mi/mi-cmd-env.c \
> mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
> mi/mi-cmd-disas.c \
> mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
> @@ -2487,6 +2487,10 @@
> mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
> $(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h) $(disasm_h)
> $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
> +mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
> + $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(inferior.h) \
> + $(mi_getopt_h)
> + $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-env.c
> mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
> $(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h)
> $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
> Index: mi/mi-cmd-env.c
> ===================================================================
> RCS file: mi/mi-cmd-env.c
> diff -N mi/mi-cmd-env.c
> --- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
> +++ mi/mi-cmd-env.c 9 Nov 2002 00:33:14 -0000
> @@ -0,0 +1,202 @@
> +/* MI Command Set - environment commands.
> + Copyright 2002 Free Software Foundation, Inc.
> + Contributed by Red Hat Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place - Suite 330,
> + Boston, MA 02111-1307, USA. */
> +
> +#include <string.h>
> +#include <sys/stat.h>
> +
> +#include "defs.h"
> +#include "target.h"
> +#include "frame.h"
> +#include "value.h"
> +#include "mi-cmds.h"
> +#include "mi-out.h"
> +#include "mi-getopt.h"
> +#include "ui-out.h"
> +#include "symtab.h"
> +#include "filenames.h"
> +#include "environ.h"
> +#include "command.h"
> +#include "top.h"
> +#include "inferior.h"
> +
Are all these includes needed? they are not listed in the Makefile
dependencies.
> +static void env_cli_command (const char *cli, char *args);
> +static void env_mod_path (char *dirname, char **which_path);
> +
> +static const char path_var_name[] = "PATH";
> +
> +/* The following is copied from mi-main.c so for m1 and below we
> + can perform old behavior and use cli commands. */
> +static void
> +env_execute_cli_command (const char *cli, char *args)
> +{
> + if (cli != 0)
> + {
> + struct cleanup *old_cleanups;
> + char *run;
> + xasprintf (&run, cli, args);
> + old_cleanups = make_cleanup (xfree, run);
> + execute_command ( /*ui */ run, 0 /*from_tty */ );
> + do_cleanups (old_cleanups);
> + return;
> + }
> +}
> +
> +
> +/* Print working directory. */
> +enum mi_cmd_result
> +mi_cmd_env_pwd (char *command, char **argv, int argc)
> +{
> + if (argc > 0)
> + error ("mi_cmd_env_pwd: No arguments required");
> +
> + if (mi_version (uiout) < 2)
> + {
> + env_execute_cli_command ("pwd", NULL);
> + return MI_CMD_DONE;
> + }
> +
> + /* Otherwise the mi level is 2 or higher. */
> +
> + getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
> + ui_out_field_string (uiout, "cwd", gdb_dirbuf);
> +
> + return MI_CMD_DONE;
> +}
> +
> +/* Change working directory. */
> +enum mi_cmd_result
> +mi_cmd_env_cd (char *command, char **argv, int argc)
> +{
> + if (argc == 0 || argc > 1)
> + error ("mi_cmd_env_cd: Usage DIRECTORY");
> +
> + env_execute_cli_command ("cd %s", argv[0]);
> +
> + return MI_CMD_DONE;
> +}
> +
> +static void
> +env_mod_path (char *dirname, char **which_path)
> +{
> + if (dirname == 0 || dirname[0] == '\0')
> + return;
> +
> + /* Call add_path with last arg 0 to indicate not to parse for
> + separator characters. */
> + add_path (dirname, which_path, 0);
> +}
> +
> +/* Add one or more directories to start of executable search path. */
> +enum mi_cmd_result
> +mi_cmd_env_path (char *command, char **argv, int argc)
> +{
> + char *exec_path;
> + char *env;
> + int i;
> +
> + if (mi_version (uiout) < 2)
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_execute_cli_command ("path %s", argv[i]);
> + return MI_CMD_DONE;
> + }
> +
> + /* Otherwise the mi level is 2 or higher. */
> + dont_repeat ();
> + env = get_in_environ (inferior_environ, path_var_name);
> +
> + /* Can be null if path is not set. */
> + if (!env)
> + env = "";
> + exec_path = xstrdup (env);
> +
> + for (i = argc - 1; i >= 0; --i)
> + env_mod_path (argv[i], &exec_path);
> +
Could you add a -reset option here too? We might as well have some symmetry.
> + set_in_environ (inferior_environ, path_var_name, exec_path);
> + xfree (exec_path);
> + env = get_in_environ (inferior_environ, path_var_name);
> + ui_out_field_string (uiout, "path", env);
> +
> + return MI_CMD_DONE;
> +}
> +
> +/* Add zero or more directories to the front of the source path. */
> +enum mi_cmd_result
> +mi_cmd_env_dir (char *command, char **argv, int argc)
> +{
> + int i;
> + int optind = 0;
> + int reset = 0;
> + char *optarg;
> + enum opt
> + {
> + RESET_OPT
> + };
> + static struct mi_opt opts[] =
> + {
> + {"r", RESET_OPT, 0},
> + 0
> + };
> +
> + dont_repeat ();
> +
> + if (mi_version (uiout) < 2)
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_execute_cli_command ("dir %s", argv[i]);
> + return MI_CMD_DONE;
> + }
> +
> + /* Otherwise mi level is 2 or higher. */
> + while (1)
> + {
> + int opt = mi_getopt ("mi_cmd_data_read_memory", argc, argv, opts,
^^^^^^^^^^^^^^^^^^^^^^^
> + &optind, &optarg);
> + if (opt < 0)
> + break;
> + switch ((enum opt) opt)
> + {
> + case RESET_OPT:
> + reset = 1;
> + break;
> + }
> + }
> + argv += optind;
> + argc -= optind;
> +
> + if (reset)
> + {
> + /* No args implies reset to default path. */
> + xfree (source_path);
> + init_source_path ();
> + }
> +
> + for (i = argc - 1; i >= 0; --i)
> + env_mod_path (argv[i], &source_path);
> + init_last_source_visited ();
> +
> + ui_out_field_string (uiout, "source-path", source_path);
> + forget_cached_source_info ();
> +
> + return MI_CMD_DONE;
> +}
> +
> Index: mi/mi-cmds.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> retrieving revision 1.5
> diff -u -r1.5 mi-cmds.h
> --- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
> +++ mi/mi-cmds.h 9 Nov 2002 00:33:14 -0000
> @@ -64,6 +64,10 @@
> extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
> extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
> extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
> +extern mi_cmd_argv_ftype mi_cmd_env_cd;
> +extern mi_cmd_argv_ftype mi_cmd_env_dir;
> +extern mi_cmd_argv_ftype mi_cmd_env_path;
> +extern mi_cmd_argv_ftype mi_cmd_env_pwd;
> extern mi_cmd_args_ftype mi_cmd_exec_continue;
> extern mi_cmd_args_ftype mi_cmd_exec_finish;
> extern mi_cmd_args_ftype mi_cmd_exec_next;
> Index: mi/mi-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> retrieving revision 1.8
> diff -u -r1.8 mi-cmds.c
> --- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
> +++ mi/mi-cmds.c 9 Nov 2002 00:33:14 -0000
> @@ -56,10 +56,10 @@
> {"display-enable", 0, 0},
> {"display-insert", 0, 0},
> {"display-list", 0, 0},
> - {"environment-cd", "cd %s", 0},
> - {"environment-directory", "dir %s", 0},
> - {"environment-path", "path %s", 0},
> - {"environment-pwd", "pwd", 0},
> + {"environment-cd", 0, 0, mi_cmd_env_cd},
> + {"environment-directory", 0, 0, mi_cmd_env_dir},
> + {"environment-path", 0, 0, mi_cmd_env_path},
> + {"environment-pwd", 0, 0, mi_cmd_env_pwd},
> {"exec-abort", 0, 0},
> {"exec-arguments", "set args %s", 0},
> {"exec-continue", 0, mi_cmd_exec_continue},
> Index: gdbmi.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
> retrieving revision 1.29
> diff -u -r1.29 gdbmi.texinfo
> --- gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
> +++ gdbmi.texinfo 9 Nov 2002 00:30:50 -0000
> @@ -1665,10 +1665,18 @@
> @subsubheading Synopsis
>
> @example
> - -environment-directory @var{pathdir}
> + -environment-directory [ -r ] [ @var{pathdir} ]+
> @end example
>
> -Add directory @var{pathdir} to beginning of search path for source files.
> +Add directories @var{pathdir} to beginning of search path for source files.
> +If the @samp{-r} option is used, the search path is reset to the default
> +search path. If directories @var{pathdir} are supplied in addition to the
> +@samp{-r} option, the search path is first reset and then addition
> +occurs as normal.
> +Specifying multiple directories in a single command
> +results in the directories added to the beginning of the
> +search path in the same order they were presented in the command.
> +If no directories are specified, the current search path is displayed.
>
> @subsubheading @value{GDBN} Command
>
> @@ -1679,7 +1687,16 @@
> @smallexample
> (@value{GDBP})
> -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
> -^done
> +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory ""
> +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory -r /home/jjohnstn/src/gdb
> +^done,source-path="/home/jjohnstn/src/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory -r
> +^done,source-path="$cdir:$cwd"
> (@value{GDBP})
> @end smallexample
>
> @@ -1690,10 +1707,12 @@
> @subsubheading Synopsis
>
> @example
> - -environment-path ( @var{pathdir} )+
> + -environment-path [ @var{pathdir} ]+
> @end example
>
> Add directories @var{pathdir} to beginning of search path for object files.
> +If no paths or an empty path is specified, the current object search path
> +is displayed with no modification.
>
> @subsubheading @value{GDBN} Command
>
> @@ -1704,7 +1723,10 @@
> @smallexample
> (@value{GDBP})
> -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
> -^done
> +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> +(@value{GDBP})
> +-environment-path
> +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> (@value{GDBP})
> @end smallexample
>
> @@ -1729,8 +1751,7 @@
> @smallexample
> (@value{GDBP})
> -environment-pwd
> -~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
> -^done
> +^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
> (@value{GDBP})
> @end smallexample
>
> Index: mi-basics.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
> retrieving revision 1.6
> diff -u -r1.6 mi-basics.exp
> --- mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
> +++ mi-basics.exp 11 Nov 2002 21:11:07 -0000
> @@ -148,26 +148,52 @@
> global srcdir
> global subdir
>
> - # Clear the search directories, then specify one to be searched
> + # Add to the search directories, display, then reset back to default
> # Tests:
> - # -environment-directory
> # -environment-directory arg
> + # -environment-directory
> + # -environment-directory -r
>
> #exp_internal 1
> - mi_gdb_test "202-environment-directory" \
> - "\\\^done" \
> + mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
> + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> + "environment-directory arg operation"
> +
> + mi_gdb_test "203-environment-directory" \
> + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> + "environment-directory empty-string operation"
> +
> + mi_gdb_test "204-environment-directory -r" \
> + "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
> "environment-directory operation"
>
> - mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
> - "\\\^done" \
> - "environment-directory arg operation"
> #exp_internal 0
> }
>
> +proc test_cwd_specification {} {
> + global mi_gdb_prompt
> + global objdir
> + global subdir
> +
> + # Change the working directory, then print the current working directory
> + # Tests:
> + # -environment-cd ${objdir}
> + # -environment-pwd
> +
> + mi_gdb_test "205-environment-cd ${objdir}" \
> + "\\\^done" \
> + "environment-cd arg operation"
> +
> + mi_gdb_test "206-environment-pwd" \
> + "\\\^done,cwd=\"${objdir}\"" \
> + "environment-pwd operation"
> +}
> +
> if [test_mi_interpreter_selection] {
> test_exec_and_symbol_mi_operatons
> test_breakpoints_deletion
> test_dir_specification
> + test_cwd_specification
> }
>
> mi_gdb_exit
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-12-06 7:34 ` Elena Zannoni
@ 2002-12-09 17:05 ` J. Johnston
2002-12-09 20:59 ` Elena Zannoni
2002-12-09 22:17 ` Eli Zaretskii
0 siblings, 2 replies; 17+ messages in thread
From: J. Johnston @ 2002-12-09 17:05 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches, eliz
[-- Attachment #1: Type: text/plain, Size: 22063 bytes --]
No problem. Hopefully the last iteration. I added the
reset option to -environment-path and also added new tests
to mi-basics.exp. The Makefile.in has been cleaned
up properly w/r the header files and I fixed the typo you noticed
in the call to mi_getopt.
Ok to commit?
-- Jeff J.
gdb/ChangeLog:
2002-12-09 Jeff Johnston <jjohnstn@redhat.com>
* defs.h (init_last_source_visited): New prototype.
(add_path): Ditto.
* source.c (add_path): New function that adds to a specified path.
(mod_path): Change to call add_path.
(init_last_source_visited): New function to allow interfaces to
initialize static variable: last_source_visited. Part of fix
for PR gdb/741.
* Makefile.in: Add support for mi/mi-cmd-env.c.
gdb/mi/ChangeLog:
2002-12-09 Jeff Johnston <jjohnstn@redhat.com>
* mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
(-environment-cd): Change to use mi_cmd_env_cd,.
(-environment-pwd): Change to use mi_cmd_env_pwd.
(-environment-path): Change to use mi_cmd_env_path.
* mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
(mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
* mi-cmd-env.c: New file. Part of fix for PR gdb/741.
* gdbmi.texinfo (environment-cd): Update output and example.
(environment-pwd): Ditto.
(environment-dir): Update output, description, and examples.
(environment-path): Ditto.
gdb/testsuite/gdb.mi/ChangeLog:
2002-12-09 Jeff Johnston <jjohnstn@redhat.com>
* mi-basics.exp: Change tests for -environment-directory. Also add
tests for -environment-cd, -environment-pwd, and -environment-path.
Part of fix for PR gdb/741.
Elena Zannoni wrote:
> J. Johnston writes:
> >
>
> Ok I noticed a few more things in mi-cmd-env.c, the rest is ok.
>
> Sorry, another iteration....
>
> See below.
>
>
>
> > gdb/ChangeLog:
> >
> > 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
> >
> > * defs.h (init_last_source_visited): New prototype.
> > (add_path): Ditto.
> > * source.c (add_path): New function that adds to a specified path.
> > (mod_path): Change to call add_path.
> > (init_last_source_visited): New function to allow interfaces to
> > initialize static variable: last_source_visited. Part of fix
> > for PR gdb/741.
> > * Makefile.in: Add support for mi/mi-cmd-env.c.
> >
> > gdb/mi/ChangeLog:
> >
> > 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
> >
> > * mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
> > (-environment-cd): Change to use mi_cmd_env_cd,.
> > (-environment-pwd): Change to use mi_cmd_env_pwd.
> > (-environment-path): Change to use mi_cmd_env_path.
> > * mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
> > (mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
> > * mi-cmd-env.c: New file. Part of fix for PR gdb/741.
> > * gdbmi.texinfo (environment-cd): Update output and example.
> > (environment-pwd): Ditto.
> > (environment-dir): Update output, description, and examples.
> > (environment-path): Ditto.
> >
> > gdb/testsuite/gdb.mi/ChangeLog:
> >
> > 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
> >
> > * mi-basics.exp: Change tests for -environment-directory. Also add
> > tests for -environment-cd and -environment-pwd. Part of fix for
> > PR gdb/741.Index: defs.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/defs.h,v
> > retrieving revision 1.102
> > diff -u -r1.102 defs.h
> > --- defs.h 15 Oct 2002 02:16:51 -0000 1.102
> > +++ defs.h 9 Nov 2002 00:33:14 -0000
> > @@ -572,9 +572,15 @@
> >
> > extern void mod_path (char *, char **);
> >
> > +extern void add_path (char *, char **, int);
> > +
> > extern void directory_command (char *, int);
> >
> > +extern char *source_path;
> > +
> > extern void init_source_path (void);
> > +
> > +extern void init_last_source_visited (void);
> >
> > extern char *symtab_to_filename (struct symtab *);
> >
> > Index: source.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/source.c,v
> > retrieving revision 1.36
> > diff -u -r1.36 source.c
> > --- source.c 24 Oct 2002 21:02:53 -0000 1.36
> > +++ source.c 9 Nov 2002 00:33:14 -0000
> > @@ -357,6 +357,12 @@
> > forget_cached_source_info ();
> > }
> >
> > +void
> > +init_last_source_visited (void)
> > +{
> > + last_source_visited = NULL;
> > +}
> > +
> > /* Add zero or more directories to the front of the source path. */
> >
> > void
> > @@ -387,6 +393,18 @@
> > void
> > mod_path (char *dirname, char **which_path)
> > {
> > + add_path (dirname, which_path, 1);
> > +}
> > +
> > +/* Workhorse of mod_path. Takes an extra argument to determine
> > + if dirname should be parsed for separators that indicate multiple
> > + directories. This allows for interfaces that pre-parse the dirname
> > + and allow specification of traditional separator characters such
> > + as space or tab. */
> > +
> > +void
> > +add_path (char *dirname, char **which_path, int parse_separators)
> > +{
> > char *old = *which_path;
> > int prefix = 0;
> >
> > @@ -403,9 +421,16 @@
> > struct stat st;
> >
> > {
> > - char *separator = strchr (name, DIRNAME_SEPARATOR);
> > - char *space = strchr (name, ' ');
> > - char *tab = strchr (name, '\t');
> > + char *separator = NULL;
> > + char *space = NULL;
> > + char *tab = NULL;
> > +
> > + if (parse_separators)
> > + {
> > + separator = strchr (name, DIRNAME_SEPARATOR);
> > + space = strchr (name, ' ');
> > + tab = strchr (name, '\t');
> > + }
> >
> > if (separator == 0 && space == 0 && tab == 0)
> > p = dirname = name + strlen (name);
> > @@ -536,7 +561,8 @@
> > tinybuf[0] = DIRNAME_SEPARATOR;
> > tinybuf[1] = '\0';
> >
> > - /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
> > + /* If we have already tacked on a name(s) in this command, be sure they stay
> > + on the front as we tack on some more. */
> > if (prefix)
> > {
> > char *temp, c;
> > Index: Makefile.in
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/Makefile.in,v
> > retrieving revision 1.278
> > diff -u -r1.278 Makefile.in
> > --- Makefile.in 8 Nov 2002 20:48:54 -0000 1.278
> > +++ Makefile.in 9 Nov 2002 00:33:14 -0000
> > @@ -166,12 +166,12 @@
> > #
> > SUBDIR_MI_OBS = \
> > mi-out.o mi-console.o \
> > - mi-cmds.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
> > + mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
> > mi-cmd-disas.o \
> > mi-main.o mi-parse.o mi-getopt.o
> > SUBDIR_MI_SRCS = \
> > mi/mi-out.c mi/mi-console.c \
> > - mi/mi-cmds.c \
> > + mi/mi-cmds.c mi/mi-cmd-env.c \
> > mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
> > mi/mi-cmd-disas.c \
> > mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
> > @@ -2487,6 +2487,10 @@
> > mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
> > $(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h) $(disasm_h)
> > $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
> > +mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
> > + $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(inferior.h) \
> > + $(mi_getopt_h)
> > + $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-env.c
> > mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
> > $(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h)
> > $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
> > Index: mi/mi-cmd-env.c
> > ===================================================================
> > RCS file: mi/mi-cmd-env.c
> > diff -N mi/mi-cmd-env.c
> > --- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
> > +++ mi/mi-cmd-env.c 9 Nov 2002 00:33:14 -0000
> > @@ -0,0 +1,202 @@
> > +/* MI Command Set - environment commands.
> > + Copyright 2002 Free Software Foundation, Inc.
> > + Contributed by Red Hat Inc.
> > +
> > + This file is part of GDB.
> > +
> > + This program is free software; you can redistribute it and/or modify
> > + it under the terms of the GNU General Public License as published by
> > + the Free Software Foundation; either version 2 of the License, or
> > + (at your option) any later version.
> > +
> > + This program is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + GNU General Public License for more details.
> > +
> > + You should have received a copy of the GNU General Public License
> > + along with this program; if not, write to the Free Software
> > + Foundation, Inc., 59 Temple Place - Suite 330,
> > + Boston, MA 02111-1307, USA. */
> > +
> > +#include <string.h>
> > +#include <sys/stat.h>
> > +
> > +#include "defs.h"
> > +#include "target.h"
> > +#include "frame.h"
> > +#include "value.h"
> > +#include "mi-cmds.h"
> > +#include "mi-out.h"
> > +#include "mi-getopt.h"
> > +#include "ui-out.h"
> > +#include "symtab.h"
> > +#include "filenames.h"
> > +#include "environ.h"
> > +#include "command.h"
> > +#include "top.h"
> > +#include "inferior.h"
> > +
>
> Are all these includes needed? they are not listed in the Makefile
> dependencies.
>
>
> > +static void env_cli_command (const char *cli, char *args);
> > +static void env_mod_path (char *dirname, char **which_path);
> > +
> > +static const char path_var_name[] = "PATH";
> > +
> > +/* The following is copied from mi-main.c so for m1 and below we
> > + can perform old behavior and use cli commands. */
> > +static void
> > +env_execute_cli_command (const char *cli, char *args)
> > +{
> > + if (cli != 0)
> > + {
> > + struct cleanup *old_cleanups;
> > + char *run;
> > + xasprintf (&run, cli, args);
> > + old_cleanups = make_cleanup (xfree, run);
> > + execute_command ( /*ui */ run, 0 /*from_tty */ );
> > + do_cleanups (old_cleanups);
> > + return;
> > + }
> > +}
> > +
> > +
> > +/* Print working directory. */
> > +enum mi_cmd_result
> > +mi_cmd_env_pwd (char *command, char **argv, int argc)
> > +{
> > + if (argc > 0)
> > + error ("mi_cmd_env_pwd: No arguments required");
> > +
> > + if (mi_version (uiout) < 2)
> > + {
> > + env_execute_cli_command ("pwd", NULL);
> > + return MI_CMD_DONE;
> > + }
> > +
> > + /* Otherwise the mi level is 2 or higher. */
> > +
> > + getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
> > + ui_out_field_string (uiout, "cwd", gdb_dirbuf);
> > +
> > + return MI_CMD_DONE;
> > +}
> > +
> > +/* Change working directory. */
> > +enum mi_cmd_result
> > +mi_cmd_env_cd (char *command, char **argv, int argc)
> > +{
> > + if (argc == 0 || argc > 1)
> > + error ("mi_cmd_env_cd: Usage DIRECTORY");
> > +
> > + env_execute_cli_command ("cd %s", argv[0]);
> > +
> > + return MI_CMD_DONE;
> > +}
> > +
> > +static void
> > +env_mod_path (char *dirname, char **which_path)
> > +{
> > + if (dirname == 0 || dirname[0] == '\0')
> > + return;
> > +
> > + /* Call add_path with last arg 0 to indicate not to parse for
> > + separator characters. */
> > + add_path (dirname, which_path, 0);
> > +}
> > +
> > +/* Add one or more directories to start of executable search path. */
> > +enum mi_cmd_result
> > +mi_cmd_env_path (char *command, char **argv, int argc)
> > +{
> > + char *exec_path;
> > + char *env;
> > + int i;
> > +
> > + if (mi_version (uiout) < 2)
> > + {
> > + for (i = argc - 1; i >= 0; --i)
> > + env_execute_cli_command ("path %s", argv[i]);
> > + return MI_CMD_DONE;
> > + }
> > +
> > + /* Otherwise the mi level is 2 or higher. */
> > + dont_repeat ();
> > + env = get_in_environ (inferior_environ, path_var_name);
> > +
> > + /* Can be null if path is not set. */
> > + if (!env)
> > + env = "";
> > + exec_path = xstrdup (env);
> > +
> > + for (i = argc - 1; i >= 0; --i)
> > + env_mod_path (argv[i], &exec_path);
> > +
>
>
> Could you add a -reset option here too? We might as well have some symmetry.
>
> > + set_in_environ (inferior_environ, path_var_name, exec_path);
> > + xfree (exec_path);
> > + env = get_in_environ (inferior_environ, path_var_name);
> > + ui_out_field_string (uiout, "path", env);
> > +
> > + return MI_CMD_DONE;
> > +}
> > +
> > +/* Add zero or more directories to the front of the source path. */
> > +enum mi_cmd_result
> > +mi_cmd_env_dir (char *command, char **argv, int argc)
> > +{
> > + int i;
> > + int optind = 0;
> > + int reset = 0;
> > + char *optarg;
> > + enum opt
> > + {
> > + RESET_OPT
> > + };
> > + static struct mi_opt opts[] =
> > + {
> > + {"r", RESET_OPT, 0},
> > + 0
> > + };
> > +
> > + dont_repeat ();
> > +
> > + if (mi_version (uiout) < 2)
> > + {
> > + for (i = argc - 1; i >= 0; --i)
> > + env_execute_cli_command ("dir %s", argv[i]);
> > + return MI_CMD_DONE;
> > + }
> > +
> > + /* Otherwise mi level is 2 or higher. */
> > + while (1)
> > + {
> > + int opt = mi_getopt ("mi_cmd_data_read_memory", argc, argv, opts,
> ^^^^^^^^^^^^^^^^^^^^^^^
>
>
> > + &optind, &optarg);
> > + if (opt < 0)
> > + break;
> > + switch ((enum opt) opt)
> > + {
> > + case RESET_OPT:
> > + reset = 1;
> > + break;
> > + }
> > + }
> > + argv += optind;
> > + argc -= optind;
> > +
> > + if (reset)
> > + {
> > + /* No args implies reset to default path. */
> > + xfree (source_path);
> > + init_source_path ();
> > + }
> > +
> > + for (i = argc - 1; i >= 0; --i)
> > + env_mod_path (argv[i], &source_path);
> > + init_last_source_visited ();
> > +
> > + ui_out_field_string (uiout, "source-path", source_path);
> > + forget_cached_source_info ();
> > +
> > + return MI_CMD_DONE;
> > +}
> > +
> > Index: mi/mi-cmds.h
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> > retrieving revision 1.5
> > diff -u -r1.5 mi-cmds.h
> > --- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
> > +++ mi/mi-cmds.h 9 Nov 2002 00:33:14 -0000
> > @@ -64,6 +64,10 @@
> > extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
> > extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
> > extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
> > +extern mi_cmd_argv_ftype mi_cmd_env_cd;
> > +extern mi_cmd_argv_ftype mi_cmd_env_dir;
> > +extern mi_cmd_argv_ftype mi_cmd_env_path;
> > +extern mi_cmd_argv_ftype mi_cmd_env_pwd;
> > extern mi_cmd_args_ftype mi_cmd_exec_continue;
> > extern mi_cmd_args_ftype mi_cmd_exec_finish;
> > extern mi_cmd_args_ftype mi_cmd_exec_next;
> > Index: mi/mi-cmds.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> > retrieving revision 1.8
> > diff -u -r1.8 mi-cmds.c
> > --- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
> > +++ mi/mi-cmds.c 9 Nov 2002 00:33:14 -0000
> > @@ -56,10 +56,10 @@
> > {"display-enable", 0, 0},
> > {"display-insert", 0, 0},
> > {"display-list", 0, 0},
> > - {"environment-cd", "cd %s", 0},
> > - {"environment-directory", "dir %s", 0},
> > - {"environment-path", "path %s", 0},
> > - {"environment-pwd", "pwd", 0},
> > + {"environment-cd", 0, 0, mi_cmd_env_cd},
> > + {"environment-directory", 0, 0, mi_cmd_env_dir},
> > + {"environment-path", 0, 0, mi_cmd_env_path},
> > + {"environment-pwd", 0, 0, mi_cmd_env_pwd},
> > {"exec-abort", 0, 0},
> > {"exec-arguments", "set args %s", 0},
> > {"exec-continue", 0, mi_cmd_exec_continue},
> > Index: gdbmi.texinfo
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
> > retrieving revision 1.29
> > diff -u -r1.29 gdbmi.texinfo
> > --- gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
> > +++ gdbmi.texinfo 9 Nov 2002 00:30:50 -0000
> > @@ -1665,10 +1665,18 @@
> > @subsubheading Synopsis
> >
> > @example
> > - -environment-directory @var{pathdir}
> > + -environment-directory [ -r ] [ @var{pathdir} ]+
> > @end example
> >
> > -Add directory @var{pathdir} to beginning of search path for source files.
> > +Add directories @var{pathdir} to beginning of search path for source files.
> > +If the @samp{-r} option is used, the search path is reset to the default
> > +search path. If directories @var{pathdir} are supplied in addition to the
> > +@samp{-r} option, the search path is first reset and then addition
> > +occurs as normal.
> > +Specifying multiple directories in a single command
> > +results in the directories added to the beginning of the
> > +search path in the same order they were presented in the command.
> > +If no directories are specified, the current search path is displayed.
> >
> > @subsubheading @value{GDBN} Command
> >
> > @@ -1679,7 +1687,16 @@
> > @smallexample
> > (@value{GDBP})
> > -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
> > -^done
> > +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> > +(@value{GDBP})
> > +-environment-directory ""
> > +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> > +(@value{GDBP})
> > +-environment-directory -r /home/jjohnstn/src/gdb
> > +^done,source-path="/home/jjohnstn/src/gdb:$cdir:$cwd"
> > +(@value{GDBP})
> > +-environment-directory -r
> > +^done,source-path="$cdir:$cwd"
> > (@value{GDBP})
> > @end smallexample
> >
> > @@ -1690,10 +1707,12 @@
> > @subsubheading Synopsis
> >
> > @example
> > - -environment-path ( @var{pathdir} )+
> > + -environment-path [ @var{pathdir} ]+
> > @end example
> >
> > Add directories @var{pathdir} to beginning of search path for object files.
> > +If no paths or an empty path is specified, the current object search path
> > +is displayed with no modification.
> >
> > @subsubheading @value{GDBN} Command
> >
> > @@ -1704,7 +1723,10 @@
> > @smallexample
> > (@value{GDBP})
> > -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
> > -^done
> > +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> > +(@value{GDBP})
> > +-environment-path
> > +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> > (@value{GDBP})
> > @end smallexample
> >
> > @@ -1729,8 +1751,7 @@
> > @smallexample
> > (@value{GDBP})
> > -environment-pwd
> > -~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
> > -^done
> > +^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
> > (@value{GDBP})
> > @end smallexample
> >
> > Index: mi-basics.exp
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
> > retrieving revision 1.6
> > diff -u -r1.6 mi-basics.exp
> > --- mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
> > +++ mi-basics.exp 11 Nov 2002 21:11:07 -0000
> > @@ -148,26 +148,52 @@
> > global srcdir
> > global subdir
> >
> > - # Clear the search directories, then specify one to be searched
> > + # Add to the search directories, display, then reset back to default
> > # Tests:
> > - # -environment-directory
> > # -environment-directory arg
> > + # -environment-directory
> > + # -environment-directory -r
> >
> > #exp_internal 1
> > - mi_gdb_test "202-environment-directory" \
> > - "\\\^done" \
> > + mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
> > + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> > + "environment-directory arg operation"
> > +
> > + mi_gdb_test "203-environment-directory" \
> > + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> > + "environment-directory empty-string operation"
> > +
> > + mi_gdb_test "204-environment-directory -r" \
> > + "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
> > "environment-directory operation"
> >
> > - mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
> > - "\\\^done" \
> > - "environment-directory arg operation"
> > #exp_internal 0
> > }
> >
> > +proc test_cwd_specification {} {
> > + global mi_gdb_prompt
> > + global objdir
> > + global subdir
> > +
> > + # Change the working directory, then print the current working directory
> > + # Tests:
> > + # -environment-cd ${objdir}
> > + # -environment-pwd
> > +
> > + mi_gdb_test "205-environment-cd ${objdir}" \
> > + "\\\^done" \
> > + "environment-cd arg operation"
> > +
> > + mi_gdb_test "206-environment-pwd" \
> > + "\\\^done,cwd=\"${objdir}\"" \
> > + "environment-pwd operation"
> > +}
> > +
> > if [test_mi_interpreter_selection] {
> > test_exec_and_symbol_mi_operatons
> > test_breakpoints_deletion
> > test_dir_specification
> > + test_cwd_specification
> > }
> >
> > mi_gdb_exit
[-- Attachment #2: 741.patch1 --]
[-- Type: text/plain, Size: 3925 bytes --]
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.102
diff -u -r1.102 defs.h
--- defs.h 15 Oct 2002 02:16:51 -0000 1.102
+++ defs.h 10 Dec 2002 00:15:26 -0000
@@ -572,9 +572,15 @@
extern void mod_path (char *, char **);
+extern void add_path (char *, char **, int);
+
extern void directory_command (char *, int);
+extern char *source_path;
+
extern void init_source_path (void);
+
+extern void init_last_source_visited (void);
extern char *symtab_to_filename (struct symtab *);
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.36
diff -u -r1.36 source.c
--- source.c 24 Oct 2002 21:02:53 -0000 1.36
+++ source.c 10 Dec 2002 00:15:26 -0000
@@ -357,6 +357,12 @@
forget_cached_source_info ();
}
+void
+init_last_source_visited (void)
+{
+ last_source_visited = NULL;
+}
+
/* Add zero or more directories to the front of the source path. */
void
@@ -387,6 +393,18 @@
void
mod_path (char *dirname, char **which_path)
{
+ add_path (dirname, which_path, 1);
+}
+
+/* Workhorse of mod_path. Takes an extra argument to determine
+ if dirname should be parsed for separators that indicate multiple
+ directories. This allows for interfaces that pre-parse the dirname
+ and allow specification of traditional separator characters such
+ as space or tab. */
+
+void
+add_path (char *dirname, char **which_path, int parse_separators)
+{
char *old = *which_path;
int prefix = 0;
@@ -403,9 +421,16 @@
struct stat st;
{
- char *separator = strchr (name, DIRNAME_SEPARATOR);
- char *space = strchr (name, ' ');
- char *tab = strchr (name, '\t');
+ char *separator = NULL;
+ char *space = NULL;
+ char *tab = NULL;
+
+ if (parse_separators)
+ {
+ separator = strchr (name, DIRNAME_SEPARATOR);
+ space = strchr (name, ' ');
+ tab = strchr (name, '\t');
+ }
if (separator == 0 && space == 0 && tab == 0)
p = dirname = name + strlen (name);
@@ -536,7 +561,8 @@
tinybuf[0] = DIRNAME_SEPARATOR;
tinybuf[1] = '\0';
- /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
+ /* If we have already tacked on a name(s) in this command, be sure they stay
+ on the front as we tack on some more. */
if (prefix)
{
char *temp, c;
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.290
diff -u -r1.290 Makefile.in
--- Makefile.in 5 Dec 2002 05:17:39 -0000 1.290
+++ Makefile.in 10 Dec 2002 00:15:26 -0000
@@ -168,12 +168,12 @@
#
SUBDIR_MI_OBS = \
mi-out.o mi-console.o \
- mi-cmds.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
+ mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
mi-cmd-disas.o \
mi-main.o mi-parse.o mi-getopt.o
SUBDIR_MI_SRCS = \
mi/mi-out.c mi/mi-console.c \
- mi/mi-cmds.c \
+ mi/mi-cmds.c mi/mi-cmd-env.c \
mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
mi/mi-cmd-disas.c \
mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
@@ -2526,6 +2526,10 @@
mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
$(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h) $(disasm_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
+mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
+ $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(inferior.h) \
+ $(mi_getopt_h) $(environ_h) $(gdbcmd_h) $(top_h)
+ $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-env.c
mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
$(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
[-- Attachment #3: 741.patch2 --]
[-- Type: text/plain, Size: 7949 bytes --]
Index: mi-cmd-env.c
===================================================================
RCS file: mi-cmd-env.c
diff -N mi-cmd-env.c
--- mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
+++ mi-cmd-env.c 10 Dec 2002 00:16:45 -0000
@@ -0,0 +1,254 @@
+/* MI Command Set - environment commands.
+ Copyright 2002 Free Software Foundation, Inc.
+ Contributed by Red Hat Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <string.h>
+#include <sys/stat.h>
+
+#include "defs.h"
+#include "inferior.h"
+#include "value.h"
+#include "mi-out.h"
+#include "mi-cmds.h"
+#include "mi-getopt.h"
+#include "symtab.h"
+#include "target.h"
+#include "environ.h"
+#include "command.h"
+#include "ui-out.h"
+#include "top.h"
+
+static void env_cli_command (const char *cli, char *args);
+static void env_mod_path (char *dirname, char **which_path);
+extern void _initialize_mi_cmd_env (void);
+
+static const char path_var_name[] = "PATH";
+static char *orig_path = NULL;
+
+/* The following is copied from mi-main.c so for m1 and below we
+ can perform old behavior and use cli commands. */
+static void
+env_execute_cli_command (const char *cli, char *args)
+{
+ if (cli != 0)
+ {
+ struct cleanup *old_cleanups;
+ char *run;
+ xasprintf (&run, cli, args);
+ old_cleanups = make_cleanup (xfree, run);
+ execute_command ( /*ui */ run, 0 /*from_tty */ );
+ do_cleanups (old_cleanups);
+ return;
+ }
+}
+
+
+/* Print working directory. */
+enum mi_cmd_result
+mi_cmd_env_pwd (char *command, char **argv, int argc)
+{
+ if (argc > 0)
+ error ("mi_cmd_env_pwd: No arguments required");
+
+ if (mi_version (uiout) < 2)
+ {
+ env_execute_cli_command ("pwd", NULL);
+ return MI_CMD_DONE;
+ }
+
+ /* Otherwise the mi level is 2 or higher. */
+
+ getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+ ui_out_field_string (uiout, "cwd", gdb_dirbuf);
+
+ return MI_CMD_DONE;
+}
+
+/* Change working directory. */
+enum mi_cmd_result
+mi_cmd_env_cd (char *command, char **argv, int argc)
+{
+ if (argc == 0 || argc > 1)
+ error ("mi_cmd_env_cd: Usage DIRECTORY");
+
+ env_execute_cli_command ("cd %s", argv[0]);
+
+ return MI_CMD_DONE;
+}
+
+static void
+env_mod_path (char *dirname, char **which_path)
+{
+ if (dirname == 0 || dirname[0] == '\0')
+ return;
+
+ /* Call add_path with last arg 0 to indicate not to parse for
+ separator characters. */
+ add_path (dirname, which_path, 0);
+}
+
+/* Add one or more directories to start of executable search path. */
+enum mi_cmd_result
+mi_cmd_env_path (char *command, char **argv, int argc)
+{
+ char *exec_path;
+ char *env;
+ int reset = 0;
+ int optind = 0;
+ int i;
+ char *optarg;
+ enum opt
+ {
+ RESET_OPT
+ };
+ static struct mi_opt opts[] =
+ {
+ {"r", RESET_OPT, 0},
+ 0
+ };
+
+ dont_repeat ();
+
+ if (mi_version (uiout) < 2)
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_execute_cli_command ("path %s", argv[i]);
+ return MI_CMD_DONE;
+ }
+
+ /* Otherwise the mi level is 2 or higher. */
+ while (1)
+ {
+ int opt = mi_getopt ("mi_cmd_env_path", argc, argv, opts,
+ &optind, &optarg);
+ if (opt < 0)
+ break;
+ switch ((enum opt) opt)
+ {
+ case RESET_OPT:
+ reset = 1;
+ break;
+ }
+ }
+ argv += optind;
+ argc -= optind;
+
+
+ if (reset)
+ {
+ /* Reset implies resetting to original path first. */
+ exec_path = xstrdup (orig_path);
+ }
+ else
+ {
+ /* Otherwise, get current path to modify. */
+ env = get_in_environ (inferior_environ, path_var_name);
+
+ /* Can be null if path is not set. */
+ if (!env)
+ env = "";
+ exec_path = xstrdup (env);
+ }
+
+ for (i = argc - 1; i >= 0; --i)
+ env_mod_path (argv[i], &exec_path);
+
+ set_in_environ (inferior_environ, path_var_name, exec_path);
+ xfree (exec_path);
+ env = get_in_environ (inferior_environ, path_var_name);
+ ui_out_field_string (uiout, "path", env);
+
+ return MI_CMD_DONE;
+}
+
+/* Add zero or more directories to the front of the source path. */
+enum mi_cmd_result
+mi_cmd_env_dir (char *command, char **argv, int argc)
+{
+ int i;
+ int optind = 0;
+ int reset = 0;
+ char *optarg;
+ enum opt
+ {
+ RESET_OPT
+ };
+ static struct mi_opt opts[] =
+ {
+ {"r", RESET_OPT, 0},
+ 0
+ };
+
+ dont_repeat ();
+
+ if (mi_version (uiout) < 2)
+ {
+ for (i = argc - 1; i >= 0; --i)
+ env_execute_cli_command ("dir %s", argv[i]);
+ return MI_CMD_DONE;
+ }
+
+ /* Otherwise mi level is 2 or higher. */
+ while (1)
+ {
+ int opt = mi_getopt ("mi_cmd_env_dir", argc, argv, opts,
+ &optind, &optarg);
+ if (opt < 0)
+ break;
+ switch ((enum opt) opt)
+ {
+ case RESET_OPT:
+ reset = 1;
+ break;
+ }
+ }
+ argv += optind;
+ argc -= optind;
+
+ if (reset)
+ {
+ /* Reset means setting to default path first. */
+ xfree (source_path);
+ init_source_path ();
+ }
+
+ for (i = argc - 1; i >= 0; --i)
+ env_mod_path (argv[i], &source_path);
+ init_last_source_visited ();
+
+ ui_out_field_string (uiout, "source-path", source_path);
+ forget_cached_source_info ();
+
+ return MI_CMD_DONE;
+}
+
+void
+_initialize_mi_cmd_env (void)
+{
+ char *env;
+
+ /* We want original execution path to reset to, if desired later. */
+ env = get_in_environ (inferior_environ, path_var_name);
+
+ /* Can be null if path is not set. */
+ if (!env)
+ env = "";
+ orig_path = xstrdup (env);
+}
Index: mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.5
diff -u -r1.5 mi-cmds.h
--- mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
+++ mi-cmds.h 10 Dec 2002 00:16:45 -0000
@@ -64,6 +64,10 @@
extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
+extern mi_cmd_argv_ftype mi_cmd_env_cd;
+extern mi_cmd_argv_ftype mi_cmd_env_dir;
+extern mi_cmd_argv_ftype mi_cmd_env_path;
+extern mi_cmd_argv_ftype mi_cmd_env_pwd;
extern mi_cmd_args_ftype mi_cmd_exec_continue;
extern mi_cmd_args_ftype mi_cmd_exec_finish;
extern mi_cmd_args_ftype mi_cmd_exec_next;
Index: mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.8
diff -u -r1.8 mi-cmds.c
--- mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
+++ mi-cmds.c 10 Dec 2002 00:16:45 -0000
@@ -56,10 +56,10 @@
{"display-enable", 0, 0},
{"display-insert", 0, 0},
{"display-list", 0, 0},
- {"environment-cd", "cd %s", 0},
- {"environment-directory", "dir %s", 0},
- {"environment-path", "path %s", 0},
- {"environment-pwd", "pwd", 0},
+ {"environment-cd", 0, 0, mi_cmd_env_cd},
+ {"environment-directory", 0, 0, mi_cmd_env_dir},
+ {"environment-path", 0, 0, mi_cmd_env_path},
+ {"environment-pwd", 0, 0, mi_cmd_env_pwd},
{"exec-abort", 0, 0},
{"exec-arguments", "set args %s", 0},
{"exec-continue", 0, mi_cmd_exec_continue},
[-- Attachment #4: 741test.patch --]
[-- Type: text/plain, Size: 3418 bytes --]
Index: testsuite/gdb.mi/mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.6
diff -u -r1.6 mi-basics.exp
--- testsuite/gdb.mi/mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
+++ testsuite/gdb.mi/mi-basics.exp 10 Dec 2002 00:18:48 -0000
@@ -148,26 +148,98 @@
global srcdir
global subdir
- # Clear the search directories, then specify one to be searched
+ # Add to the search directories, display, then reset back to default
# Tests:
- # -environment-directory
# -environment-directory arg
+ # -environment-directory
+ # -environment-directory -r
#exp_internal 1
- mi_gdb_test "202-environment-directory" \
- "\\\^done" \
+ mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
+ "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
+ "environment-directory arg operation"
+
+ mi_gdb_test "203-environment-directory" \
+ "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
+ "environment-directory empty-string operation"
+
+ mi_gdb_test "204-environment-directory -r" \
+ "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
"environment-directory operation"
- mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
- "\\\^done" \
- "environment-directory arg operation"
#exp_internal 0
}
+proc test_cwd_specification {} {
+ global mi_gdb_prompt
+ global objdir
+ global subdir
+
+ # Change the working directory, then print the current working directory
+ # Tests:
+ # -environment-cd ${objdir}
+ # -environment-pwd
+
+ mi_gdb_test "205-environment-cd ${objdir}" \
+ "\\\^done" \
+ "environment-cd arg operation"
+
+ mi_gdb_test "206-environment-pwd" \
+ "\\\^done,cwd=\"${objdir}\"" \
+ "environment-pwd operation"
+}
+
+proc test_path_specification {} {
+ global mi_gdb_prompt
+ global orig_path
+ global objdir
+ global srcdir
+
+ # Add to the path, display, then reset
+ # Tests:
+ # -environment-path
+ # -environment-path dir1 dir2
+ # -environment-path -r dir
+ # -environment-path -r
+
+#exp_internal 1
+
+ send_gdb "-environment-path\n"
+ gdb_expect 20 {
+ -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" {
+ set orig_path $expect_out(1,string);
+ }
+ timeout {
+ perror "-environment-path (timeout)" ;
+ return
+ }
+ }
+
+ mi_gdb_test "207-environment-path" \
+ "\\\^done,path=\"$orig_path\"" \
+ "environment-path no-args operation"
+
+ mi_gdb_test "208-environment-path $srcdir $objdir" \
+ "\\\^done,path=\"$srcdir:$objdir:$orig_path\"" \
+ "environment-path dir1 dir2 operation"
+
+ mi_gdb_test "209-environment-path -r $objdir" \
+ "\\\^done,path=\"$objdir:$orig_path\"" \
+ "environment-path -r dir operation"
+
+ mi_gdb_test "210-environment-path -r" \
+ "\\\^done,path=\"$orig_path\"" \
+ "environment-path -r operation"
+
+#exp_internal 0
+}
+
if [test_mi_interpreter_selection] {
test_exec_and_symbol_mi_operatons
test_breakpoints_deletion
test_dir_specification
+ test_cwd_specification
+ test_path_specification
}
mi_gdb_exit
[-- Attachment #5: 741.doc.patch --]
[-- Type: text/plain, Size: 3135 bytes --]
Index: gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.30
diff -u -r1.30 gdbmi.texinfo
--- gdbmi.texinfo 11 Nov 2002 17:09:50 -0000 1.30
+++ gdbmi.texinfo 10 Dec 2002 00:12:25 -0000
@@ -1665,10 +1665,18 @@
@subsubheading Synopsis
@example
- -environment-directory @var{pathdir}
+ -environment-directory [ -r ] [ @var{pathdir} ]+
@end example
-Add directory @var{pathdir} to beginning of search path for source files.
+Add directories @var{pathdir} to beginning of search path for source files.
+If the @samp{-r} option is used, the search path is reset to the default
+search path. If directories @var{pathdir} are supplied in addition to the
+@samp{-r} option, the search path is first reset and then addition
+occurs as normal.
+Specifying multiple directories in a single command
+results in the directories added to the beginning of the
+search path in the same order they were presented in the command.
+If no directories are specified, the current search path is displayed.
@subsubheading @value{GDBN} Command
@@ -1679,7 +1687,16 @@
@smallexample
(@value{GDBP})
-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
-^done
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory ""
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory -r /home/jjohnstn/src/gdb
+^done,source-path="/home/jjohnstn/src/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory -r
+^done,source-path="$cdir:$cwd"
(@value{GDBP})
@end smallexample
@@ -1690,10 +1707,19 @@
@subsubheading Synopsis
@example
- -environment-path ( @var{pathdir} )+
+ -environment-path [ -r ] [ @var{pathdir} ]+
@end example
Add directories @var{pathdir} to beginning of search path for object files.
+If the @samp{-r} option is used, the search path is reset to the original
+search path that existed at gdb start-up. If directories @var{pathdir} are
+supplied in addition to the
+@samp{-r} option, the search path is first reset and then addition
+occurs as normal.
+Specifying multiple directories in a single command
+results in the directories added to the beginning of the
+search path in the same order they were presented in the command.
+If no directories are specified, the current path is displayed.
@subsubheading @value{GDBN} Command
@@ -1703,8 +1729,14 @@
@smallexample
(@value{GDBP})
+-environment-path
+^done,path="/usr/bin"
+(@value{GDBP})
-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
-^done
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
+(@value{GDBP})
+-environment-path -r /usr/local/bin
+^done,path="/usr/local/bin:/usr/bin"
(@value{GDBP})
@end smallexample
@@ -1729,8 +1761,7 @@
@smallexample
(@value{GDBP})
-environment-pwd
-~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
-^done
+^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
(@value{GDBP})
@end smallexample
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-12-09 17:05 ` J. Johnston
@ 2002-12-09 20:59 ` Elena Zannoni
2002-12-09 22:17 ` Eli Zaretskii
1 sibling, 0 replies; 17+ messages in thread
From: Elena Zannoni @ 2002-12-09 20:59 UTC (permalink / raw)
To: J. Johnston; +Cc: Elena Zannoni, gdb-patches, eliz
J. Johnston writes:
> No problem. Hopefully the last iteration. I added the
> reset option to -environment-path and also added new tests
> to mi-basics.exp. The Makefile.in has been cleaned
> up properly w/r the header files and I fixed the typo you noticed
> in the call to mi_getopt.
>
> Ok to commit?
Yep.
thanks
Elena
>
> -- Jeff J.
>
> gdb/ChangeLog:
>
> 2002-12-09 Jeff Johnston <jjohnstn@redhat.com>
>
> * defs.h (init_last_source_visited): New prototype.
> (add_path): Ditto.
> * source.c (add_path): New function that adds to a specified path.
> (mod_path): Change to call add_path.
> (init_last_source_visited): New function to allow interfaces to
> initialize static variable: last_source_visited. Part of fix
> for PR gdb/741.
> * Makefile.in: Add support for mi/mi-cmd-env.c.
>
> gdb/mi/ChangeLog:
>
> 2002-12-09 Jeff Johnston <jjohnstn@redhat.com>
>
> * mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
> (-environment-cd): Change to use mi_cmd_env_cd,.
> (-environment-pwd): Change to use mi_cmd_env_pwd.
> (-environment-path): Change to use mi_cmd_env_path.
> * mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
> (mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
> * mi-cmd-env.c: New file. Part of fix for PR gdb/741.
> * gdbmi.texinfo (environment-cd): Update output and example.
> (environment-pwd): Ditto.
> (environment-dir): Update output, description, and examples.
> (environment-path): Ditto.
>
> gdb/testsuite/gdb.mi/ChangeLog:
>
> 2002-12-09 Jeff Johnston <jjohnstn@redhat.com>
>
> * mi-basics.exp: Change tests for -environment-directory. Also add
> tests for -environment-cd, -environment-pwd, and -environment-path.
> Part of fix for PR gdb/741.
>
> Elena Zannoni wrote:
> > J. Johnston writes:
> > >
> >
> > Ok I noticed a few more things in mi-cmd-env.c, the rest is ok.
> >
> > Sorry, another iteration....
> >
> > See below.
> >
> >
> >
> > > gdb/ChangeLog:
> > >
> > > 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
> > >
> > > * defs.h (init_last_source_visited): New prototype.
> > > (add_path): Ditto.
> > > * source.c (add_path): New function that adds to a specified path.
> > > (mod_path): Change to call add_path.
> > > (init_last_source_visited): New function to allow interfaces to
> > > initialize static variable: last_source_visited. Part of fix
> > > for PR gdb/741.
> > > * Makefile.in: Add support for mi/mi-cmd-env.c.
> > >
> > > gdb/mi/ChangeLog:
> > >
> > > 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
> > >
> > > * mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir,
> > > (-environment-cd): Change to use mi_cmd_env_cd,.
> > > (-environment-pwd): Change to use mi_cmd_env_pwd.
> > > (-environment-path): Change to use mi_cmd_env_path.
> > > * mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes.
> > > (mi_cmd_env_path, mi_cmd_env_pwd): Ditto.
> > > * mi-cmd-env.c: New file. Part of fix for PR gdb/741.
> > > * gdbmi.texinfo (environment-cd): Update output and example.
> > > (environment-pwd): Ditto.
> > > (environment-dir): Update output, description, and examples.
> > > (environment-path): Ditto.
> > >
> > > gdb/testsuite/gdb.mi/ChangeLog:
> > >
> > > 2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
> > >
> > > * mi-basics.exp: Change tests for -environment-directory. Also add
> > > tests for -environment-cd and -environment-pwd. Part of fix for
> > > PR gdb/741.Index: defs.h
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/defs.h,v
> > > retrieving revision 1.102
> > > diff -u -r1.102 defs.h
> > > --- defs.h 15 Oct 2002 02:16:51 -0000 1.102
> > > +++ defs.h 9 Nov 2002 00:33:14 -0000
> > > @@ -572,9 +572,15 @@
> > >
> > > extern void mod_path (char *, char **);
> > >
> > > +extern void add_path (char *, char **, int);
> > > +
> > > extern void directory_command (char *, int);
> > >
> > > +extern char *source_path;
> > > +
> > > extern void init_source_path (void);
> > > +
> > > +extern void init_last_source_visited (void);
> > >
> > > extern char *symtab_to_filename (struct symtab *);
> > >
> > > Index: source.c
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/source.c,v
> > > retrieving revision 1.36
> > > diff -u -r1.36 source.c
> > > --- source.c 24 Oct 2002 21:02:53 -0000 1.36
> > > +++ source.c 9 Nov 2002 00:33:14 -0000
> > > @@ -357,6 +357,12 @@
> > > forget_cached_source_info ();
> > > }
> > >
> > > +void
> > > +init_last_source_visited (void)
> > > +{
> > > + last_source_visited = NULL;
> > > +}
> > > +
> > > /* Add zero or more directories to the front of the source path. */
> > >
> > > void
> > > @@ -387,6 +393,18 @@
> > > void
> > > mod_path (char *dirname, char **which_path)
> > > {
> > > + add_path (dirname, which_path, 1);
> > > +}
> > > +
> > > +/* Workhorse of mod_path. Takes an extra argument to determine
> > > + if dirname should be parsed for separators that indicate multiple
> > > + directories. This allows for interfaces that pre-parse the dirname
> > > + and allow specification of traditional separator characters such
> > > + as space or tab. */
> > > +
> > > +void
> > > +add_path (char *dirname, char **which_path, int parse_separators)
> > > +{
> > > char *old = *which_path;
> > > int prefix = 0;
> > >
> > > @@ -403,9 +421,16 @@
> > > struct stat st;
> > >
> > > {
> > > - char *separator = strchr (name, DIRNAME_SEPARATOR);
> > > - char *space = strchr (name, ' ');
> > > - char *tab = strchr (name, '\t');
> > > + char *separator = NULL;
> > > + char *space = NULL;
> > > + char *tab = NULL;
> > > +
> > > + if (parse_separators)
> > > + {
> > > + separator = strchr (name, DIRNAME_SEPARATOR);
> > > + space = strchr (name, ' ');
> > > + tab = strchr (name, '\t');
> > > + }
> > >
> > > if (separator == 0 && space == 0 && tab == 0)
> > > p = dirname = name + strlen (name);
> > > @@ -536,7 +561,8 @@
> > > tinybuf[0] = DIRNAME_SEPARATOR;
> > > tinybuf[1] = '\0';
> > >
> > > - /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
> > > + /* If we have already tacked on a name(s) in this command, be sure they stay
> > > + on the front as we tack on some more. */
> > > if (prefix)
> > > {
> > > char *temp, c;
> > > Index: Makefile.in
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/Makefile.in,v
> > > retrieving revision 1.278
> > > diff -u -r1.278 Makefile.in
> > > --- Makefile.in 8 Nov 2002 20:48:54 -0000 1.278
> > > +++ Makefile.in 9 Nov 2002 00:33:14 -0000
> > > @@ -166,12 +166,12 @@
> > > #
> > > SUBDIR_MI_OBS = \
> > > mi-out.o mi-console.o \
> > > - mi-cmds.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
> > > + mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
> > > mi-cmd-disas.o \
> > > mi-main.o mi-parse.o mi-getopt.o
> > > SUBDIR_MI_SRCS = \
> > > mi/mi-out.c mi/mi-console.c \
> > > - mi/mi-cmds.c \
> > > + mi/mi-cmds.c mi/mi-cmd-env.c \
> > > mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
> > > mi/mi-cmd-disas.c \
> > > mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
> > > @@ -2487,6 +2487,10 @@
> > > mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
> > > $(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h) $(disasm_h)
> > > $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
> > > +mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
> > > + $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(inferior.h) \
> > > + $(mi_getopt_h)
> > > + $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-env.c
> > > mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
> > > $(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h)
> > > $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
> > > Index: mi/mi-cmd-env.c
> > > ===================================================================
> > > RCS file: mi/mi-cmd-env.c
> > > diff -N mi/mi-cmd-env.c
> > > --- mi/mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
> > > +++ mi/mi-cmd-env.c 9 Nov 2002 00:33:14 -0000
> > > @@ -0,0 +1,202 @@
> > > +/* MI Command Set - environment commands.
> > > + Copyright 2002 Free Software Foundation, Inc.
> > > + Contributed by Red Hat Inc.
> > > +
> > > + This file is part of GDB.
> > > +
> > > + This program is free software; you can redistribute it and/or modify
> > > + it under the terms of the GNU General Public License as published by
> > > + the Free Software Foundation; either version 2 of the License, or
> > > + (at your option) any later version.
> > > +
> > > + This program is distributed in the hope that it will be useful,
> > > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > > + GNU General Public License for more details.
> > > +
> > > + You should have received a copy of the GNU General Public License
> > > + along with this program; if not, write to the Free Software
> > > + Foundation, Inc., 59 Temple Place - Suite 330,
> > > + Boston, MA 02111-1307, USA. */
> > > +
> > > +#include <string.h>
> > > +#include <sys/stat.h>
> > > +
> > > +#include "defs.h"
> > > +#include "target.h"
> > > +#include "frame.h"
> > > +#include "value.h"
> > > +#include "mi-cmds.h"
> > > +#include "mi-out.h"
> > > +#include "mi-getopt.h"
> > > +#include "ui-out.h"
> > > +#include "symtab.h"
> > > +#include "filenames.h"
> > > +#include "environ.h"
> > > +#include "command.h"
> > > +#include "top.h"
> > > +#include "inferior.h"
> > > +
> >
> > Are all these includes needed? they are not listed in the Makefile
> > dependencies.
> >
> >
> > > +static void env_cli_command (const char *cli, char *args);
> > > +static void env_mod_path (char *dirname, char **which_path);
> > > +
> > > +static const char path_var_name[] = "PATH";
> > > +
> > > +/* The following is copied from mi-main.c so for m1 and below we
> > > + can perform old behavior and use cli commands. */
> > > +static void
> > > +env_execute_cli_command (const char *cli, char *args)
> > > +{
> > > + if (cli != 0)
> > > + {
> > > + struct cleanup *old_cleanups;
> > > + char *run;
> > > + xasprintf (&run, cli, args);
> > > + old_cleanups = make_cleanup (xfree, run);
> > > + execute_command ( /*ui */ run, 0 /*from_tty */ );
> > > + do_cleanups (old_cleanups);
> > > + return;
> > > + }
> > > +}
> > > +
> > > +
> > > +/* Print working directory. */
> > > +enum mi_cmd_result
> > > +mi_cmd_env_pwd (char *command, char **argv, int argc)
> > > +{
> > > + if (argc > 0)
> > > + error ("mi_cmd_env_pwd: No arguments required");
> > > +
> > > + if (mi_version (uiout) < 2)
> > > + {
> > > + env_execute_cli_command ("pwd", NULL);
> > > + return MI_CMD_DONE;
> > > + }
> > > +
> > > + /* Otherwise the mi level is 2 or higher. */
> > > +
> > > + getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
> > > + ui_out_field_string (uiout, "cwd", gdb_dirbuf);
> > > +
> > > + return MI_CMD_DONE;
> > > +}
> > > +
> > > +/* Change working directory. */
> > > +enum mi_cmd_result
> > > +mi_cmd_env_cd (char *command, char **argv, int argc)
> > > +{
> > > + if (argc == 0 || argc > 1)
> > > + error ("mi_cmd_env_cd: Usage DIRECTORY");
> > > +
> > > + env_execute_cli_command ("cd %s", argv[0]);
> > > +
> > > + return MI_CMD_DONE;
> > > +}
> > > +
> > > +static void
> > > +env_mod_path (char *dirname, char **which_path)
> > > +{
> > > + if (dirname == 0 || dirname[0] == '\0')
> > > + return;
> > > +
> > > + /* Call add_path with last arg 0 to indicate not to parse for
> > > + separator characters. */
> > > + add_path (dirname, which_path, 0);
> > > +}
> > > +
> > > +/* Add one or more directories to start of executable search path. */
> > > +enum mi_cmd_result
> > > +mi_cmd_env_path (char *command, char **argv, int argc)
> > > +{
> > > + char *exec_path;
> > > + char *env;
> > > + int i;
> > > +
> > > + if (mi_version (uiout) < 2)
> > > + {
> > > + for (i = argc - 1; i >= 0; --i)
> > > + env_execute_cli_command ("path %s", argv[i]);
> > > + return MI_CMD_DONE;
> > > + }
> > > +
> > > + /* Otherwise the mi level is 2 or higher. */
> > > + dont_repeat ();
> > > + env = get_in_environ (inferior_environ, path_var_name);
> > > +
> > > + /* Can be null if path is not set. */
> > > + if (!env)
> > > + env = "";
> > > + exec_path = xstrdup (env);
> > > +
> > > + for (i = argc - 1; i >= 0; --i)
> > > + env_mod_path (argv[i], &exec_path);
> > > +
> >
> >
> > Could you add a -reset option here too? We might as well have some symmetry.
> >
> > > + set_in_environ (inferior_environ, path_var_name, exec_path);
> > > + xfree (exec_path);
> > > + env = get_in_environ (inferior_environ, path_var_name);
> > > + ui_out_field_string (uiout, "path", env);
> > > +
> > > + return MI_CMD_DONE;
> > > +}
> > > +
> > > +/* Add zero or more directories to the front of the source path. */
> > > +enum mi_cmd_result
> > > +mi_cmd_env_dir (char *command, char **argv, int argc)
> > > +{
> > > + int i;
> > > + int optind = 0;
> > > + int reset = 0;
> > > + char *optarg;
> > > + enum opt
> > > + {
> > > + RESET_OPT
> > > + };
> > > + static struct mi_opt opts[] =
> > > + {
> > > + {"r", RESET_OPT, 0},
> > > + 0
> > > + };
> > > +
> > > + dont_repeat ();
> > > +
> > > + if (mi_version (uiout) < 2)
> > > + {
> > > + for (i = argc - 1; i >= 0; --i)
> > > + env_execute_cli_command ("dir %s", argv[i]);
> > > + return MI_CMD_DONE;
> > > + }
> > > +
> > > + /* Otherwise mi level is 2 or higher. */
> > > + while (1)
> > > + {
> > > + int opt = mi_getopt ("mi_cmd_data_read_memory", argc, argv, opts,
> > ^^^^^^^^^^^^^^^^^^^^^^^
> >
> >
> > > + &optind, &optarg);
> > > + if (opt < 0)
> > > + break;
> > > + switch ((enum opt) opt)
> > > + {
> > > + case RESET_OPT:
> > > + reset = 1;
> > > + break;
> > > + }
> > > + }
> > > + argv += optind;
> > > + argc -= optind;
> > > +
> > > + if (reset)
> > > + {
> > > + /* No args implies reset to default path. */
> > > + xfree (source_path);
> > > + init_source_path ();
> > > + }
> > > +
> > > + for (i = argc - 1; i >= 0; --i)
> > > + env_mod_path (argv[i], &source_path);
> > > + init_last_source_visited ();
> > > +
> > > + ui_out_field_string (uiout, "source-path", source_path);
> > > + forget_cached_source_info ();
> > > +
> > > + return MI_CMD_DONE;
> > > +}
> > > +
> > > Index: mi/mi-cmds.h
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> > > retrieving revision 1.5
> > > diff -u -r1.5 mi-cmds.h
> > > --- mi/mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
> > > +++ mi/mi-cmds.h 9 Nov 2002 00:33:14 -0000
> > > @@ -64,6 +64,10 @@
> > > extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
> > > extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
> > > extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
> > > +extern mi_cmd_argv_ftype mi_cmd_env_cd;
> > > +extern mi_cmd_argv_ftype mi_cmd_env_dir;
> > > +extern mi_cmd_argv_ftype mi_cmd_env_path;
> > > +extern mi_cmd_argv_ftype mi_cmd_env_pwd;
> > > extern mi_cmd_args_ftype mi_cmd_exec_continue;
> > > extern mi_cmd_args_ftype mi_cmd_exec_finish;
> > > extern mi_cmd_args_ftype mi_cmd_exec_next;
> > > Index: mi/mi-cmds.c
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> > > retrieving revision 1.8
> > > diff -u -r1.8 mi-cmds.c
> > > --- mi/mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
> > > +++ mi/mi-cmds.c 9 Nov 2002 00:33:14 -0000
> > > @@ -56,10 +56,10 @@
> > > {"display-enable", 0, 0},
> > > {"display-insert", 0, 0},
> > > {"display-list", 0, 0},
> > > - {"environment-cd", "cd %s", 0},
> > > - {"environment-directory", "dir %s", 0},
> > > - {"environment-path", "path %s", 0},
> > > - {"environment-pwd", "pwd", 0},
> > > + {"environment-cd", 0, 0, mi_cmd_env_cd},
> > > + {"environment-directory", 0, 0, mi_cmd_env_dir},
> > > + {"environment-path", 0, 0, mi_cmd_env_path},
> > > + {"environment-pwd", 0, 0, mi_cmd_env_pwd},
> > > {"exec-abort", 0, 0},
> > > {"exec-arguments", "set args %s", 0},
> > > {"exec-continue", 0, mi_cmd_exec_continue},
> > > Index: gdbmi.texinfo
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
> > > retrieving revision 1.29
> > > diff -u -r1.29 gdbmi.texinfo
> > > --- gdbmi.texinfo 3 Oct 2002 22:31:31 -0000 1.29
> > > +++ gdbmi.texinfo 9 Nov 2002 00:30:50 -0000
> > > @@ -1665,10 +1665,18 @@
> > > @subsubheading Synopsis
> > >
> > > @example
> > > - -environment-directory @var{pathdir}
> > > + -environment-directory [ -r ] [ @var{pathdir} ]+
> > > @end example
> > >
> > > -Add directory @var{pathdir} to beginning of search path for source files.
> > > +Add directories @var{pathdir} to beginning of search path for source files.
> > > +If the @samp{-r} option is used, the search path is reset to the default
> > > +search path. If directories @var{pathdir} are supplied in addition to the
> > > +@samp{-r} option, the search path is first reset and then addition
> > > +occurs as normal.
> > > +Specifying multiple directories in a single command
> > > +results in the directories added to the beginning of the
> > > +search path in the same order they were presented in the command.
> > > +If no directories are specified, the current search path is displayed.
> > >
> > > @subsubheading @value{GDBN} Command
> > >
> > > @@ -1679,7 +1687,16 @@
> > > @smallexample
> > > (@value{GDBP})
> > > -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
> > > -^done
> > > +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> > > +(@value{GDBP})
> > > +-environment-directory ""
> > > +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> > > +(@value{GDBP})
> > > +-environment-directory -r /home/jjohnstn/src/gdb
> > > +^done,source-path="/home/jjohnstn/src/gdb:$cdir:$cwd"
> > > +(@value{GDBP})
> > > +-environment-directory -r
> > > +^done,source-path="$cdir:$cwd"
> > > (@value{GDBP})
> > > @end smallexample
> > >
> > > @@ -1690,10 +1707,12 @@
> > > @subsubheading Synopsis
> > >
> > > @example
> > > - -environment-path ( @var{pathdir} )+
> > > + -environment-path [ @var{pathdir} ]+
> > > @end example
> > >
> > > Add directories @var{pathdir} to beginning of search path for object files.
> > > +If no paths or an empty path is specified, the current object search path
> > > +is displayed with no modification.
> > >
> > > @subsubheading @value{GDBN} Command
> > >
> > > @@ -1704,7 +1723,10 @@
> > > @smallexample
> > > (@value{GDBP})
> > > -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
> > > -^done
> > > +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> > > +(@value{GDBP})
> > > +-environment-path
> > > +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> > > (@value{GDBP})
> > > @end smallexample
> > >
> > > @@ -1729,8 +1751,7 @@
> > > @smallexample
> > > (@value{GDBP})
> > > -environment-pwd
> > > -~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
> > > -^done
> > > +^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
> > > (@value{GDBP})
> > > @end smallexample
> > >
> > > Index: mi-basics.exp
> > > ===================================================================
> > > RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
> > > retrieving revision 1.6
> > > diff -u -r1.6 mi-basics.exp
> > > --- mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
> > > +++ mi-basics.exp 11 Nov 2002 21:11:07 -0000
> > > @@ -148,26 +148,52 @@
> > > global srcdir
> > > global subdir
> > >
> > > - # Clear the search directories, then specify one to be searched
> > > + # Add to the search directories, display, then reset back to default
> > > # Tests:
> > > - # -environment-directory
> > > # -environment-directory arg
> > > + # -environment-directory
> > > + # -environment-directory -r
> > >
> > > #exp_internal 1
> > > - mi_gdb_test "202-environment-directory" \
> > > - "\\\^done" \
> > > + mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
> > > + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> > > + "environment-directory arg operation"
> > > +
> > > + mi_gdb_test "203-environment-directory" \
> > > + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> > > + "environment-directory empty-string operation"
> > > +
> > > + mi_gdb_test "204-environment-directory -r" \
> > > + "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
> > > "environment-directory operation"
> > >
> > > - mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
> > > - "\\\^done" \
> > > - "environment-directory arg operation"
> > > #exp_internal 0
> > > }
> > >
> > > +proc test_cwd_specification {} {
> > > + global mi_gdb_prompt
> > > + global objdir
> > > + global subdir
> > > +
> > > + # Change the working directory, then print the current working directory
> > > + # Tests:
> > > + # -environment-cd ${objdir}
> > > + # -environment-pwd
> > > +
> > > + mi_gdb_test "205-environment-cd ${objdir}" \
> > > + "\\\^done" \
> > > + "environment-cd arg operation"
> > > +
> > > + mi_gdb_test "206-environment-pwd" \
> > > + "\\\^done,cwd=\"${objdir}\"" \
> > > + "environment-pwd operation"
> > > +}
> > > +
> > > if [test_mi_interpreter_selection] {
> > > test_exec_and_symbol_mi_operatons
> > > test_breakpoints_deletion
> > > test_dir_specification
> > > + test_cwd_specification
> > > }
> > >
> > > mi_gdb_exit
>
> Index: defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.102
> diff -u -r1.102 defs.h
> --- defs.h 15 Oct 2002 02:16:51 -0000 1.102
> +++ defs.h 10 Dec 2002 00:15:26 -0000
> @@ -572,9 +572,15 @@
>
> extern void mod_path (char *, char **);
>
> +extern void add_path (char *, char **, int);
> +
> extern void directory_command (char *, int);
>
> +extern char *source_path;
> +
> extern void init_source_path (void);
> +
> +extern void init_last_source_visited (void);
>
> extern char *symtab_to_filename (struct symtab *);
>
> Index: source.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.36
> diff -u -r1.36 source.c
> --- source.c 24 Oct 2002 21:02:53 -0000 1.36
> +++ source.c 10 Dec 2002 00:15:26 -0000
> @@ -357,6 +357,12 @@
> forget_cached_source_info ();
> }
>
> +void
> +init_last_source_visited (void)
> +{
> + last_source_visited = NULL;
> +}
> +
> /* Add zero or more directories to the front of the source path. */
>
> void
> @@ -387,6 +393,18 @@
> void
> mod_path (char *dirname, char **which_path)
> {
> + add_path (dirname, which_path, 1);
> +}
> +
> +/* Workhorse of mod_path. Takes an extra argument to determine
> + if dirname should be parsed for separators that indicate multiple
> + directories. This allows for interfaces that pre-parse the dirname
> + and allow specification of traditional separator characters such
> + as space or tab. */
> +
> +void
> +add_path (char *dirname, char **which_path, int parse_separators)
> +{
> char *old = *which_path;
> int prefix = 0;
>
> @@ -403,9 +421,16 @@
> struct stat st;
>
> {
> - char *separator = strchr (name, DIRNAME_SEPARATOR);
> - char *space = strchr (name, ' ');
> - char *tab = strchr (name, '\t');
> + char *separator = NULL;
> + char *space = NULL;
> + char *tab = NULL;
> +
> + if (parse_separators)
> + {
> + separator = strchr (name, DIRNAME_SEPARATOR);
> + space = strchr (name, ' ');
> + tab = strchr (name, '\t');
> + }
>
> if (separator == 0 && space == 0 && tab == 0)
> p = dirname = name + strlen (name);
> @@ -536,7 +561,8 @@
> tinybuf[0] = DIRNAME_SEPARATOR;
> tinybuf[1] = '\0';
>
> - /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */
> + /* If we have already tacked on a name(s) in this command, be sure they stay
> + on the front as we tack on some more. */
> if (prefix)
> {
> char *temp, c;
> Index: Makefile.in
> ===================================================================
> RCS file: /cvs/src/src/gdb/Makefile.in,v
> retrieving revision 1.290
> diff -u -r1.290 Makefile.in
> --- Makefile.in 5 Dec 2002 05:17:39 -0000 1.290
> +++ Makefile.in 10 Dec 2002 00:15:26 -0000
> @@ -168,12 +168,12 @@
> #
> SUBDIR_MI_OBS = \
> mi-out.o mi-console.o \
> - mi-cmds.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
> + mi-cmds.o mi-cmd-env.o mi-cmd-var.o mi-cmd-break.o mi-cmd-stack.o \
> mi-cmd-disas.o \
> mi-main.o mi-parse.o mi-getopt.o
> SUBDIR_MI_SRCS = \
> mi/mi-out.c mi/mi-console.c \
> - mi/mi-cmds.c \
> + mi/mi-cmds.c mi/mi-cmd-env.c \
> mi/mi-cmd-var.c mi/mi-cmd-break.c mi/mi-cmd-stack.c \
> mi/mi-cmd-disas.c \
> mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
> @@ -2526,6 +2526,10 @@
> mi-cmd-disas.o: $(srcdir)/mi/mi-cmd-disas.c $(defs_h) $(target_h) $(value_h) \
> $(mi_cmds_h) $(mi_getopt_h) $(ui_out_h) $(gdb_string_h) $(disasm_h)
> $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-disas.c
> +mi-cmd-env.o: $(srcdir)/mi/mi-cmd-env.c $(defs_h) $(mi_cmds_h) $(ui_out_h) \
> + $(mi_out_h) $(varobj_h) $(value_h) $(gdb_string_h) $(inferior.h) \
> + $(mi_getopt_h) $(environ_h) $(gdbcmd_h) $(top_h)
> + $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-env.c
> mi-cmd-stack.o: $(srcdir)/mi/mi-cmd-stack.c $(defs_h) $(target_h) $(frame_h) \
> $(value_h) $(mi_cmds_h) $(ui_out_h) $(symtab_h)
> $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/mi/mi-cmd-stack.c
> Index: mi-cmd-env.c
> ===================================================================
> RCS file: mi-cmd-env.c
> diff -N mi-cmd-env.c
> --- mi-cmd-env.c 1 Jan 1970 00:00:00 -0000
> +++ mi-cmd-env.c 10 Dec 2002 00:16:45 -0000
> @@ -0,0 +1,254 @@
> +/* MI Command Set - environment commands.
> + Copyright 2002 Free Software Foundation, Inc.
> + Contributed by Red Hat Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 2 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place - Suite 330,
> + Boston, MA 02111-1307, USA. */
> +
> +#include <string.h>
> +#include <sys/stat.h>
> +
> +#include "defs.h"
> +#include "inferior.h"
> +#include "value.h"
> +#include "mi-out.h"
> +#include "mi-cmds.h"
> +#include "mi-getopt.h"
> +#include "symtab.h"
> +#include "target.h"
> +#include "environ.h"
> +#include "command.h"
> +#include "ui-out.h"
> +#include "top.h"
> +
> +static void env_cli_command (const char *cli, char *args);
> +static void env_mod_path (char *dirname, char **which_path);
> +extern void _initialize_mi_cmd_env (void);
> +
> +static const char path_var_name[] = "PATH";
> +static char *orig_path = NULL;
> +
> +/* The following is copied from mi-main.c so for m1 and below we
> + can perform old behavior and use cli commands. */
> +static void
> +env_execute_cli_command (const char *cli, char *args)
> +{
> + if (cli != 0)
> + {
> + struct cleanup *old_cleanups;
> + char *run;
> + xasprintf (&run, cli, args);
> + old_cleanups = make_cleanup (xfree, run);
> + execute_command ( /*ui */ run, 0 /*from_tty */ );
> + do_cleanups (old_cleanups);
> + return;
> + }
> +}
> +
> +
> +/* Print working directory. */
> +enum mi_cmd_result
> +mi_cmd_env_pwd (char *command, char **argv, int argc)
> +{
> + if (argc > 0)
> + error ("mi_cmd_env_pwd: No arguments required");
> +
> + if (mi_version (uiout) < 2)
> + {
> + env_execute_cli_command ("pwd", NULL);
> + return MI_CMD_DONE;
> + }
> +
> + /* Otherwise the mi level is 2 or higher. */
> +
> + getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
> + ui_out_field_string (uiout, "cwd", gdb_dirbuf);
> +
> + return MI_CMD_DONE;
> +}
> +
> +/* Change working directory. */
> +enum mi_cmd_result
> +mi_cmd_env_cd (char *command, char **argv, int argc)
> +{
> + if (argc == 0 || argc > 1)
> + error ("mi_cmd_env_cd: Usage DIRECTORY");
> +
> + env_execute_cli_command ("cd %s", argv[0]);
> +
> + return MI_CMD_DONE;
> +}
> +
> +static void
> +env_mod_path (char *dirname, char **which_path)
> +{
> + if (dirname == 0 || dirname[0] == '\0')
> + return;
> +
> + /* Call add_path with last arg 0 to indicate not to parse for
> + separator characters. */
> + add_path (dirname, which_path, 0);
> +}
> +
> +/* Add one or more directories to start of executable search path. */
> +enum mi_cmd_result
> +mi_cmd_env_path (char *command, char **argv, int argc)
> +{
> + char *exec_path;
> + char *env;
> + int reset = 0;
> + int optind = 0;
> + int i;
> + char *optarg;
> + enum opt
> + {
> + RESET_OPT
> + };
> + static struct mi_opt opts[] =
> + {
> + {"r", RESET_OPT, 0},
> + 0
> + };
> +
> + dont_repeat ();
> +
> + if (mi_version (uiout) < 2)
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_execute_cli_command ("path %s", argv[i]);
> + return MI_CMD_DONE;
> + }
> +
> + /* Otherwise the mi level is 2 or higher. */
> + while (1)
> + {
> + int opt = mi_getopt ("mi_cmd_env_path", argc, argv, opts,
> + &optind, &optarg);
> + if (opt < 0)
> + break;
> + switch ((enum opt) opt)
> + {
> + case RESET_OPT:
> + reset = 1;
> + break;
> + }
> + }
> + argv += optind;
> + argc -= optind;
> +
> +
> + if (reset)
> + {
> + /* Reset implies resetting to original path first. */
> + exec_path = xstrdup (orig_path);
> + }
> + else
> + {
> + /* Otherwise, get current path to modify. */
> + env = get_in_environ (inferior_environ, path_var_name);
> +
> + /* Can be null if path is not set. */
> + if (!env)
> + env = "";
> + exec_path = xstrdup (env);
> + }
> +
> + for (i = argc - 1; i >= 0; --i)
> + env_mod_path (argv[i], &exec_path);
> +
> + set_in_environ (inferior_environ, path_var_name, exec_path);
> + xfree (exec_path);
> + env = get_in_environ (inferior_environ, path_var_name);
> + ui_out_field_string (uiout, "path", env);
> +
> + return MI_CMD_DONE;
> +}
> +
> +/* Add zero or more directories to the front of the source path. */
> +enum mi_cmd_result
> +mi_cmd_env_dir (char *command, char **argv, int argc)
> +{
> + int i;
> + int optind = 0;
> + int reset = 0;
> + char *optarg;
> + enum opt
> + {
> + RESET_OPT
> + };
> + static struct mi_opt opts[] =
> + {
> + {"r", RESET_OPT, 0},
> + 0
> + };
> +
> + dont_repeat ();
> +
> + if (mi_version (uiout) < 2)
> + {
> + for (i = argc - 1; i >= 0; --i)
> + env_execute_cli_command ("dir %s", argv[i]);
> + return MI_CMD_DONE;
> + }
> +
> + /* Otherwise mi level is 2 or higher. */
> + while (1)
> + {
> + int opt = mi_getopt ("mi_cmd_env_dir", argc, argv, opts,
> + &optind, &optarg);
> + if (opt < 0)
> + break;
> + switch ((enum opt) opt)
> + {
> + case RESET_OPT:
> + reset = 1;
> + break;
> + }
> + }
> + argv += optind;
> + argc -= optind;
> +
> + if (reset)
> + {
> + /* Reset means setting to default path first. */
> + xfree (source_path);
> + init_source_path ();
> + }
> +
> + for (i = argc - 1; i >= 0; --i)
> + env_mod_path (argv[i], &source_path);
> + init_last_source_visited ();
> +
> + ui_out_field_string (uiout, "source-path", source_path);
> + forget_cached_source_info ();
> +
> + return MI_CMD_DONE;
> +}
> +
> +void
> +_initialize_mi_cmd_env (void)
> +{
> + char *env;
> +
> + /* We want original execution path to reset to, if desired later. */
> + env = get_in_environ (inferior_environ, path_var_name);
> +
> + /* Can be null if path is not set. */
> + if (!env)
> + env = "";
> + orig_path = xstrdup (env);
> +}
> Index: mi-cmds.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
> retrieving revision 1.5
> diff -u -r1.5 mi-cmds.h
> --- mi-cmds.h 6 Mar 2001 08:21:45 -0000 1.5
> +++ mi-cmds.h 10 Dec 2002 00:16:45 -0000
> @@ -64,6 +64,10 @@
> extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
> extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
> extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
> +extern mi_cmd_argv_ftype mi_cmd_env_cd;
> +extern mi_cmd_argv_ftype mi_cmd_env_dir;
> +extern mi_cmd_argv_ftype mi_cmd_env_path;
> +extern mi_cmd_argv_ftype mi_cmd_env_pwd;
> extern mi_cmd_args_ftype mi_cmd_exec_continue;
> extern mi_cmd_args_ftype mi_cmd_exec_finish;
> extern mi_cmd_args_ftype mi_cmd_exec_next;
> Index: mi-cmds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
> retrieving revision 1.8
> diff -u -r1.8 mi-cmds.c
> --- mi-cmds.c 6 Mar 2001 08:21:45 -0000 1.8
> +++ mi-cmds.c 10 Dec 2002 00:16:45 -0000
> @@ -56,10 +56,10 @@
> {"display-enable", 0, 0},
> {"display-insert", 0, 0},
> {"display-list", 0, 0},
> - {"environment-cd", "cd %s", 0},
> - {"environment-directory", "dir %s", 0},
> - {"environment-path", "path %s", 0},
> - {"environment-pwd", "pwd", 0},
> + {"environment-cd", 0, 0, mi_cmd_env_cd},
> + {"environment-directory", 0, 0, mi_cmd_env_dir},
> + {"environment-path", 0, 0, mi_cmd_env_path},
> + {"environment-pwd", 0, 0, mi_cmd_env_pwd},
> {"exec-abort", 0, 0},
> {"exec-arguments", "set args %s", 0},
> {"exec-continue", 0, mi_cmd_exec_continue},
> Index: testsuite/gdb.mi/mi-basics.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
> retrieving revision 1.6
> diff -u -r1.6 mi-basics.exp
> --- testsuite/gdb.mi/mi-basics.exp 27 Jun 2001 17:27:07 -0000 1.6
> +++ testsuite/gdb.mi/mi-basics.exp 10 Dec 2002 00:18:48 -0000
> @@ -148,26 +148,98 @@
> global srcdir
> global subdir
>
> - # Clear the search directories, then specify one to be searched
> + # Add to the search directories, display, then reset back to default
> # Tests:
> - # -environment-directory
> # -environment-directory arg
> + # -environment-directory
> + # -environment-directory -r
>
> #exp_internal 1
> - mi_gdb_test "202-environment-directory" \
> - "\\\^done" \
> + mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
> + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> + "environment-directory arg operation"
> +
> + mi_gdb_test "203-environment-directory" \
> + "\\\^done,source-path=\"${srcdir}/${subdir}:\\\$cdir:\\\$cwd\"" \
> + "environment-directory empty-string operation"
> +
> + mi_gdb_test "204-environment-directory -r" \
> + "\\\^done,source-path=\"\\\$cdir:\\\$cwd\"" \
> "environment-directory operation"
>
> - mi_gdb_test "203-environment-directory ${srcdir}/${subdir}" \
> - "\\\^done" \
> - "environment-directory arg operation"
> #exp_internal 0
> }
>
> +proc test_cwd_specification {} {
> + global mi_gdb_prompt
> + global objdir
> + global subdir
> +
> + # Change the working directory, then print the current working directory
> + # Tests:
> + # -environment-cd ${objdir}
> + # -environment-pwd
> +
> + mi_gdb_test "205-environment-cd ${objdir}" \
> + "\\\^done" \
> + "environment-cd arg operation"
> +
> + mi_gdb_test "206-environment-pwd" \
> + "\\\^done,cwd=\"${objdir}\"" \
> + "environment-pwd operation"
> +}
> +
> +proc test_path_specification {} {
> + global mi_gdb_prompt
> + global orig_path
> + global objdir
> + global srcdir
> +
> + # Add to the path, display, then reset
> + # Tests:
> + # -environment-path
> + # -environment-path dir1 dir2
> + # -environment-path -r dir
> + # -environment-path -r
> +
> +#exp_internal 1
> +
> + send_gdb "-environment-path\n"
> + gdb_expect 20 {
> + -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" {
> + set orig_path $expect_out(1,string);
> + }
> + timeout {
> + perror "-environment-path (timeout)" ;
> + return
> + }
> + }
> +
> + mi_gdb_test "207-environment-path" \
> + "\\\^done,path=\"$orig_path\"" \
> + "environment-path no-args operation"
> +
> + mi_gdb_test "208-environment-path $srcdir $objdir" \
> + "\\\^done,path=\"$srcdir:$objdir:$orig_path\"" \
> + "environment-path dir1 dir2 operation"
> +
> + mi_gdb_test "209-environment-path -r $objdir" \
> + "\\\^done,path=\"$objdir:$orig_path\"" \
> + "environment-path -r dir operation"
> +
> + mi_gdb_test "210-environment-path -r" \
> + "\\\^done,path=\"$orig_path\"" \
> + "environment-path -r operation"
> +
> +#exp_internal 0
> +}
> +
> if [test_mi_interpreter_selection] {
> test_exec_and_symbol_mi_operatons
> test_breakpoints_deletion
> test_dir_specification
> + test_cwd_specification
> + test_path_specification
> }
>
> mi_gdb_exit
> Index: gdbmi.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
> retrieving revision 1.30
> diff -u -r1.30 gdbmi.texinfo
> --- gdbmi.texinfo 11 Nov 2002 17:09:50 -0000 1.30
> +++ gdbmi.texinfo 10 Dec 2002 00:12:25 -0000
> @@ -1665,10 +1665,18 @@
> @subsubheading Synopsis
>
> @example
> - -environment-directory @var{pathdir}
> + -environment-directory [ -r ] [ @var{pathdir} ]+
> @end example
>
> -Add directory @var{pathdir} to beginning of search path for source files.
> +Add directories @var{pathdir} to beginning of search path for source files.
> +If the @samp{-r} option is used, the search path is reset to the default
> +search path. If directories @var{pathdir} are supplied in addition to the
> +@samp{-r} option, the search path is first reset and then addition
> +occurs as normal.
> +Specifying multiple directories in a single command
> +results in the directories added to the beginning of the
> +search path in the same order they were presented in the command.
> +If no directories are specified, the current search path is displayed.
>
> @subsubheading @value{GDBN} Command
>
> @@ -1679,7 +1687,16 @@
> @smallexample
> (@value{GDBP})
> -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
> -^done
> +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory ""
> +^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory -r /home/jjohnstn/src/gdb
> +^done,source-path="/home/jjohnstn/src/gdb:$cdir:$cwd"
> +(@value{GDBP})
> +-environment-directory -r
> +^done,source-path="$cdir:$cwd"
> (@value{GDBP})
> @end smallexample
>
> @@ -1690,10 +1707,19 @@
> @subsubheading Synopsis
>
> @example
> - -environment-path ( @var{pathdir} )+
> + -environment-path [ -r ] [ @var{pathdir} ]+
> @end example
>
> Add directories @var{pathdir} to beginning of search path for object files.
> +If the @samp{-r} option is used, the search path is reset to the original
> +search path that existed at gdb start-up. If directories @var{pathdir} are
> +supplied in addition to the
> +@samp{-r} option, the search path is first reset and then addition
> +occurs as normal.
> +Specifying multiple directories in a single command
> +results in the directories added to the beginning of the
> +search path in the same order they were presented in the command.
> +If no directories are specified, the current path is displayed.
>
> @subsubheading @value{GDBN} Command
>
> @@ -1703,8 +1729,14 @@
>
> @smallexample
> (@value{GDBP})
> +-environment-path
> +^done,path="/usr/bin"
> +(@value{GDBP})
> -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
> -^done
> +^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/usr/bin"
> +(@value{GDBP})
> +-environment-path -r /usr/local/bin
> +^done,path="/usr/local/bin:/usr/bin"
> (@value{GDBP})
> @end smallexample
>
> @@ -1729,8 +1761,7 @@
> @smallexample
> (@value{GDBP})
> -environment-pwd
> -~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
> -^done
> +^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
> (@value{GDBP})
> @end smallexample
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-12-09 17:05 ` J. Johnston
2002-12-09 20:59 ` Elena Zannoni
@ 2002-12-09 22:17 ` Eli Zaretskii
2002-12-10 11:35 ` J. Johnston
1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2002-12-09 22:17 UTC (permalink / raw)
To: J. Johnston; +Cc: Elena Zannoni, gdb-patches
On Mon, 9 Dec 2002, J. Johnston wrote:
> No problem. Hopefully the last iteration. I added the
> reset option to -environment-path and also added new tests
> to mi-basics.exp. The Makefile.in has been cleaned
> up properly w/r the header files and I fixed the typo you noticed
> in the call to mi_getopt.
The doco patch is approved, with one minor gripe: you don't really
explain the syntax of adding multiple directories. One of the examples
suggests that they should be separated by a colon, but that's probably
not true for the DOS/Windows ports, where a semicolon should be used,
right? I suggest to add something about this to the doco.
Thanks.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-12-09 22:17 ` Eli Zaretskii
@ 2002-12-10 11:35 ` J. Johnston
2002-12-10 12:22 ` Eli Zaretskii
0 siblings, 1 reply; 17+ messages in thread
From: J. Johnston @ 2002-12-10 11:35 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Elena Zannoni, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]
Eli Zaretskii wrote:
> On Mon, 9 Dec 2002, J. Johnston wrote:
>
>
>>No problem. Hopefully the last iteration. I added the
>>reset option to -environment-path and also added new tests
>>to mi-basics.exp. The Makefile.in has been cleaned
>>up properly w/r the header files and I fixed the typo you noticed
>>in the call to mi_getopt.
>
>
> The doco patch is approved, with one minor gripe: you don't really
> explain the syntax of adding multiple directories. One of the examples
> suggests that they should be separated by a colon, but that's probably
> not true for the DOS/Windows ports, where a semicolon should be used,
> right? I suggest to add something about this to the doco.
>
Actually, the multiple directories are input on the command, separated by blanks
(this is defined by the syntax of the command). The separator found in
the output of the command is dependenent on the system. I have modified the
doc slightly to add examples that specify more than one directory separated
by a blank. Is that sufficient to handle your concern?
-- Jeff J.
[-- Attachment #2: 741.doc.patch --]
[-- Type: text/plain, Size: 3234 bytes --]
Index: gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.30
diff -u -r1.30 gdbmi.texinfo
--- gdbmi.texinfo 11 Nov 2002 17:09:50 -0000 1.30
+++ gdbmi.texinfo 10 Dec 2002 19:24:53 -0000
@@ -1665,10 +1665,18 @@
@subsubheading Synopsis
@example
- -environment-directory @var{pathdir}
+ -environment-directory [ -r ] [ @var{pathdir} ]+
@end example
-Add directory @var{pathdir} to beginning of search path for source files.
+Add directories @var{pathdir} to beginning of search path for source files.
+If the @samp{-r} option is used, the search path is reset to the default
+search path. If directories @var{pathdir} are supplied in addition to the
+@samp{-r} option, the search path is first reset and then addition
+occurs as normal.
+Specifying multiple directories in a single command
+results in the directories added to the beginning of the
+search path in the same order they were presented in the command.
+If no directories are specified, the current search path is displayed.
@subsubheading @value{GDBN} Command
@@ -1679,7 +1687,16 @@
@smallexample
(@value{GDBP})
-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
-^done
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory ""
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory -r /home/jjohnstn/src/gdb /usr/src
+^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory -r
+^done,source-path="$cdir:$cwd"
(@value{GDBP})
@end smallexample
@@ -1690,10 +1707,19 @@
@subsubheading Synopsis
@example
- -environment-path ( @var{pathdir} )+
+ -environment-path [ -r ] [ @var{pathdir} ]+
@end example
Add directories @var{pathdir} to beginning of search path for object files.
+If the @samp{-r} option is used, the search path is reset to the original
+search path that existed at gdb start-up. If directories @var{pathdir} are
+supplied in addition to the
+@samp{-r} option, the search path is first reset and then addition
+occurs as normal.
+Specifying multiple directories in a single command
+results in the directories added to the beginning of the
+search path in the same order they were presented in the command.
+If no directories are specified, the current path is displayed.
@subsubheading @value{GDBN} Command
@@ -1703,8 +1729,14 @@
@smallexample
(@value{GDBP})
--environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
-^done
+-environment-path
+^done,path="/usr/bin"
+(@value{GDBP})
+-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
+(@value{GDBP})
+-environment-path -r /usr/local/bin
+^done,path="/usr/local/bin:/usr/bin"
(@value{GDBP})
@end smallexample
@@ -1729,8 +1761,7 @@
@smallexample
(@value{GDBP})
-environment-pwd
-~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
-^done
+^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
(@value{GDBP})
@end smallexample
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-12-10 11:35 ` J. Johnston
@ 2002-12-10 12:22 ` Eli Zaretskii
2002-12-12 14:58 ` J. Johnston
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2002-12-10 12:22 UTC (permalink / raw)
To: jjohnstn; +Cc: ezannoni, gdb-patches
> Date: Tue, 10 Dec 2002 14:28:06 -0500
> From: "J. Johnston" <jjohnstn@redhat.com>
> >
> > The doco patch is approved, with one minor gripe: you don't really
> > explain the syntax of adding multiple directories. One of the examples
> > suggests that they should be separated by a colon, but that's probably
> > not true for the DOS/Windows ports, where a semicolon should be used,
> > right? I suggest to add something about this to the doco.
> >
>
> Actually, the multiple directories are input on the command,
> separated by blanks
See what I mean? ;-)
> (this is defined by the syntax of the command). The separator found in
> the output of the command is dependenent on the system. I have modified the
> doc slightly to add examples that specify more than one directory separated
> by a blank. Is that sufficient to handle your concern?
It's better, but I'd prefer that the text said explicitly that
multiple directories should be separated by blanks.
(This, of course, raises the issue of directories whose names include
blanks ;-)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-12-10 12:22 ` Eli Zaretskii
@ 2002-12-12 14:58 ` J. Johnston
2002-12-13 5:05 ` Eli Zaretskii
0 siblings, 1 reply; 17+ messages in thread
From: J. Johnston @ 2002-12-12 14:58 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: ezannoni, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]
Eli Zaretskii wrote:
>>Date: Tue, 10 Dec 2002 14:28:06 -0500
>>From: "J. Johnston" <jjohnstn@redhat.com>
>>
>>>The doco patch is approved, with one minor gripe: you don't really
>>>explain the syntax of adding multiple directories. One of the examples
>>>suggests that they should be separated by a colon, but that's probably
>>>not true for the DOS/Windows ports, where a semicolon should be used,
>>>right? I suggest to add something about this to the doco.
>>>
>>
>>Actually, the multiple directories are input on the command,
>>separated by blanks
>
>
> See what I mean? ;-)
>
>
>>(this is defined by the syntax of the command). The separator found in
>>the output of the command is dependenent on the system. I have modified the
>>doc slightly to add examples that specify more than one directory separated
>>by a blank. Is that sufficient to handle your concern?
>
>
> It's better, but I'd prefer that the text said explicitly that
> multiple directories should be separated by blanks.
>
> (This, of course, raises the issue of directories whose names include
> blanks ;-)
See the latest attached version.
-- Jeff J.
[-- Attachment #2: 741.doc.patch --]
[-- Type: text/plain, Size: 3920 bytes --]
Index: gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.30
diff -u -r1.30 gdbmi.texinfo
--- gdbmi.texinfo 11 Nov 2002 17:09:50 -0000 1.30
+++ gdbmi.texinfo 12 Dec 2002 20:58:09 -0000
@@ -1665,10 +1665,25 @@
@subsubheading Synopsis
@example
- -environment-directory @var{pathdir}
+ -environment-directory [ -r ] [ @var{pathdir} ]+
@end example
-Add directory @var{pathdir} to beginning of search path for source files.
+Add directories @var{pathdir} to beginning of search path for source files.
+If the @samp{-r} option is used, the search path is reset to the default
+search path. If directories @var{pathdir} are supplied in addition to the
+@samp{-r} option, the search path is first reset and then addition
+occurs as normal.
+Multiple directories may be specified, separated by blanks. Specifying
+multiple directories in a single command
+results in the directories added to the beginning of the
+search path in the same order they were presented in the command.
+If blanks are needed as
+part of a directory name, double-quotes should be used around
+the name. In the command output, the path will show up separated
+by the system directory-separator character. The directory-seperator
+character must not be used
+in any directory name.
+If no directories are specified, the current search path is displayed.
@subsubheading @value{GDBN} Command
@@ -1679,7 +1694,16 @@
@smallexample
(@value{GDBP})
-environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
-^done
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory ""
+^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory -r /home/jjohnstn/src/gdb /usr/src
+^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
+(@value{GDBP})
+-environment-directory -r
+^done,source-path="$cdir:$cwd"
(@value{GDBP})
@end smallexample
@@ -1690,10 +1714,27 @@
@subsubheading Synopsis
@example
- -environment-path ( @var{pathdir} )+
+ -environment-path [ -r ] [ @var{pathdir} ]+
@end example
Add directories @var{pathdir} to beginning of search path for object files.
+If the @samp{-r} option is used, the search path is reset to the original
+search path that existed at gdb start-up. If directories @var{pathdir} are
+supplied in addition to the
+@samp{-r} option, the search path is first reset and then addition
+occurs as normal.
+Multiple directories may be specified, separated by blanks. Specifying
+multiple directories in a single command
+results in the directories added to the beginning of the
+search path in the same order they were presented in the command.
+If blanks are needed as
+part of a directory name, double-quotes should be used around
+the name. In the command output, the path will show up separated
+by the system directory-separator character. The directory-seperator
+character must not be used
+in any directory name.
+If no directories are specified, the current path is displayed.
+
@subsubheading @value{GDBN} Command
@@ -1703,8 +1744,14 @@
@smallexample
(@value{GDBP})
--environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb
-^done
+-environment-path
+^done,path="/usr/bin"
+(@value{GDBP})
+-environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
+^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
+(@value{GDBP})
+-environment-path -r /usr/local/bin
+^done,path="/usr/local/bin:/usr/bin"
(@value{GDBP})
@end smallexample
@@ -1729,8 +1776,7 @@
@smallexample
(@value{GDBP})
-environment-pwd
-~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
-^done
+^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
(@value{GDBP})
@end smallexample
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-12-12 14:58 ` J. Johnston
@ 2002-12-13 5:05 ` Eli Zaretskii
2002-12-13 9:59 ` J. Johnston
0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2002-12-13 5:05 UTC (permalink / raw)
To: jjohnstn; +Cc: ezannoni, gdb-patches
> Date: Thu, 12 Dec 2002 16:03:09 -0500
> From: "J. Johnston" <jjohnstn@redhat.com>
> >
> > It's better, but I'd prefer that the text said explicitly that
> > multiple directories should be separated by blanks.
> >
> > (This, of course, raises the issue of directories whose names include
> > blanks ;-)
>
> See the latest attached version.
This is perfect. Please commit it (assuming the code itself was
approved by The Powers That Be).
Thanks!
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Proposed patch for gdb/mi 741
2002-12-13 5:05 ` Eli Zaretskii
@ 2002-12-13 9:59 ` J. Johnston
0 siblings, 0 replies; 17+ messages in thread
From: J. Johnston @ 2002-12-13 9:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: ezannoni, gdb-patches
All of the patches have been checked in.
-- Jeff J.
Eli Zaretskii wrote:
>>Date: Thu, 12 Dec 2002 16:03:09 -0500
>>From: "J. Johnston" <jjohnstn@redhat.com>
>>
>>>It's better, but I'd prefer that the text said explicitly that
>>>multiple directories should be separated by blanks.
>>>
>>>(This, of course, raises the issue of directories whose names include
>>>blanks ;-)
>>
>>See the latest attached version.
>
>
> This is perfect. Please commit it (assuming the code itself was
> approved by The Powers That Be).
>
> Thanks!
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2002-12-13 17:58 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-09 12:50 Proposed patch for gdb/mi 741 J. Johnston
2002-10-09 23:03 ` Eli Zaretskii
2002-10-22 9:08 ` Elena Zannoni
2002-11-07 14:10 ` J. Johnston
2002-11-07 16:00 ` Elena Zannoni
2002-11-08 15:53 ` J. Johnston
2002-11-11 17:15 ` J. Johnston
2002-12-06 7:34 ` Elena Zannoni
2002-12-09 17:05 ` J. Johnston
2002-12-09 20:59 ` Elena Zannoni
2002-12-09 22:17 ` Eli Zaretskii
2002-12-10 11:35 ` J. Johnston
2002-12-10 12:22 ` Eli Zaretskii
2002-12-12 14:58 ` J. Johnston
2002-12-13 5:05 ` Eli Zaretskii
2002-12-13 9:59 ` J. Johnston
2002-11-09 13:28 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox