This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA:] sim --sysroot=... option.
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 7 Dec 2004 18:31:15 +0100
- Subject: Re: [RFA:] sim --sysroot=... option.
> Date: Mon, 6 Dec 2004 17:54:12 +0100
> From: Hans-Peter Nilsson <hp@axis.com>
> * nrun.c (main): If simulator_sysroot is not empty, chdir there.
> * run.c (main): Ditto.
After doing a test-build of all buildable simulators in CVS,
(covered by arm-elf frv-elf h8300-elf m32r-elf m68hc11-elf
mcore-elf mips-elf mn10300-elf powerpc-elf v850-elf), I'd like
to retract the run.c part, which is just for an obsolete
interface, and doesn't include sim-config.h (or apparently the
option handler or the other bits from sim/common).
I'd also like to like to replace the nrun.c patch with one that
also includes unistd.h to get the chdir prototype (else there's
a compilation warning, but only for *some* simulators;
presumable target header files include unistd.h in some cases).
Sorry for the extra reading.
* nrun.c [HAVE_UNISTD_H]: Include unistd.h.
(main): If simulator_sysroot is not empty, chdir there.
Index: nrun.c
===================================================================
RCS file: /cvs/src/src/sim/common/nrun.c,v
retrieving revision 1.4
diff -c -p -r1.4 nrun.c
*** nrun.c 23 Jun 2003 18:03:17 -0000 1.4
--- nrun.c 7 Dec 2004 17:27:27 -0000
***************
*** 1,5 ****
/* New version of run front end support for simulators.
! Copyright (C) 1997 Free Software Foundation, Inc.
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
--- 1,5 ----
/* New version of run front end support for simulators.
! Copyright (C) 1997, 2004 Free Software Foundation, Inc.
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
*************** with this program; if not, write to the
*** 24,29 ****
--- 24,34 ----
extern char **environ;
#endif
+ #ifdef HAVE_UNISTD_H
+ /* For chdir. */
+ #include <unistd.h>
+ #endif
+
static void usage (void);
extern host_callback default_callback;
*************** main (int argc, char **argv)
*** 117,122 ****
--- 122,137 ----
sim_create_inferior (sd, prog_bfd, prog_argv, NULL);
#endif
+ /* To accommodate relative file paths, chdir to sysroot now. We
+ mustn't do this until BFD has opened the program, else we wouldn't
+ find the executable if it has a relative file path. */
+ if (simulator_sysroot[0] != '\0' && chdir (simulator_sysroot) < 0)
+ {
+ fprintf (stderr, "%s: can't change directory to \"%s\"\n",
+ myname, simulator_sysroot);
+ exit (1);
+ }
+
/* Run/Step the program. */
if (single_step)
{
brgds, H-P