8f40d74305d2f8a47bd8176295800b5c3b1b0537
1 /* Definitions for BFD wrappers used by GDB.
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "gdb_assert.h"
24 #include "gdb_string.h"
29 gdb_bfd_stash_filename (struct bfd
*abfd
)
31 char *name
= bfd_get_filename (abfd
);
34 data
= bfd_alloc (abfd
, strlen (name
) + 1);
37 /* Unwarranted chumminess with BFD. */
38 abfd
->filename
= data
;
41 /* Close ABFD, and warn if that fails. */
44 gdb_bfd_close_or_warn (struct bfd
*abfd
)
47 char *name
= bfd_get_filename (abfd
);
49 ret
= bfd_close (abfd
);
52 warning (_("cannot close \"%s\": %s"),
53 name
, bfd_errmsg (bfd_get_error ()));
58 /* Add reference to ABFD. Returns ABFD. */
61 gdb_bfd_ref (struct bfd
*abfd
)
68 p_refcount
= bfd_usrdata (abfd
);
70 if (p_refcount
!= NULL
)
76 p_refcount
= xmalloc (sizeof (*p_refcount
));
78 bfd_usrdata (abfd
) = p_refcount
;
83 /* Unreference and possibly close ABFD. */
86 gdb_bfd_unref (struct bfd
*abfd
)
94 p_refcount
= bfd_usrdata (abfd
);
95 gdb_assert (*p_refcount
>= 1);
102 bfd_usrdata (abfd
) = NULL
; /* Paranoia. */
104 name
= bfd_get_filename (abfd
);
105 gdb_bfd_close_or_warn (abfd
);
This page took 0.031249 seconds and 4 git commands to generate.