2002-12-13 18:00:22 +01:00
|
|
|
/* MI Command Set - environment commands.
|
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* ax-gdb.c, c-valprint.c, charset.c, corefile.c: Update copyright.
* demangle.c, disasm.c, dwarf2cfi.c, dwarfread.c: Update copyright.
* elfread.c, eval.c, expprint.c, expression.h: Update copyright.
* f-typeprint.c, findvar.c, gcore.c, gdb_mbuild.sh: Update copyright.
* gdbtypes.h, gnu-v2-abi.c, inferior.h, inftarg.c: Update copyright.
* language.c, language.h, m32r-tdep.c: Update copyright.
* mn10200-tdep.c, scm-lang.c, scm-lang.h: Update copyright.
* somsolib.c, somsolib.h, symfile.c, symtab.h: Update copyright.
* thread-db.c, typeprint.c, utils.c, valarith.c: Update copyright.
* values.c, win32-nat.c, x86-64-linux-nat.c: Update copyright.
* x86-64-linux-tdep.c, z8k-tdep.c: Update copyright.
* cli/cli-decode.h, config/h8500/tm-h8500.h: Update copyright.
Index: mi/ChangeLog
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* mi-cmd-env.c: Update copyright.
2003-01-14 01:49:06 +01:00
|
|
|
|
2010-01-01 08:32:07 +01:00
|
|
|
Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009, 2010
|
2009-01-03 06:58:08 +01:00
|
|
|
Free Software Foundation, Inc.
|
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* ax-gdb.c, c-valprint.c, charset.c, corefile.c: Update copyright.
* demangle.c, disasm.c, dwarf2cfi.c, dwarfread.c: Update copyright.
* elfread.c, eval.c, expprint.c, expression.h: Update copyright.
* f-typeprint.c, findvar.c, gcore.c, gdb_mbuild.sh: Update copyright.
* gdbtypes.h, gnu-v2-abi.c, inferior.h, inftarg.c: Update copyright.
* language.c, language.h, m32r-tdep.c: Update copyright.
* mn10200-tdep.c, scm-lang.c, scm-lang.h: Update copyright.
* somsolib.c, somsolib.h, symfile.c, symtab.h: Update copyright.
* thread-db.c, typeprint.c, utils.c, valarith.c: Update copyright.
* values.c, win32-nat.c, x86-64-linux-nat.c: Update copyright.
* x86-64-linux-tdep.c, z8k-tdep.c: Update copyright.
* cli/cli-decode.h, config/h8500/tm-h8500.h: Update copyright.
Index: mi/ChangeLog
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* mi-cmd-env.c: Update copyright.
2003-01-14 01:49:06 +01:00
|
|
|
|
2002-12-13 18:00:22 +01:00
|
|
|
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
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2002-12-13 18:00:22 +01:00
|
|
|
(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
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2002-12-13 18:00:22 +01:00
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2003-01-09 19:03:38 +01:00
|
|
|
#include "gdb_string.h"
|
2003-02-07 01:27:31 +01:00
|
|
|
#include "gdb_stat.h"
|
2003-01-09 19:03:38 +01:00
|
|
|
|
2002-12-13 18:00:22 +01:00
|
|
|
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;
|
|
|
|
|
2003-08-05 21:55:17 +02:00
|
|
|
/* The following is copied from mi-main.c so for m1 and below we can
|
|
|
|
perform old behavior and use cli commands. If ARGS is non-null,
|
|
|
|
append it to the CMD. */
|
2002-12-13 18:00:22 +01:00
|
|
|
static void
|
2003-08-05 21:55:17 +02:00
|
|
|
env_execute_cli_command (const char *cmd, const char *args)
|
2002-12-13 18:00:22 +01:00
|
|
|
{
|
2003-08-05 21:55:17 +02:00
|
|
|
if (cmd != 0)
|
2002-12-13 18:00:22 +01:00
|
|
|
{
|
|
|
|
struct cleanup *old_cleanups;
|
|
|
|
char *run;
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2003-08-05 21:55:17 +02:00
|
|
|
if (args != NULL)
|
2004-06-01 15:33:58 +02:00
|
|
|
run = xstrprintf ("%s %s", cmd, args);
|
2003-08-05 21:55:17 +02:00
|
|
|
else
|
|
|
|
run = xstrdup (cmd);
|
2002-12-13 18:00:22 +01:00
|
|
|
old_cleanups = make_cleanup (xfree, run);
|
|
|
|
execute_command ( /*ui */ run, 0 /*from_tty */ );
|
|
|
|
do_cleanups (old_cleanups);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Print working directory. */
|
2008-06-25 17:15:42 +02:00
|
|
|
void
|
2002-12-13 18:00:22 +01:00
|
|
|
mi_cmd_env_pwd (char *command, char **argv, int argc)
|
|
|
|
{
|
|
|
|
if (argc > 0)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
error (_("mi_cmd_env_pwd: No arguments required"));
|
2002-12-13 18:00:22 +01:00
|
|
|
|
|
|
|
if (mi_version (uiout) < 2)
|
|
|
|
{
|
|
|
|
env_execute_cli_command ("pwd", NULL);
|
2008-06-25 17:15:42 +02:00
|
|
|
return;
|
2002-12-13 18:00:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise the mi level is 2 or higher. */
|
|
|
|
|
2009-01-06 19:31:59 +01:00
|
|
|
if (! getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)))
|
|
|
|
error (_("mi_cmd_env_pwd: error finding name of working directory: %s"),
|
|
|
|
safe_strerror (errno));
|
|
|
|
|
2002-12-13 18:00:22 +01:00
|
|
|
ui_out_field_string (uiout, "cwd", gdb_dirbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Change working directory. */
|
2008-06-25 17:15:42 +02:00
|
|
|
void
|
2002-12-13 18:00:22 +01:00
|
|
|
mi_cmd_env_cd (char *command, char **argv, int argc)
|
|
|
|
{
|
|
|
|
if (argc == 0 || argc > 1)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
error (_("mi_cmd_env_cd: Usage DIRECTORY"));
|
2002-12-13 18:00:22 +01:00
|
|
|
|
2003-08-05 21:55:17 +02:00
|
|
|
env_execute_cli_command ("cd", argv[0]);
|
2002-12-13 18:00:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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. */
|
2008-06-25 17:15:42 +02:00
|
|
|
void
|
2002-12-13 18:00:22 +01:00
|
|
|
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},
|
2007-01-03 20:01:25 +01:00
|
|
|
{ 0, 0, 0 }
|
2002-12-13 18:00:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
dont_repeat ();
|
|
|
|
|
|
|
|
if (mi_version (uiout) < 2)
|
|
|
|
{
|
|
|
|
for (i = argc - 1; i >= 0; --i)
|
2003-08-05 21:55:17 +02:00
|
|
|
env_execute_cli_command ("path", argv[i]);
|
2008-06-25 17:15:42 +02:00
|
|
|
return;
|
2002-12-13 18:00:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise the mi level is 2 or higher. */
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
int opt = mi_getopt ("mi_cmd_env_path", argc, argv, opts,
|
|
|
|
&optind, &optarg);
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2002-12-13 18:00:22 +01:00
|
|
|
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. */
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 15:23:07 +01:00
|
|
|
env = get_in_environ (current_inferior ()->environment, path_var_name);
|
2002-12-13 18:00:22 +01:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 15:23:07 +01:00
|
|
|
set_in_environ (current_inferior ()->environment, path_var_name, exec_path);
|
2002-12-13 18:00:22 +01:00
|
|
|
xfree (exec_path);
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 15:23:07 +01:00
|
|
|
env = get_in_environ (current_inferior ()->environment, path_var_name);
|
2002-12-13 18:00:22 +01:00
|
|
|
ui_out_field_string (uiout, "path", env);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add zero or more directories to the front of the source path. */
|
2008-06-25 17:15:42 +02:00
|
|
|
void
|
2002-12-13 18:00:22 +01:00
|
|
|
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},
|
2007-01-03 20:01:25 +01:00
|
|
|
{ 0, 0, 0 }
|
2002-12-13 18:00:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
dont_repeat ();
|
|
|
|
|
|
|
|
if (mi_version (uiout) < 2)
|
|
|
|
{
|
|
|
|
for (i = argc - 1; i >= 0; --i)
|
2003-08-05 21:55:17 +02:00
|
|
|
env_execute_cli_command ("dir", argv[i]);
|
2008-06-25 17:15:42 +02:00
|
|
|
return;
|
2002-12-13 18:00:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise mi level is 2 or higher. */
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
int opt = mi_getopt ("mi_cmd_env_dir", argc, argv, opts,
|
|
|
|
&optind, &optarg);
|
2010-05-17 22:49:39 +02:00
|
|
|
|
2002-12-13 18:00:22 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
ui_out_field_string (uiout, "source-path", source_path);
|
|
|
|
forget_cached_source_info ();
|
|
|
|
}
|
|
|
|
|
2005-07-06 16:54:37 +02:00
|
|
|
/* Set the inferior terminal device name. */
|
2008-06-25 17:15:42 +02:00
|
|
|
void
|
2005-07-06 16:54:37 +02:00
|
|
|
mi_cmd_inferior_tty_set (char *command, char **argv, int argc)
|
|
|
|
{
|
|
|
|
set_inferior_io_terminal (argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print the inferior terminal device name */
|
2008-06-25 17:15:42 +02:00
|
|
|
void
|
2005-07-06 16:54:37 +02:00
|
|
|
mi_cmd_inferior_tty_show (char *command, char **argv, int argc)
|
|
|
|
{
|
|
|
|
const char *inferior_io_terminal = get_inferior_io_terminal ();
|
|
|
|
|
|
|
|
if ( !mi_valid_noargs ("mi_cmd_inferior_tty_show", argc, argv))
|
|
|
|
error (_("mi_cmd_inferior_tty_show: Usage: No args"));
|
|
|
|
|
|
|
|
if (inferior_io_terminal)
|
|
|
|
ui_out_field_string (uiout, "inferior_tty_terminal", inferior_io_terminal);
|
|
|
|
}
|
|
|
|
|
2002-12-13 18:00:22 +01:00
|
|
|
void
|
|
|
|
_initialize_mi_cmd_env (void)
|
|
|
|
{
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 15:23:07 +01:00
|
|
|
struct gdb_environ *environment;
|
2002-12-13 18:00:22 +01:00
|
|
|
char *env;
|
|
|
|
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 15:23:07 +01:00
|
|
|
/* We want original execution path to reset to, if desired later.
|
|
|
|
At this point, current inferior is not created, so cannot use
|
|
|
|
current_inferior ()->environment. Also, there's no obvious
|
|
|
|
place where this code can be moved suchs that it surely run
|
|
|
|
before any code possibly mangles original PATH. */
|
|
|
|
environment = make_environ ();
|
|
|
|
init_environ (environment);
|
|
|
|
env = get_in_environ (environment, path_var_name);
|
2002-12-13 18:00:22 +01:00
|
|
|
|
|
|
|
/* Can be null if path is not set. */
|
|
|
|
if (!env)
|
|
|
|
env = "";
|
|
|
|
orig_path = xstrdup (env);
|
|
|
|
}
|