diff options
author | Tom Tromey <tom@tromey.com> | 2021-12-26 14:03:41 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-12-29 10:47:48 -0700 |
commit | 3defe97705e325f2f3048b8c18321518a6c7e190 (patch) | |
tree | 408f1572d3f090ad8d6b87b801eb81ec262987d3 /gdb/machoread.c | |
parent | 7fea6c34a1bcf11757c9d76c9d23ca5372d56501 (diff) | |
download | gdb-3defe97705e325f2f3048b8c18321518a6c7e190.zip gdb-3defe97705e325f2f3048b8c18321518a6c7e190.tar.gz gdb-3defe97705e325f2f3048b8c18321518a6c7e190.tar.bz2 |
Use debug_prefixed_printf_cond_nofunc in machoread
This changes machoread.c to use debug_prefixed_printf_cond_nofunc. As
a side effect, the logs are now written to gdb_stdlog. This is part
of PR gdb/7233.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7233
Diffstat (limited to 'gdb/machoread.c')
-rw-r--r-- | gdb/machoread.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/gdb/machoread.c b/gdb/machoread.c index b3bd549..0272ec7 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -37,6 +37,10 @@ /* If non-zero displays debugging message. */ static unsigned int mach_o_debug_level = 0; +#define macho_debug(LEVEL, FMT, ...) \ + debug_prefixed_printf_cond_nofunc (mach_o_debug_level > LEVEL, \ + "machoread", FMT, ## __VA_ARGS__) + /* Dwarf debugging information are never in the final executable. They stay in object files and the executable contains the list of object files read during the link. @@ -421,9 +425,7 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd, /* Per section flag to mark which section have been rebased. */ unsigned char *sections_rebased; - if (mach_o_debug_level > 0) - printf_unfiltered - (_("Loading debugging symbols from oso: %s\n"), oso->name); + macho_debug (0, _("Loading debugging symbols from oso: %s\n"), oso->name); if (!bfd_check_format (abfd.get (), bfd_object)) { @@ -492,13 +494,9 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd, complaint (_("Duplicated symbol %s in symbol table"), sym->name); else { - if (mach_o_debug_level > 4) - { - struct gdbarch *arch = main_objfile->arch (); - printf_unfiltered - (_("Adding symbol %s (addr: %s)\n"), - sym->name, paddress (arch, sym->value)); - } + macho_debug (4, _("Adding symbol %s (addr: %s)\n"), + sym->name, paddress (main_objfile->arch (), + sym->value)); ent->sym = sym; } } @@ -566,14 +564,9 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd, { CORE_ADDR res = addr - sym->value; - if (mach_o_debug_level > 3) - { - struct gdbarch *arch = main_objfile->arch (); - printf_unfiltered - (_("resolve sect %s with %s (set to %s)\n"), - sec->name, sym->name, - paddress (arch, res)); - } + macho_debug (3, _("resolve sect %s with %s (set to %s)\n"), + sec->name, sym->name, + paddress (main_objfile->arch (), res)); bfd_set_section_vma (sec, res); sections_rebased[sec->index] = 1; } @@ -843,8 +836,7 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) { struct bfd_section *asect, *dsect; - if (mach_o_debug_level > 0) - printf_unfiltered (_("dsym file found\n")); + macho_debug (0, _("dsym file found\n")); /* Set dsym section size. */ for (asect = objfile->obfd->sections, dsect = dsym_bfd->sections; @@ -887,9 +879,8 @@ macho_symfile_relocate (struct objfile *objfile, asection *sectp, if ((sectp->flags & SEC_RELOC) == 0) return NULL; - if (mach_o_debug_level > 0) - printf_unfiltered (_("Relocate section '%s' of %s\n"), - sectp->name, objfile_name (objfile)); + macho_debug (0, _("Relocate section '%s' of %s\n"), + sectp->name, objfile_name (objfile)); return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL); } |