This is the mail archive of the 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]

[patch] release handle on object files after program exits


One of our Windows users reported that he was not able to delete
the exe file even after the program was run to completion. As it
turns out, we did fix something similar a while ago but only when
the program was kill-ed.

The attached patch fixes the problem in the case when the program
is let to run to completion.

2009-04-03  Joel Brobecker  <>

        * target.c (target_mourn_inferior): Call bfd_cache_close_all.

Tested on x86_64-linux. Also tested on x86-windows using AdaCore's

I will write a testcase for this one. I have to run now, but I wanted
to put this patch out, in case someone has some comments about it.
Will commit in a few days if no objection.

One thing that crossed my mind while working on this is wondering
whether it would make sense for target_kill to call target_mourn_inferior
at the end. Right now, it looks like a lot (most? all?) implementations
of the target_kill method call target_mourn_inferior...

diff --git a/gdb/target.c b/gdb/target.c
index 86cdb71..3c37ee4 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1934,6 +1934,12 @@ void
 target_mourn_inferior (void)
   struct target_ops *t;
+  /* We no longer need to keep handles on any of the object files.
+     Make sure to release them to avoid unnecessarily locking any
+     of them while we're not actually debugging.  */
+  bfd_cache_close_all ();
   for (t = current_target.beneath; t != NULL; t = t->beneath)
       if (t->to_mourn_inferior != NULL)	

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