This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Initialize the correct cwd for the child
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: Initialize the correct cwd for the child
- From: Robert Hoehne <robert dot hoehne at gmx dot net>
- Date: Fri, 4 Aug 2000 15:43:26 +0200
- Organization: none provided
On DJGPP, the child's working directory have to be remembered.
In the current implementation this is done once, when gdb is started.
But this is wrong, since the user can change it with the gdb-command
cd <some-directory>
and when running the child, it is expected, that it get this directory as
its starting directory. So I made a patch for this.
2000-08-04 Robert Hoehne <robert.hoehne@gmx.net>
* go32-nat.c: (go32_wait, go32_create_inferior, init_go32_ops) :
initialize the child's cwd to the actual current one
--- gdb-5.0/gdb/go32-nat.c~ Wed Apr 12 17:06:18 2000
+++ gdb-5.0/gdb/go32-nat.c Fri Aug 4 15:18:26 2000
@@ -389,6 +389,13 @@ go32_wait (int pid ATTRIBUTE_UNUSED, str
point of changing back to where GDB thinks is its cwd, when we
return control to the debugger, but restore child's cwd before we
run it. */
+ /* Initialize child_cwd, before the first call to run_child and not
+ in the initialization, so the child get also the changed directory
+ set with the gdb-command "cd ..." */
+ if (!*child_cwd)
+ /* Initialize child's cwd with the current one. */
+ getcwd (child_cwd, sizeof (child_cwd));
+
chdir (child_cwd);
#if __DJGPP_MINOR__ < 3
@@ -603,6 +610,11 @@ go32_create_inferior (char *exec_file, c
}
resume_signal = -1;
resume_is_step = 0;
+
+ /* Initialize child's cwd as empty to be initialized when starting
+ the child. */
+ *child_cwd = 0;
+
/* Init command line storage. */
if (redir_debug_init (&child_cmd) == -1)
internal_error ("Cannot allocate redirection storage: not enough memory.\n");
@@ -1224,8 +1236,9 @@ init_go32_ops (void)
go32_ops.to_has_execution = 1;
go32_ops.to_magic = OPS_MAGIC;
- /* Initialize child's cwd with the current one. */
- getcwd (child_cwd, sizeof (child_cwd));
+ /* Initialize child's cwd as empty to be initialized when starting
+ the child. */
+ *child_cwd = 0;
/* Initialize child's command line storage. */
if (redir_debug_init (&child_cmd) == -1)
******************************************************
* email: Robert Hoehne <robert.hoehne@gmx.net> *
* Post: Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW: http://www.tu-chemnitz.de/~sho/rho *
******************************************************