* [RFA] bfd_cache_close_all
@ 2004-06-16 16:17 Jerome Guitton
2004-06-17 2:22 ` Alan Modra
0 siblings, 1 reply; 6+ messages in thread
From: Jerome Guitton @ 2004-06-16 16:17 UTC (permalink / raw)
To: binutils; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 320 bytes --]
Hello,
In GDB, it would be useful on several platforms (e.g. win32) to
force BFD to release the file handles. Details are here:
http://sources.redhat.com/ml/gdb-patches/2004-05/msg00678.html
The idea would be to have a function bfd_cache_close_all that would
clear the file descriptor cache.
OK to apply?
--
Jerome
[-- Attachment #2: bfd_cache_close_all.dif --]
[-- Type: text/plain, Size: 2342 bytes --]
2004-06-16 Jerome Guitton <guitton@gnat.com>
* bfd-in.h (bfd_cache_close_all): New function declaration.
* bfd-in2.h: Regenerate.
* cache.c (bfd_cache_close_all): New function definition.
Index: bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.81
diff -u -r1.81 bfd-in.h
--- bfd-in.h 15 Jun 2004 01:24:22 -0000 1.81
+++ bfd-in.h 16 Jun 2004 13:12:59 -0000
@@ -511,6 +511,8 @@
(bfd *abfd);
/* NB: This declaration should match the autogenerated one in libbfd.h. */
+extern bfd_boolean bfd_cache_close_all (void);
+
extern bfd_boolean bfd_record_phdr
(bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
Index: bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.280
diff -u -r1.280 bfd-in2.h
--- bfd-in2.h 15 Jun 2004 01:24:22 -0000 1.280
+++ bfd-in2.h 16 Jun 2004 13:12:59 -0000
@@ -518,6 +518,8 @@
(bfd *abfd);
/* NB: This declaration should match the autogenerated one in libbfd.h. */
+extern bfd_boolean bfd_cache_close_all (void);
+
extern bfd_boolean bfd_record_phdr
(bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
Index: cache.c
===================================================================
RCS file: /cvs/src/src/bfd/cache.c,v
retrieving revision 1.14
diff -u -r1.14 cache.c
--- cache.c 5 May 2004 15:39:11 -0000 1.14
+++ cache.c 16 Jun 2004 13:12:59 -0000
@@ -344,6 +344,42 @@
}
/*
+FUNCTION
+ bfd_cache_close_all
+
+SYNOPSIS
+ bfd_boolean bfd_cache_close_all (void);
+
+DESCRIPTION
+ Remove all BFDs from the cache. If the attached file is open,
+ then close it too.
+
+RETURNS
+ <<FALSE>> is returned if closing one of the file fails, <<TRUE>> is
+ returned if all is well.
+*/
+
+bfd_boolean
+bfd_cache_close_all ()
+{
+ bfd_boolean ret = TRUE;
+ register bfd *kill;
+
+ if (!bfd_last_cache)
+ return TRUE;
+
+ for (kill = bfd_last_cache->lru_prev;
+ open_files;
+ kill = kill->lru_prev)
+ {
+ ret = ret && bfd_cache_close (kill);
+ }
+
+ return ret;
+}
+
+
+/*
INTERNAL_FUNCTION
bfd_open_file
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] bfd_cache_close_all
2004-06-16 16:17 [RFA] bfd_cache_close_all Jerome Guitton
@ 2004-06-17 2:22 ` Alan Modra
2004-06-17 11:51 ` Jerome Guitton
0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2004-06-17 2:22 UTC (permalink / raw)
To: Jerome Guitton; +Cc: binutils, gdb-patches
On Wed, Jun 16, 2004 at 07:17:48PM +0200, Jerome Guitton wrote:
> The idea would be to have a function bfd_cache_close_all that would
> clear the file descriptor cache.
>
> OK to apply?
> + if (!bfd_last_cache)
> + return TRUE;
> +
> + for (kill = bfd_last_cache->lru_prev;
> + open_files;
> + kill = kill->lru_prev)
> + {
> + ret = ret && bfd_cache_close (kill);
> + }
No need to close oldest first. OK with the following change to simplify
the code.
while (bfd_last_cache != NULL)
ret &= bfd_cache_close (bfd_last_cache);
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] bfd_cache_close_all
2004-06-17 2:22 ` Alan Modra
@ 2004-06-17 11:51 ` Jerome Guitton
2004-06-17 11:58 ` Jerome Guitton
0 siblings, 1 reply; 6+ messages in thread
From: Jerome Guitton @ 2004-06-17 11:51 UTC (permalink / raw)
To: binutils, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 247 bytes --]
Alan Modra (amodra@bigpond.net.au):
> No need to close oldest first. OK with the following change to simplify
> the code.
>
> while (bfd_last_cache != NULL)
> ret &= bfd_cache_close (bfd_last_cache);
Thanks. Patch committed.
--
Jerome
[-- Attachment #2: bfd_cache_close_all.dif --]
[-- Type: text/plain, Size: 2170 bytes --]
2004-06-17 Jerome Guitton <guitton@gnat.com>
* bfd-in.h (bfd_cache_close_all): New function declaration.
* bfd-in2.h: Regenerate.
* cache.c (bfd_cache_close_all): New function definition.
Index: bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.81
diff -u -r1.81 bfd-in.h
--- bfd-in.h 15 Jun 2004 01:24:22 -0000 1.81
+++ bfd-in.h 17 Jun 2004 10:34:24 -0000
@@ -511,6 +511,8 @@
(bfd *abfd);
/* NB: This declaration should match the autogenerated one in libbfd.h. */
+extern bfd_boolean bfd_cache_close_all (void);
+
extern bfd_boolean bfd_record_phdr
(bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
Index: bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.280
diff -u -r1.280 bfd-in2.h
--- bfd-in2.h 15 Jun 2004 01:24:22 -0000 1.280
+++ bfd-in2.h 17 Jun 2004 10:34:24 -0000
@@ -518,6 +518,8 @@
(bfd *abfd);
/* NB: This declaration should match the autogenerated one in libbfd.h. */
+extern bfd_boolean bfd_cache_close_all (void);
+
extern bfd_boolean bfd_record_phdr
(bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma,
bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **);
Index: cache.c
===================================================================
RCS file: /cvs/src/src/bfd/cache.c,v
retrieving revision 1.14
diff -u -r1.14 cache.c
--- cache.c 5 May 2004 15:39:11 -0000 1.14
+++ cache.c 17 Jun 2004 10:34:25 -0000
@@ -344,6 +344,31 @@
}
/*
+FUNCTION
+ bfd_cache_close_all
+
+SYNOPSIS
+ bfd_boolean bfd_cache_close_all (void);
+
+DESCRIPTION
+ Remove all BFDs from the cache. If the attached file is open,
+ then close it too.
+
+RETURNS
+ <<FALSE>> is returned if closing one of the file fails, <<TRUE>> is
+ returned if all is well.
+*/
+
+bfd_boolean
+bfd_cache_close_all ()
+{
+ bfd_boolean ret = TRUE;
+
+ while (bfd_last_cache != NULL)
+ ret &= bfd_cache_close (bfd_last_cache);
+}
+
+/*
INTERNAL_FUNCTION
bfd_open_file
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] bfd_cache_close_all
2004-06-17 11:51 ` Jerome Guitton
@ 2004-06-17 11:58 ` Jerome Guitton
2004-06-17 12:09 ` Alan Modra
0 siblings, 1 reply; 6+ messages in thread
From: Jerome Guitton @ 2004-06-17 11:58 UTC (permalink / raw)
To: binutils, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
Oh wait, there is no return statement... I've checked in the following,
as obvious. Do I need to add a changelog entry?
2004-06-17 Jerome Guitton <guitton@gnat.com>
* cache.c (bfd_cache_close_all): Add missing return statement.
--
Jerome
[-- Attachment #2: ob.dif --]
[-- Type: text/plain, Size: 405 bytes --]
Index: cache.c
===================================================================
RCS file: /cvs/src/src/bfd/cache.c,v
retrieving revision 1.15
diff -u -p -r1.15 cache.c
--- cache.c 17 Jun 2004 11:47:18 -0000 1.15
+++ cache.c 17 Jun 2004 11:53:58 -0000
@@ -366,6 +366,8 @@ bfd_cache_close_all ()
while (bfd_last_cache != NULL)
ret &= bfd_cache_close (bfd_last_cache);
+
+ return ret;
}
/*
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] bfd_cache_close_all
2004-06-17 11:58 ` Jerome Guitton
@ 2004-06-17 12:09 ` Alan Modra
2004-06-17 12:11 ` Jerome Guitton
0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2004-06-17 12:09 UTC (permalink / raw)
To: Jerome Guitton; +Cc: binutils, gdb-patches
On Thu, Jun 17, 2004 at 02:57:58PM +0200, Jerome Guitton wrote:
> Oh wait, there is no return statement... I've checked in the following,
> as obvious. Do I need to add a changelog entry?
I don't think it matters.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] bfd_cache_close_all
2004-06-17 12:09 ` Alan Modra
@ 2004-06-17 12:11 ` Jerome Guitton
0 siblings, 0 replies; 6+ messages in thread
From: Jerome Guitton @ 2004-06-17 12:11 UTC (permalink / raw)
To: binutils, gdb-patches
Alan Modra (amodra@bigpond.net.au):
> I don't think it matters.
OK, thanks again.
--
Jerome
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-06-17 12:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-16 16:17 [RFA] bfd_cache_close_all Jerome Guitton
2004-06-17 2:22 ` Alan Modra
2004-06-17 11:51 ` Jerome Guitton
2004-06-17 11:58 ` Jerome Guitton
2004-06-17 12:09 ` Alan Modra
2004-06-17 12:11 ` Jerome Guitton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).