aboutsummaryrefslogtreecommitdiff
path: root/gdb/machoread.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/machoread.c')
-rw-r--r--gdb/machoread.c197
1 files changed, 99 insertions, 98 deletions
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 49cf4fd..d577033 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -37,9 +37,9 @@
/* 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__)
+#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
@@ -51,11 +51,11 @@ static unsigned int mach_o_debug_level = 0;
struct oso_el
{
oso_el (asymbol **oso_sym_, asymbol **end_sym_, unsigned int nbr_syms_)
- : name((*oso_sym_)->name),
- mtime((*oso_sym_)->value),
- oso_sym(oso_sym_),
- end_sym(end_sym_),
- nbr_syms(nbr_syms_)
+ : name ((*oso_sym_)->name),
+ mtime ((*oso_sym_)->value),
+ oso_sym (oso_sym_),
+ end_sym (end_sym_),
+ nbr_syms (nbr_syms_)
{
}
@@ -136,7 +136,7 @@ macho_symtab_add_minsym (minimal_symbol_reader &reader,
ms_type = mst_unknown;
}
else
- return; /* Skip this symbol. */
+ return; /* Skip this symbol. */
reader.record_with_info (sym->name, symaddr, ms_type,
gdb_bfd_section_index (objfile->obfd.get (),
@@ -148,8 +148,7 @@ macho_symtab_add_minsym (minimal_symbol_reader &reader,
NUMBER_OF_SYMBOLS for OBJFILE. Registers OSO filenames found. */
static void
-macho_symtab_read (minimal_symbol_reader &reader,
- struct objfile *objfile,
+macho_symtab_read (minimal_symbol_reader &reader, struct objfile *objfile,
long number_of_symbols, asymbol **symbol_table,
std::vector<oso_el> *oso_vector_ptr)
{
@@ -177,12 +176,13 @@ macho_symtab_read (minimal_symbol_reader &reader,
S_DWARF_FILE,
S_STAB_FILE
- } state = S_NO_SO;
+ } state
+ = S_NO_SO;
for (i = 0; i < number_of_symbols; i++)
{
const asymbol *sym = symbol_table[i];
- bfd_mach_o_asymbol *mach_o_sym = (bfd_mach_o_asymbol *)sym;
+ bfd_mach_o_asymbol *mach_o_sym = (bfd_mach_o_asymbol *) sym;
switch (state)
{
@@ -193,7 +193,7 @@ macho_symtab_read (minimal_symbol_reader &reader,
if (sym->name == NULL || sym->name[0] == 0)
{
/* Unexpected empty N_SO. */
- complaint (_("Unexpected empty N_SO stab"));
+ complaint (_ ("Unexpected empty N_SO stab"));
}
else
{
@@ -210,7 +210,7 @@ macho_symtab_read (minimal_symbol_reader &reader,
}
/* Debugging symbols are not expected here. */
- complaint (_("%s: Unexpected debug stab outside SO markers"),
+ complaint (_ ("%s: Unexpected debug stab outside SO markers"),
objfile_name (objfile));
}
else
@@ -227,7 +227,7 @@ macho_symtab_read (minimal_symbol_reader &reader,
if (sym->name == NULL || sym->name[0] == 0)
{
/* Unexpected empty N_SO. */
- complaint (_("Empty SO section"));
+ complaint (_ ("Empty SO section"));
state = S_NO_SO;
}
else if (state == S_FIRST_SO)
@@ -237,7 +237,7 @@ macho_symtab_read (minimal_symbol_reader &reader,
state = S_SECOND_SO;
}
else
- complaint (_("Three SO in a raw"));
+ complaint (_ ("Three SO in a raw"));
}
else if (mach_o_sym->n_type == N_OSO)
{
@@ -246,7 +246,7 @@ macho_symtab_read (minimal_symbol_reader &reader,
/* Empty OSO. Means that this file was compiled with
stabs. */
state = S_STAB_FILE;
- warning (_("stabs debugging not supported for %s"),
+ warning (_ ("stabs debugging not supported for %s"),
file_so->name);
}
else
@@ -258,7 +258,7 @@ macho_symtab_read (minimal_symbol_reader &reader,
}
}
else
- complaint (_("Unexpected stab after SO"));
+ complaint (_ ("Unexpected stab after SO"));
break;
case S_STAB_FILE:
@@ -275,7 +275,7 @@ macho_symtab_read (minimal_symbol_reader &reader,
}
else
{
- complaint (_("Missing nul SO"));
+ complaint (_ ("Missing nul SO"));
file_so = sym;
state = S_FIRST_SO;
}
@@ -303,19 +303,19 @@ macho_symtab_read (minimal_symbol_reader &reader,
case N_GSYM:
break;
default:
- complaint (_("unhandled stab for dwarf OSO file"));
+ complaint (_ ("unhandled stab for dwarf OSO file"));
break;
}
}
}
else
- complaint (_("non-debugging symbol within SO"));
+ complaint (_ ("non-debugging symbol within SO"));
break;
}
}
if (state != S_NO_SO)
- complaint (_("missing nul SO"));
+ complaint (_ ("missing nul SO"));
}
/* If NAME describes an archive member (ie: ARCHIVE '(' MEMBER ')'),
@@ -359,8 +359,7 @@ struct macho_sym_hash_entry
static struct bfd_hash_entry *
macho_sym_hash_newfunc (struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string)
+ struct bfd_hash_table *table, const char *string)
{
struct macho_sym_hash_entry *ret = (struct macho_sym_hash_entry *) entry;
@@ -368,13 +367,13 @@ macho_sym_hash_newfunc (struct bfd_hash_entry *entry,
subclass. */
if (ret == NULL)
ret = (struct macho_sym_hash_entry *) bfd_hash_allocate (table,
- sizeof (* ret));
+ sizeof (*ret));
if (ret == NULL)
return NULL;
/* Call the allocation method of the superclass. */
ret = (struct macho_sym_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string);
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string);
if (ret)
{
@@ -400,7 +399,7 @@ macho_resolve_oso_sym_with_minsym (struct objfile *main_objfile, asymbol *sym)
msym = lookup_minimal_symbol (name, NULL, main_objfile);
if (msym.minsym == NULL)
{
- warning (_("can't find symbol '%s' in minsymtab"), name);
+ warning (_ ("can't find symbol '%s' in minsymtab"), name);
return 0;
}
else
@@ -411,8 +410,7 @@ macho_resolve_oso_sym_with_minsym (struct objfile *main_objfile, asymbol *sym)
static void
macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
- const char *name,
- struct objfile *main_objfile,
+ const char *name, struct objfile *main_objfile,
symfile_add_flags symfile_flags)
{
int storage;
@@ -425,18 +423,18 @@ 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;
- macho_debug (0, _("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))
{
- warning (_("`%s': can't read symbols: %s."), oso->name,
+ warning (_ ("`%s': can't read symbols: %s."), oso->name,
bfd_errmsg (bfd_get_error ()));
return;
}
if (abfd->my_archive == NULL && oso->mtime != bfd_get_mtime (abfd.get ()))
{
- warning (_("`%s': file time stamp mismatch."), oso->name);
+ warning (_ ("`%s': file time stamp mismatch."), oso->name);
return;
}
@@ -444,7 +442,7 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
sizeof (struct macho_sym_hash_entry),
oso->nbr_syms))
{
- warning (_("`%s': can't create hash table"), oso->name);
+ warning (_ ("`%s': can't create hash table"), oso->name);
return;
}
@@ -465,7 +463,7 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
for (symp = oso->oso_sym; symp != oso->end_sym; symp++)
{
const asymbol *sym = *symp;
- bfd_mach_o_asymbol *mach_o_sym = (bfd_mach_o_asymbol *)sym;
+ bfd_mach_o_asymbol *mach_o_sym = (bfd_mach_o_asymbol *) sym;
switch (mach_o_sym->n_type)
{
@@ -488,15 +486,15 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
{
struct macho_sym_hash_entry *ent;
- ent = (struct macho_sym_hash_entry *)
- bfd_hash_lookup (&table, sym->name, TRUE, FALSE);
+ ent = (struct macho_sym_hash_entry *) bfd_hash_lookup (&table,
+ sym->name,
+ TRUE, FALSE);
if (ent->sym != NULL)
- complaint (_("Duplicated symbol %s in symbol table"), sym->name);
+ complaint (_ ("Duplicated symbol %s in symbol table"), sym->name);
else
{
- macho_debug (4, _("Adding symbol %s (addr: %s)\n"),
- sym->name, paddress (main_objfile->arch (),
- sym->value));
+ macho_debug (4, _ ("Adding symbol %s (addr: %s)\n"), sym->name,
+ paddress (main_objfile->arch (), sym->value));
ent->sym = sym;
}
}
@@ -506,12 +504,12 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
for (i = 0; symbol_table[i]; i++)
{
asymbol *sym = symbol_table[i];
- bfd_mach_o_asymbol *mach_o_sym = (bfd_mach_o_asymbol *)sym;
+ bfd_mach_o_asymbol *mach_o_sym = (bfd_mach_o_asymbol *) sym;
if (mach_o_sym->n_type & BFD_MACH_O_N_STAB)
continue;
if ((mach_o_sym->n_type & BFD_MACH_O_N_TYPE) == BFD_MACH_O_N_UNDF
- && sym->value != 0)
+ && sym->value != 0)
{
/* For common symbol use the min symtab and modify the OSO
symbol table. */
@@ -564,7 +562,7 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
{
CORE_ADDR res = addr - sym->value;
- macho_debug (3, _("resolve sect %s with %s (set to %s)\n"),
+ 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);
@@ -583,12 +581,11 @@ macho_add_oso_symfile (oso_el *oso, const gdb_bfd_ref_ptr &abfd,
/* We need to clear SYMFILE_MAINLINE to avoid interactive question
from symfile.c:symbol_file_add_with_addrs_or_offsets. */
- symbol_file_add_from_bfd
- (abfd, name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE),
- NULL,
- main_objfile->flags & (OBJF_REORDERED | OBJF_SHARED
- | OBJF_READNOW | OBJF_USERLOADED),
- main_objfile);
+ symbol_file_add_from_bfd (
+ abfd, name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL,
+ main_objfile->flags
+ & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW | OBJF_USERLOADED),
+ main_objfile);
}
/* Read symbols from the vector of oso files.
@@ -636,26 +633,27 @@ macho_symfile_read_all_oso (std::vector<oso_el> *oso_vector_ptr,
gnutarget));
if (archive_bfd == NULL)
{
- warning (_("Could not open OSO archive file \"%s\""),
+ warning (_ ("Could not open OSO archive file \"%s\""),
archive_name.c_str ());
ix = last_ix;
continue;
}
if (!bfd_check_format (archive_bfd.get (), bfd_archive))
{
- warning (_("OSO archive file \"%s\" not an archive."),
+ warning (_ ("OSO archive file \"%s\" not an archive."),
archive_name.c_str ());
ix = last_ix;
continue;
}
- gdb_bfd_ref_ptr member_bfd
- (gdb_bfd_openr_next_archived_file (archive_bfd.get (), NULL));
+ gdb_bfd_ref_ptr member_bfd (
+ gdb_bfd_openr_next_archived_file (archive_bfd.get (), NULL));
if (member_bfd == NULL)
{
- warning (_("Could not read archive members out of "
- "OSO archive \"%s\""), archive_name.c_str ());
+ warning (_ ("Could not read archive members out of "
+ "OSO archive \"%s\""),
+ archive_name.c_str ());
ix = last_ix;
continue;
}
@@ -676,24 +674,26 @@ macho_symfile_read_all_oso (std::vector<oso_el> *oso_vector_ptr,
&& !memcmp (member_name, oso2->name + pfx_len + 1,
member_len))
{
- macho_add_oso_symfile (oso2, member_bfd,
- bfd_get_filename (member_bfd.get ()),
- main_objfile, symfile_flags);
+ macho_add_oso_symfile (
+ oso2, member_bfd, bfd_get_filename (member_bfd.get ()),
+ main_objfile, symfile_flags);
oso2->name = NULL;
break;
}
}
- member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd.get (),
- member_bfd.get ());
+ member_bfd
+ = gdb_bfd_openr_next_archived_file (archive_bfd.get (),
+ member_bfd.get ());
}
for (ix2 = ix; ix2 < last_ix; ix2++)
{
oso2 = &(*oso_vector_ptr)[ix2];
if (oso2->name != NULL)
- warning (_("Could not find specified archive member "
- "for OSO name \"%s\""), oso->name);
+ warning (_ ("Could not find specified archive member "
+ "for OSO name \"%s\""),
+ oso->name);
}
ix = last_ix;
}
@@ -701,7 +701,7 @@ macho_symfile_read_all_oso (std::vector<oso_el> *oso_vector_ptr,
{
gdb_bfd_ref_ptr abfd (gdb_bfd_open (oso->name, gnutarget));
if (abfd == NULL)
- warning (_("`%s': can't open to read symbols: %s."), oso->name,
+ warning (_ ("`%s': can't open to read symbols: %s."), oso->name,
bfd_errmsg (bfd_get_error ()));
else
macho_add_oso_symfile (oso, abfd, oso->name, main_objfile,
@@ -742,35 +742,37 @@ macho_check_dsym (struct objfile *objfile, std::string *filenamep)
if (access (dsym_filename, R_OK) != 0)
return NULL;
- if (bfd_mach_o_lookup_command (objfile->obfd.get (),
- BFD_MACH_O_LC_UUID, &main_uuid) == 0)
+ if (bfd_mach_o_lookup_command (objfile->obfd.get (), BFD_MACH_O_LC_UUID,
+ &main_uuid)
+ == 0)
{
- warning (_("can't find UUID in %s"), objfile_name (objfile));
+ warning (_ ("can't find UUID in %s"), objfile_name (objfile));
return NULL;
}
gdb_bfd_ref_ptr dsym_bfd (gdb_bfd_openr (dsym_filename, gnutarget));
if (dsym_bfd == NULL)
{
- warning (_("can't open dsym file %s"), dsym_filename);
+ warning (_ ("can't open dsym file %s"), dsym_filename);
return NULL;
}
if (!bfd_check_format (dsym_bfd.get (), bfd_object))
{
- warning (_("bad dsym file format: %s"), bfd_errmsg (bfd_get_error ()));
+ warning (_ ("bad dsym file format: %s"), bfd_errmsg (bfd_get_error ()));
return NULL;
}
- if (bfd_mach_o_lookup_command (dsym_bfd.get (),
- BFD_MACH_O_LC_UUID, &dsym_uuid) == 0)
+ if (bfd_mach_o_lookup_command (dsym_bfd.get (), BFD_MACH_O_LC_UUID,
+ &dsym_uuid)
+ == 0)
{
- warning (_("can't find UUID in %s"), dsym_filename);
+ warning (_ ("can't find UUID in %s"), dsym_filename);
return NULL;
}
if (memcmp (dsym_uuid->command.uuid.uuid, main_uuid->command.uuid.uuid,
sizeof (main_uuid->command.uuid.uuid)))
{
- warning (_("dsym file UUID doesn't match the one in %s"),
+ warning (_ ("dsym file UUID doesn't match the one in %s"),
objfile_name (objfile));
return NULL;
}
@@ -798,7 +800,7 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
/* Process the normal symbol table first. */
storage_needed = bfd_get_symtab_upper_bound (objfile->obfd.get ());
if (storage_needed < 0)
- error (_("Can't read symbols from %s: %s"),
+ error (_ ("Can't read symbols from %s: %s"),
bfd_get_filename (objfile->obfd.get ()),
bfd_errmsg (bfd_get_error ()));
@@ -814,7 +816,7 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
symbol_table.data ());
if (symcount < 0)
- error (_("Can't read symbols from %s: %s"),
+ error (_ ("Can't read symbols from %s: %s"),
bfd_get_filename (objfile->obfd.get ()),
bfd_errmsg (bfd_get_error ()));
@@ -836,12 +838,11 @@ macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
struct bfd_section *asect, *dsect;
- macho_debug (0, _("dsym file found\n"));
+ macho_debug (0, _ ("dsym file found\n"));
/* Set dsym section size. */
for (asect = objfile->obfd->sections, dsect = dsym_bfd->sections;
- asect && dsect;
- asect = asect->next, dsect = dsect->next)
+ asect && dsect; asect = asect->next, dsect = dsect->next)
{
if (strcmp (asect->name, dsect->name) != 0)
break;
@@ -879,8 +880,8 @@ macho_symfile_relocate (struct objfile *objfile, asection *sectp,
if ((sectp->flags & SEC_RELOC) == 0)
return NULL;
- macho_debug (0, _("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);
}
@@ -891,14 +892,14 @@ macho_symfile_finish (struct objfile *objfile)
}
static void
-macho_symfile_offsets (struct objfile *objfile,
- const section_addr_info &addrs)
+macho_symfile_offsets (struct objfile *objfile, const section_addr_info &addrs)
{
unsigned int i;
struct obj_section *osect;
/* Allocate section_offsets. */
- objfile->section_offsets.assign (gdb_bfd_count_sections (objfile->obfd.get ()), 0);
+ objfile->section_offsets.assign (
+ gdb_bfd_count_sections (objfile->obfd.get ()), 0);
/* This code is run when we first add the objfile with
symfile_add_with_addrs_or_offsets, when "addrs" not "offsets" are
@@ -928,7 +929,8 @@ macho_symfile_offsets (struct objfile *objfile,
ALL_OBJFILE_OSECTIONS (objfile, osect)
{
const char *bfd_sect_name = osect->the_bfd_section->name;
- int sect_index = osect - objfile->sections;;
+ int sect_index = osect - objfile->sections;
+ ;
if (startswith (bfd_sect_name, "LC_SEGMENT."))
bfd_sect_name += 11;
@@ -939,27 +941,26 @@ macho_symfile_offsets (struct objfile *objfile,
}
static const struct sym_fns macho_sym_fns = {
- macho_new_init, /* init anything gbl to entire symtab */
- macho_symfile_init, /* read initial info, setup for sym_read() */
- macho_symfile_read, /* read a symbol file into symtab */
- macho_symfile_finish, /* finished with file, cleanup */
- macho_symfile_offsets, /* xlate external to internal form */
- default_symfile_segments, /* Get segment information from a file. */
+ macho_new_init, /* init anything gbl to entire symtab */
+ macho_symfile_init, /* read initial info, setup for sym_read() */
+ macho_symfile_read, /* read a symbol file into symtab */
+ macho_symfile_finish, /* finished with file, cleanup */
+ macho_symfile_offsets, /* xlate external to internal form */
+ default_symfile_segments, /* Get segment information from a file. */
NULL,
- macho_symfile_relocate, /* Relocate a debug section. */
- NULL, /* sym_get_probes */
+ macho_symfile_relocate, /* Relocate a debug section. */
+ NULL, /* sym_get_probes */
};
void _initialize_machoread ();
+
void
_initialize_machoread ()
{
add_symtab_fns (bfd_target_mach_o_flavour, &macho_sym_fns);
- add_setshow_zuinteger_cmd ("mach-o", class_obscure,
- &mach_o_debug_level,
- _("Set if printing Mach-O symbols processing."),
- _("Show if printing Mach-O symbols processing."),
- NULL, NULL, NULL,
- &setdebuglist, &showdebuglist);
+ add_setshow_zuinteger_cmd ("mach-o", class_obscure, &mach_o_debug_level,
+ _ ("Set if printing Mach-O symbols processing."),
+ _ ("Show if printing Mach-O symbols processing."),
+ NULL, NULL, NULL, &setdebuglist, &showdebuglist);
}