This is the mail archive of the
mailing list for the GDB project.
Re: [patch] release handle on object files after program exits
> I'm left wondering if generic_mourn_inferior wouldn't be a better place
> for this. That is, at the tail end of mourning, instead of before mourning,
> which e.g., has a better change of not triggering a file reopen.
> generic_mourn_inferior already calls reopen_exec_file, which
> conditionaly calls bfd_cache_close_all.
Looks like generic_mourn_inferior is not necessarily called at
the end of the execution of the program. Lots of targets actually
call it at the end of their own mourn_inferior, but it is conceivable
that some may not.
But you do have a point. How about the following patch instead?
Instead of closing all descriptors before calling the mourn_inferior
routine, it does it after.
2009-04-08 Joel Brobecker <email@example.com>
* target.c (target_mourn_inferior): Call bfd_cache_close_all
after having executed the target mourn_inferior routine.
Tested on x86-windows.
--- target.c (revision 147356)
+++ target.c (working copy)
@@ -1947,6 +1942,12 @@ target_mourn_inferior (void)
fprintf_unfiltered (gdb_stdlog, "target_mourn_inferior ()\n");
+ /* 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 ();