/* Darwin support for GDB, the GNU debugger.
- Copyright (C) 2008-2021 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
Contributed by AdaCore.
/* 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.
/* 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))
{
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;
}
}
{
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;
}
{
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;
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);
}
struct obj_section *osect;
/* Allocate section_offsets. */
- objfile->section_offsets.assign (bfd_count_sections (objfile->obfd), 0);
+ objfile->section_offsets.assign (gdb_bfd_count_sections (objfile->obfd), 0);
/* This code is run when we first add the objfile with
symfile_add_with_addrs_or_offsets, when "addrs" not "offsets" are
if (bfd_sect_name == addrs[i].name)
{
- obj_section_offset (osect) = addrs[i].addr;
+ osect->set_offset (addrs[i].addr);
break;
}
}