This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] delete corefile.c:close_exec_file (was: "Re: [0/17] RFC: share minimal symbols across objfiles")


> However, according to a comment in fork-child., we have to close the fd
> in order to exec on some targets:
> 
>   /* On some systems an exec will fail if the executable is open.  */
>   close_exec_file ();
> 
> This is the basic contradiction.

I reasearched this one, and I'm afraid that it predates CVS.

But the good news is in corefile.c:

    | /* The exec file must be closed before running an inferior.
    |    If it is needed again after the inferior dies, it must
    |    be reopened.  */
    | 
    | void
    | close_exec_file (void)
    | {
    | #if 0                           /* FIXME */
    |   if (exec_bfd)
    |     bfd_tempclose (exec_bfd);
    | #endif
    | }

Ha ha ha!

The code has been commented out side Jul 07, 1999 (the revision history
says: "import gdb-1999-07-07 post reformat").

Attached is the patch that I just checked in as obvious.  Does it
simplify a bit your work?

gdb/ChangeLog:

        * corefile.c (close_exec_file): Delete.
        (reopen_exec_file): Remove commented out code that seems related
        to close_exec_file, which is being deleted here.
        * inferior.h (close_exec_file): Delete.
        * fork-child.c (fork_inferior): Remove call to fork_inferior.

Tested by rebuilding GDB on x86_64-linux.  Testsuite running, but
how can it regress?

-- 
Joel
>From 36ac6184edccab0330e7d87a23f02e97f22b8ae9 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Wed, 4 Jan 2012 19:07:24 +0400
Subject: [PATCH] Get rid of corefile.c:close_exec_file

The body of this function has been commented out since Jul 1999, and
thus seems unnecessary. While at it, remove some commented out code
that seems to be related to the function being deleted.

gdb/ChangeLog:

	* corefile.c (close_exec_file): Delete.
	(reopen_exec_file): Remove commented out code that seems related
	to close_exec_file, which is being deleted here.
	* inferior.h (close_exec_file): Delete.
	* fork-child.c (fork_inferior): Remove call to fork_inferior.
---
 gdb/ChangeLog    |    8 ++++++++
 gdb/corefile.c   |   18 ------------------
 gdb/fork-child.c |    3 ---
 gdb/inferior.h   |    2 --
 4 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8bdb758..445e931 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
 2012-01-04  Joel Brobecker  <brobecker@adacore.com>
 
+	* corefile.c (close_exec_file): Delete.
+	(reopen_exec_file): Remove commented out code that seems related
+	to close_exec_file, which is being deleted here.
+	* inferior.h (close_exec_file): Delete.
+	* fork-child.c (fork_inferior): Remove call to fork_inferior.
+
+2012-01-04  Joel Brobecker  <brobecker@adacore.com>
+
 	* ada-lang.c: #include "cli/cli-utils.h".
 	(get_selections): Use skip_spaces.
 	(ada_get_next_arg): Use skip_spaces and skip_to_space.
diff --git a/gdb/corefile.c b/gdb/corefile.c
index c07447b..1741e9c 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -132,26 +132,9 @@ specify_exec_file_hook (void (*hook) (char *))
     deprecated_exec_file_display_hook = hook;
 }
 
-/* The exec file must be closed before running an inferior.
-   If it is needed again after the inferior dies, it must
-   be reopened.  */
-
-void
-close_exec_file (void)
-{
-#if 0				/* FIXME */
-  if (exec_bfd)
-    bfd_tempclose (exec_bfd);
-#endif
-}
-
 void
 reopen_exec_file (void)
 {
-#if 0				/* FIXME */
-  if (exec_bfd)
-    bfd_reopen (exec_bfd);
-#else
   char *filename;
   int res;
   struct stat st;
@@ -175,7 +158,6 @@ reopen_exec_file (void)
     bfd_cache_close_all ();
 
   do_cleanups (cleanups);
-#endif
 }
 
 /* If we have both a core file and an exec file,
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index cba91f9..3b8da49 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -272,9 +272,6 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env,
       argv[3] = (char *) 0;
     }
 
-  /* On some systems an exec will fail if the executable is open.  */
-  close_exec_file ();
-
   /* Retain a copy of our environment variables, since the child will
      replace the value of environ and if we're vforked, we have to
      restore it.  */
diff --git a/gdb/inferior.h b/gdb/inferior.h
index f9b3656..f05789f 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -154,8 +154,6 @@ extern void fetch_inferior_event (void *);
 
 extern void init_wait_for_inferior (void);
 
-extern void close_exec_file (void);
-
 extern void reopen_exec_file (void);
 
 /* The `resume' routine should only be called in special circumstances.
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]