gdb: convert bfd-cache to new-style debug macros
gdb/ChangeLog: * gdb_bfd.c (bfd_cache_debug_printf): New, use throughout file. Change-Id: Ie29948d82adfae7edb3cdcbd61f59a66892fcc99
This commit is contained in:
parent
439706e6a9
commit
1e15fcac94
@ -1,3 +1,7 @@
|
|||||||
|
2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
|
* gdb_bfd.c (bfd_cache_debug_printf): New, use throughout file.
|
||||||
|
|
||||||
2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
|
2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* ser-tcp.c (wait_for_connect): Use interruptible_select instead
|
* ser-tcp.c (wait_for_connect): Use interruptible_select instead
|
||||||
|
@ -138,6 +138,11 @@ show_bfd_sharing (struct ui_file *file, int from_tty,
|
|||||||
|
|
||||||
static bool debug_bfd_cache;
|
static bool debug_bfd_cache;
|
||||||
|
|
||||||
|
/* Print an "bfd-cache" debug statement. */
|
||||||
|
|
||||||
|
#define bfd_cache_debug_printf(fmt, ...) \
|
||||||
|
debug_prefixed_printf_cond (debug_bfd_cache, "bfd-cache", fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_bfd_cache_debug (struct ui_file *file, int from_tty,
|
show_bfd_cache_debug (struct ui_file *file, int from_tty,
|
||||||
struct cmd_list_element *c, const char *value)
|
struct cmd_list_element *c, const char *value)
|
||||||
@ -529,10 +534,7 @@ gdb_bfd_open (const char *name, const char *target, int fd,
|
|||||||
if (fstat (fd, &st) < 0)
|
if (fstat (fd, &st) < 0)
|
||||||
{
|
{
|
||||||
/* Weird situation here -- don't cache if we can't stat. */
|
/* Weird situation here -- don't cache if we can't stat. */
|
||||||
if (debug_bfd_cache)
|
bfd_cache_debug_printf ("Could not stat %s - not caching", name);
|
||||||
fprintf_unfiltered (gdb_stdlog,
|
|
||||||
"Could not stat %s - not caching\n",
|
|
||||||
name);
|
|
||||||
abfd = bfd_fopen (name, target, FOPEN_RB, fd);
|
abfd = bfd_fopen (name, target, FOPEN_RB, fd);
|
||||||
if (abfd == nullptr)
|
if (abfd == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -553,11 +555,9 @@ gdb_bfd_open (const char *name, const char *target, int fd,
|
|||||||
abfd = (struct bfd *) htab_find_with_hash (gdb_bfd_cache, &search, hash);
|
abfd = (struct bfd *) htab_find_with_hash (gdb_bfd_cache, &search, hash);
|
||||||
if (bfd_sharing && abfd != NULL)
|
if (bfd_sharing && abfd != NULL)
|
||||||
{
|
{
|
||||||
if (debug_bfd_cache)
|
bfd_cache_debug_printf ("Reusing cached bfd %s for %s",
|
||||||
fprintf_unfiltered (gdb_stdlog,
|
host_address_to_string (abfd),
|
||||||
"Reusing cached bfd %s for %s\n",
|
bfd_get_filename (abfd));
|
||||||
host_address_to_string (abfd),
|
|
||||||
bfd_get_filename (abfd));
|
|
||||||
close (fd);
|
close (fd);
|
||||||
return gdb_bfd_ref_ptr::new_reference (abfd);
|
return gdb_bfd_ref_ptr::new_reference (abfd);
|
||||||
}
|
}
|
||||||
@ -566,11 +566,9 @@ gdb_bfd_open (const char *name, const char *target, int fd,
|
|||||||
if (abfd == NULL)
|
if (abfd == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (debug_bfd_cache)
|
bfd_cache_debug_printf ("Creating new bfd %s for %s",
|
||||||
fprintf_unfiltered (gdb_stdlog,
|
host_address_to_string (abfd),
|
||||||
"Creating new bfd %s for %s\n",
|
bfd_get_filename (abfd));
|
||||||
host_address_to_string (abfd),
|
|
||||||
bfd_get_filename (abfd));
|
|
||||||
|
|
||||||
if (bfd_sharing)
|
if (bfd_sharing)
|
||||||
{
|
{
|
||||||
@ -646,11 +644,9 @@ gdb_bfd_ref (struct bfd *abfd)
|
|||||||
|
|
||||||
gdata = (struct gdb_bfd_data *) bfd_usrdata (abfd);
|
gdata = (struct gdb_bfd_data *) bfd_usrdata (abfd);
|
||||||
|
|
||||||
if (debug_bfd_cache)
|
bfd_cache_debug_printf ("Increase reference count on bfd %s (%s)",
|
||||||
fprintf_unfiltered (gdb_stdlog,
|
host_address_to_string (abfd),
|
||||||
"Increase reference count on bfd %s (%s)\n",
|
bfd_get_filename (abfd));
|
||||||
host_address_to_string (abfd),
|
|
||||||
bfd_get_filename (abfd));
|
|
||||||
|
|
||||||
if (gdata != NULL)
|
if (gdata != NULL)
|
||||||
{
|
{
|
||||||
@ -681,19 +677,15 @@ gdb_bfd_unref (struct bfd *abfd)
|
|||||||
gdata->refc -= 1;
|
gdata->refc -= 1;
|
||||||
if (gdata->refc > 0)
|
if (gdata->refc > 0)
|
||||||
{
|
{
|
||||||
if (debug_bfd_cache)
|
bfd_cache_debug_printf ("Decrease reference count on bfd %s (%s)",
|
||||||
fprintf_unfiltered (gdb_stdlog,
|
host_address_to_string (abfd),
|
||||||
"Decrease reference count on bfd %s (%s)\n",
|
bfd_get_filename (abfd));
|
||||||
host_address_to_string (abfd),
|
|
||||||
bfd_get_filename (abfd));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_bfd_cache)
|
bfd_cache_debug_printf ("Delete final reference count on bfd %s (%s)",
|
||||||
fprintf_unfiltered (gdb_stdlog,
|
host_address_to_string (abfd),
|
||||||
"Delete final reference count on bfd %s (%s)\n",
|
bfd_get_filename (abfd));
|
||||||
host_address_to_string (abfd),
|
|
||||||
bfd_get_filename (abfd));
|
|
||||||
|
|
||||||
archive_bfd = gdata->archive_bfd;
|
archive_bfd = gdata->archive_bfd;
|
||||||
search.filename = bfd_get_filename (abfd);
|
search.filename = bfd_get_filename (abfd);
|
||||||
|
Loading…
Reference in New Issue
Block a user