2008-11-27 09:23:01 +00:00
|
|
|
/* Darwin support for GDB, the GNU debugger.
|
2014-01-01 03:54:24 +00:00
|
|
|
Copyright (C) 2008-2014 Free Software Foundation, Inc.
|
2008-11-27 09:23:01 +00:00
|
|
|
|
|
|
|
Contributed by AdaCore.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2013-06-07 14:39:33 +00:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2008-11-27 09:23:01 +00:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "symfile.h"
|
|
|
|
#include "objfiles.h"
|
|
|
|
#include "buildsym.h"
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "mach-o.h"
|
|
|
|
#include "gdb_assert.h"
|
|
|
|
#include "aout/stab_gnu.h"
|
|
|
|
#include "vec.h"
|
gdb
* xcoffread.c: Include psymtab.h.
(xcoff_sym_fns): Update.
* symtab.h (struct partial_symbol): Remove.
(PSYMBOL_DOMAIN, PSYMBOL_CLASS): Remove.
(struct partial_symtab): Remove.
(PSYMTAB_TO_SYMTAB): Remove.
(lookup_partial_symbol, lookup_partial_symtab, find_pc_psymtab)
(find_pc_sect_psymtab): Remove.
(find_pc_sect_symtab_via_partial): Declare.
(find_pc_psymtab, find_pc_sect_psymbol, psymtab_to_symtab)
(find_main_psymtab): Remove.
(find_main_filename): Declare.
(fixup_psymbol_section): Remove.
(fixup_section): Declare.
* symtab.c: Include psymtab.h.
(lookup_symtab): Use lookup_symtab method.
(lookup_partial_symtab): Remove.
(find_pc_sect_psymtab_closer): Remove.
(find_pc_sect_psymtab): Remove.
(find_pc_sect_symtab_via_partial): New function.
(find_pc_psymtab, find_pc_sect_psymbol, find_pc_psymbol): Remove.
(fixup_section): No longer static.
(fixup_psymbol_section): Remove.
(lookup_symbol_aux): Use lookup_symbol_aux_quick.
(lookup_global_symbol_from_objfile): Likewise.
(lookup_symbol_aux_psymtabs): Remove.
(lookup_symbol_aux_quick): New function.
(lookup_symbol_global): Use lookup_symbol_aux_quick.
(lookup_partial_symbol): Remove.
(basic_lookup_transparent_type_quick): New function.
(basic_lookup_transparent_type): Use it.
(find_main_psymtab): Remove.
(find_main_filename): New function.
(find_pc_sect_symtab): Use find_pc_sect_symtab method.
(find_line_symtab): Use expand_symtabs_with_filename method.
(output_partial_symbol_filename): New function.
(sources_info): Use map_partial_symbol_filenames.
(struct search_symbols_data): New type.
(search_symbols_file_matches): New function.
(search_symbols_name_matches): Likewise.
(search_symbols): Use expand_symtabs_matching method.
(struct add_name_data): Rename from add_macro_name_data.
(add_macro_name): Update.
(add_partial_symbol_name): New function.
(default_make_symbol_completion_list): Use
map_partial_symbol_names.
(struct add_partial_symbol_name): New type.
(maybe_add_partial_symtab_filename): New function.
(make_source_files_completion_list): Use
map_partial_symbol_filenames.
(expand_line_sal): Use expand_symtabs_with_filename method.
* symmisc.c: Include psymtab.h.
(print_objfile_statistics): Use print_stats method.
(dump_objfile): Use dump method.
(dump_psymtab, maintenance_print_psymbols)
(maintenance_info_psymtabs, maintenance_check_symtabs)
(extend_psymbol_list): Remove.
* symfile.h (struct quick_symbol_functions): New struct.
(struct sym_fns) <qf>: New field.
(sort_pst_symbols): Remove.
(increment_reading_symtab): Declare.
* symfile.c: Include psymtab.h.
(compare_psymbols, sort_pst_symbols): Remove.
(psymtab_to_symtab): Remove.
(increment_reading_symtab): New function.
(symbol_file_add_with_addrs_or_offsets): Use expand_all_symtabs
method.
(set_initial_language): Use find_main_filename.
(allocate_psymtab, discard_psymtab, cashier_psymtab): Remove.
(free_named_symtabs): Remove unused code.
(start_psymtab_common, add_psymbol_to_bcache)
(append_psymbol_to_list, add_psymbol_to_list, init_psymbol_list):
Remove.
* stack.c: Include psymtab.h, symfile.h.
(backtrace_command_1): Use find_pc_sect_symtab_via_partial.
* source.h (psymtab_to_fullname): Don't declare.
* source.c: Include psymtab.h.
(select_source_symtab): Use find_last_source_symtab method.
(forget_cached_source_info): Use forget_cached_source_info
method.
(find_and_open_source): No longer static.
(psymtab_to_fullname): Remove.
* somread.c: Include psymtab.h.
(som_sym_fns): Update.
* psympriv.h: New file.
* psymtab.h: New file.
* psymtab.c: New file.
* objfiles.h: (ALL_OBJFILE_PSYMTABS): Remove.
(ALL_PSYMTABS, ALL_PSPACE_PSYMTABS): Likewise.
* objfiles.c: Include psymtab.h.
(objfile_relocate1): Use relocate method.
(objfile_has_partial_symbols): Use has_symbols method.
* mipsread.c: Include psymtab.h.
(ecoff_sym_fns): Update.
* mi/mi-cmd-file.c: Include psymtab.h.
(print_partial_file_name): New function.
(mi_cmd_file_list_exec_source_files): Use
map_partial_symbol_filenames.
* mdebugread.c: Include psympriv.h.
* machoread.c: Include psympriv.h.
(macho_sym_fns): Update.
* m2-exp.y (yylex): Use lookup_symtab.
* elfread.c: Include psympriv.h.
(elf_sym_fns): Update.
* dwarf2read.c: Include psympriv.h.
* dbxread.c: Include psympriv.h.
(aout_sym_fns): Update.
* cp-support.c: Include psymtab.h.
(read_in_psymtabs): Remove.
(make_symbol_overload_list_qualified): Use
expand_symtabs_for_function method.
* coffread.c: Include psympriv.h.
(coff_sym_fns): Update.
* blockframe.c: Include psymtab.h.
(find_pc_partial_function): Use find_pc_sect_symtab method.
* ada-lang.h (ada_update_initial_language): Update.
* ada-lang.c: Include psymtab.h.
(ada_update_initial_language): Remove 'main_pst' argument.
(ada_lookup_partial_symbol): Remove.
(struct ada_psym_data): New type.
(ada_add_psyms): New function.
(ada_add_non_local_symbols): Use map_ada_symtabs method.
(struct add_partial_datum): New type.
(ada_add_partial_symbol_completions): New function.
(ada_make_symbol_completion_list): Use map_partial_symbol_names.
(ada_exception_support_info_sniffer): Update.
* Makefile.in (SFILES): Add psymtab.c.
(COMMON_OBS): Add psymtab.o.
(HFILES_NO_SRCDIR): Add psymtab.h, psympriv.h.
gdb/doc
* gdbint.texinfo (Symbol Handling): Update.
2010-03-10 18:20:08 +00:00
|
|
|
#include "psympriv.h"
|
2011-11-24 16:26:25 +00:00
|
|
|
#include "complaints.h"
|
2012-07-26 09:00:42 +00:00
|
|
|
#include "gdb_bfd.h"
|
2008-11-27 09:23:01 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/* If non-zero displays debugging message. */
|
2012-08-02 09:36:40 +00:00
|
|
|
static unsigned int mach_o_debug_level = 0;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
Each time an oso (other source) is found in the executable, the reader
|
|
|
|
creates such a structure. They are read after the processing of the
|
2011-01-09 03:20:33 +00:00
|
|
|
executable. */
|
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
typedef struct oso_el
|
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Object file name. Can also be a member name. */
|
2008-11-27 09:23:01 +00:00
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* Associated time stamp. */
|
|
|
|
unsigned long mtime;
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Stab symbols range for this OSO. */
|
|
|
|
asymbol **oso_sym;
|
|
|
|
asymbol **end_sym;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Number of interesting stabs in the range. */
|
|
|
|
unsigned int nbr_syms;
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
oso_el;
|
|
|
|
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
/* Vector of object files to be read after the executable. */
|
2008-11-27 09:23:01 +00:00
|
|
|
DEF_VEC_O (oso_el);
|
|
|
|
|
2010-02-04 12:45:49 +00:00
|
|
|
static void
|
|
|
|
macho_new_init (struct objfile *objfile)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
macho_symfile_init (struct objfile *objfile)
|
|
|
|
{
|
|
|
|
objfile->flags |= OBJF_REORDERED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a new OSO to the vector of OSO to load. */
|
2009-10-13 09:42:57 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
static void
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
macho_register_oso (VEC (oso_el) **oso_vector_ptr,
|
|
|
|
struct objfile *objfile,
|
2011-11-24 16:26:25 +00:00
|
|
|
asymbol **oso_sym, asymbol **end_sym,
|
|
|
|
unsigned int nbr_syms)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
|
|
|
oso_el el;
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
el.name = (*oso_sym)->name;
|
|
|
|
el.mtime = (*oso_sym)->value;
|
|
|
|
el.oso_sym = oso_sym;
|
|
|
|
el.end_sym = end_sym;
|
|
|
|
el.nbr_syms = nbr_syms;
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
VEC_safe_push (oso_el, *oso_vector_ptr, &el);
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Add symbol SYM to the minimal symbol table of OBJFILE. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
macho_symtab_add_minsym (struct objfile *objfile, const asymbol *sym)
|
|
|
|
{
|
|
|
|
if (sym->name == NULL || *sym->name == '\0')
|
|
|
|
{
|
|
|
|
/* Skip names that don't exist (shouldn't happen), or names
|
|
|
|
that are null strings (may happen). */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sym->flags & (BSF_GLOBAL | BSF_LOCAL | BSF_WEAK))
|
|
|
|
{
|
|
|
|
CORE_ADDR symaddr;
|
|
|
|
enum minimal_symbol_type ms_type;
|
|
|
|
|
|
|
|
/* Bfd symbols are section relative. */
|
|
|
|
symaddr = sym->value + sym->section->vma;
|
|
|
|
|
2012-05-05 03:05:32 +00:00
|
|
|
if (sym->section == bfd_abs_section_ptr)
|
2011-11-24 16:26:25 +00:00
|
|
|
ms_type = mst_abs;
|
|
|
|
else if (sym->section->flags & SEC_CODE)
|
|
|
|
{
|
|
|
|
if (sym->flags & (BSF_GLOBAL | BSF_WEAK))
|
|
|
|
ms_type = mst_text;
|
|
|
|
else
|
|
|
|
ms_type = mst_file_text;
|
|
|
|
}
|
|
|
|
else if (sym->section->flags & SEC_ALLOC)
|
|
|
|
{
|
|
|
|
if (sym->flags & (BSF_GLOBAL | BSF_WEAK))
|
|
|
|
{
|
|
|
|
if (sym->section->flags & SEC_LOAD)
|
|
|
|
ms_type = mst_data;
|
|
|
|
else
|
|
|
|
ms_type = mst_bss;
|
|
|
|
}
|
|
|
|
else if (sym->flags & BSF_LOCAL)
|
|
|
|
{
|
|
|
|
/* Not a special stabs-in-elf symbol, do regular
|
|
|
|
symbol processing. */
|
|
|
|
if (sym->section->flags & SEC_LOAD)
|
|
|
|
ms_type = mst_file_data;
|
|
|
|
else
|
|
|
|
ms_type = mst_file_bss;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ms_type = mst_unknown;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return; /* Skip this symbol. */
|
|
|
|
|
|
|
|
prim_record_minimal_symbol_and_info
|
2013-04-08 20:04:42 +00:00
|
|
|
(sym->name, symaddr, ms_type,
|
|
|
|
gdb_bfd_section_index (objfile->obfd, sym->section),
|
2013-04-08 20:13:22 +00:00
|
|
|
objfile);
|
2011-11-24 16:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
/* Build the minimal symbol table from SYMBOL_TABLE of length
|
2011-11-24 16:26:25 +00:00
|
|
|
NUMBER_OF_SYMBOLS for OBJFILE. Registers OSO filenames found. */
|
2009-10-13 09:42:57 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
static void
|
|
|
|
macho_symtab_read (struct objfile *objfile,
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
long number_of_symbols, asymbol **symbol_table,
|
|
|
|
VEC (oso_el) **oso_vector_ptr)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
long i;
|
|
|
|
const asymbol *dir_so = NULL;
|
|
|
|
const asymbol *file_so = NULL;
|
|
|
|
asymbol **oso_file = NULL;
|
2012-02-16 14:57:02 +00:00
|
|
|
unsigned int nbr_syms = 0;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Current state while reading stabs. */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
/* Not within an SO part. Only non-debugging symbols should be present,
|
|
|
|
and will be added to the minimal symbols table. */
|
|
|
|
S_NO_SO,
|
2009-06-19 Tristan Gingold <gingold@adacore.com>
* machoread.c (macho_symtab_read): Adjust for bfd changes.
* darwin-nat.h (struct darwin_exception_msg): New type to describe
a mach exception.
(struct private_thread_info): New type to describe the state of the
thread.
(DEF_VEC_I thread_t): Removed, replaced by ...
(DEF_VEC_O darwin_thread_t): ... this new type.
(struct darwin_inferior): Renamed to ...
(struct private_inferior): ... this type. Fields added.
(darwin_not_port): Moved into the private inferior structure.
* darwin-nat.c: Add includes, improve comments.
Rewrite to handle multiple threads and processes.
(darwin_resume_to): New function and protype.
(darwin_resume, darwin_wait_to, darwin_wait): Ditto.
(darwin_kill_inferior): Add ops argument.
(darwin_pid_to_str): New function.
(darwin_thread_alive): Ditto.
(darwin_inf, darwin_not_port): Removed.
(darwin_inf_fake_stop): New variable.
(msgin, msgout, msg_state, exc_msg): Removed.
(mach_check_error): Use warning instead of error.
(darwin_ptrace): Adjust debug level.
(cmp_thread_t): Fix names (typo).
(darwin_check_new_threads): Argument is now an inferior,
adjust for new structures, add no change check, ignore dead ports,
handle first thread case.
(find_inferior_task_it): New function.
(find_inferior_notify_it): Ditto.
(darwin_find_inferior_by_task): Ditto.
(darwin_find_inferior_by_notify): Ditto.
(darwin_find_thread): Ditto.
(darwin_suspend_inferior): Ditto.
(darwin_resume_inferior): Ditto.
(catch_exception_raise_state): Removed.
(catch_exception_raise_state_identity): Removed.
(darwin_suspend_inferior_it): New function.
(darwin_resume_inferior_it): Ditto.
(darwin_dump_message): New function, extracted from darwin_wait.
(darwin_decode_exception_message): New function.
(darwin_encode_reply): New function.
(catch_exception_raise): Removed.
(darwin_send_reply): New function, extracted from darwin_resume.
(darwin_resume_thread): New function, extracted from darwin_resume.
(struct resume_inferior_threads_param): New type.
(darwin_resume_inferior_threads_it): New function.
(darwin_resume_inferior_threads): New function.
(darwin_suspend_inferior_threads): New function.
(darwin_resume): Mostly rewritten to handle multiple threads and
some corner cases.
(darwin_decode_message): New function extracted from darwin_wait.
(cancel_breakpoint): New function.
(darwin_wait): Mostly rewritten. Handle multiple threads.
(darwin_mourn_inferior): Adjust for per process structures.
(darwin_reply_to_all_pending_messages): New function.
(darwin_stop_inferior): Adjust for per inferior structures.
(darwin_attach_pid): Ditto.
(darwin_init_thread_list): Ditto.
(darwin_attach): Ditto.
(darwin_detach): Ditto.
(darwin_files_info): Now empty.
(darwin_pid_to_str): Adjust returns string to match one expected by
the testsuite.
(darwin_read_write_inferior): Rename err variable to match other uses.
Adjust debug message. Handle submaps.
(darwin_xfer_memory): Adjust for per inferior structures.
(set_enable_mach_exceptions): Ditto.
(darwin_pid_to_exec_file): New function.
(darwin_get_ada_task_ptid): Ditto.
(darwin_supports_multi_process): Ditto.
(_initialize_darwin_inferior): Remove useless assertion, adjust for
per inferior structures. Add new target operations.
2009-06-19 14:30:30 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* First SO read. Introduce an SO section, and may be followed by a second
|
|
|
|
SO. The SO section should contain onl debugging symbols. */
|
|
|
|
S_FIRST_SO,
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Second non-null SO found, just after the first one. Means that the first
|
|
|
|
is in fact a directory name. */
|
|
|
|
S_SECOND_SO,
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Non-null OSO found. Debugging info are DWARF in this OSO file. */
|
|
|
|
S_DWARF_FILE,
|
2009-12-15 09:37:14 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
S_STAB_FILE
|
|
|
|
} state = S_NO_SO;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
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;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case S_NO_SO:
|
|
|
|
if (mach_o_sym->n_type == N_SO)
|
|
|
|
{
|
|
|
|
/* Start of object stab. */
|
|
|
|
if (sym->name == NULL || sym->name[0] == 0)
|
|
|
|
{
|
|
|
|
/* Unexpected empty N_SO. */
|
|
|
|
complaint (&symfile_complaints,
|
|
|
|
_("Unexpected empty N_SO stab"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file_so = sym;
|
|
|
|
dir_so = NULL;
|
|
|
|
state = S_FIRST_SO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sym->flags & BSF_DEBUGGING)
|
|
|
|
{
|
2011-12-07 09:11:25 +00:00
|
|
|
if (mach_o_sym->n_type == N_OPT)
|
|
|
|
{
|
|
|
|
/* No complaint for OPT. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Debugging symbols are not expected here. */
|
|
|
|
complaint (&symfile_complaints,
|
2011-12-07 09:11:25 +00:00
|
|
|
_("%s: Unexpected debug stab outside SO markers"),
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 13:57:38 +00:00
|
|
|
objfile_name (objfile));
|
2011-11-24 16:26:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Non-debugging symbols go to the minimal symbol table. */
|
|
|
|
macho_symtab_add_minsym (objfile, sym);
|
|
|
|
}
|
|
|
|
break;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
case S_FIRST_SO:
|
|
|
|
case S_SECOND_SO:
|
|
|
|
if (mach_o_sym->n_type == N_SO)
|
|
|
|
{
|
|
|
|
if (sym->name == NULL || sym->name[0] == 0)
|
|
|
|
{
|
|
|
|
/* Unexpected empty N_SO. */
|
|
|
|
complaint (&symfile_complaints, _("Empty SO section"));
|
|
|
|
state = S_NO_SO;
|
|
|
|
}
|
|
|
|
else if (state == S_FIRST_SO)
|
|
|
|
{
|
|
|
|
/* Second SO stab for the file name. */
|
|
|
|
dir_so = file_so;
|
|
|
|
file_so = sym;
|
|
|
|
state = S_SECOND_SO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
complaint (&symfile_complaints, _("Three SO in a raw"));
|
|
|
|
}
|
|
|
|
else if (mach_o_sym->n_type == N_OSO)
|
|
|
|
{
|
|
|
|
if (sym->name == NULL || sym->name[0] == 0)
|
|
|
|
{
|
|
|
|
/* Empty OSO. Means that this file was compiled with
|
|
|
|
stabs. */
|
|
|
|
state = S_STAB_FILE;
|
|
|
|
warning (_("stabs debugging not supported for %s"),
|
|
|
|
file_so->name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Non-empty OSO for a Dwarf file. */
|
|
|
|
oso_file = symbol_table + i;
|
|
|
|
nbr_syms = 0;
|
|
|
|
state = S_DWARF_FILE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
complaint (&symfile_complaints,
|
|
|
|
_("Unexpected stab after SO"));
|
|
|
|
break;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
case S_STAB_FILE:
|
|
|
|
case S_DWARF_FILE:
|
|
|
|
if (mach_o_sym->n_type == N_SO)
|
|
|
|
{
|
|
|
|
if (sym->name == NULL || sym->name[0] == 0)
|
|
|
|
{
|
|
|
|
/* End of file. */
|
|
|
|
if (state == S_DWARF_FILE)
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
macho_register_oso (oso_vector_ptr, objfile,
|
|
|
|
oso_file, symbol_table + i,
|
2011-11-24 16:26:25 +00:00
|
|
|
nbr_syms);
|
|
|
|
state = S_NO_SO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
complaint (&symfile_complaints, _("Missing nul SO"));
|
|
|
|
file_so = sym;
|
|
|
|
dir_so = NULL;
|
|
|
|
state = S_FIRST_SO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sym->flags & BSF_DEBUGGING)
|
|
|
|
{
|
|
|
|
if (state == S_STAB_FILE)
|
|
|
|
{
|
|
|
|
/* FIXME: to be implemented. */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (mach_o_sym->n_type)
|
|
|
|
{
|
|
|
|
case N_FUN:
|
|
|
|
if (sym->name == NULL || sym->name[0] == 0)
|
|
|
|
break;
|
|
|
|
/* Fall through. */
|
|
|
|
case N_STSYM:
|
|
|
|
/* Interesting symbol. */
|
|
|
|
nbr_syms++;
|
|
|
|
break;
|
|
|
|
case N_ENSYM:
|
|
|
|
case N_BNSYM:
|
|
|
|
case N_GSYM:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
complaint (&symfile_complaints,
|
|
|
|
_("unhandled stab for dwarf OSO file"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
complaint (&symfile_complaints,
|
|
|
|
_("non-debugging symbol within SO"));
|
|
|
|
break;
|
|
|
|
}
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
if (state != S_NO_SO)
|
|
|
|
complaint (&symfile_complaints, _("missing nul SO"));
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If NAME describes an archive member (ie: ARCHIVE '(' MEMBER ')'),
|
|
|
|
returns the length of the archive name.
|
|
|
|
Returns -1 otherwise. */
|
2009-10-13 09:42:57 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
static int
|
|
|
|
get_archive_prefix_len (const char *name)
|
|
|
|
{
|
|
|
|
char *lparen;
|
|
|
|
int name_len = strlen (name);
|
|
|
|
|
|
|
|
if (name_len == 0 || name[name_len - 1] != ')')
|
|
|
|
return -1;
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
lparen = strrchr (name, '(');
|
|
|
|
if (lparen == NULL || lparen == name)
|
|
|
|
return -1;
|
|
|
|
return lparen - name;
|
|
|
|
}
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Compare function to qsort OSOs, so that members of a library are
|
|
|
|
gathered. */
|
|
|
|
|
2009-10-13 09:42:57 +00:00
|
|
|
static int
|
|
|
|
oso_el_compare_name (const void *vl, const void *vr)
|
|
|
|
{
|
|
|
|
const oso_el *l = (const oso_el *)vl;
|
|
|
|
const oso_el *r = (const oso_el *)vr;
|
|
|
|
|
|
|
|
return strcmp (l->name, r->name);
|
|
|
|
}
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Hash table entry structure for the stabs symbols in the main object file.
|
|
|
|
This is used to speed up lookup for symbols in the OSO. */
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
struct macho_sym_hash_entry
|
|
|
|
{
|
|
|
|
struct bfd_hash_entry base;
|
|
|
|
const asymbol *sym;
|
|
|
|
};
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Routine to create an entry in the hash table. */
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
static struct bfd_hash_entry *
|
|
|
|
macho_sym_hash_newfunc (struct bfd_hash_entry *entry,
|
|
|
|
struct bfd_hash_table *table,
|
|
|
|
const char *string)
|
2011-07-01 18:36:36 +00:00
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
struct macho_sym_hash_entry *ret = (struct macho_sym_hash_entry *) entry;
|
|
|
|
|
|
|
|
/* Allocate the structure if it has not already been allocated by a
|
|
|
|
subclass. */
|
|
|
|
if (ret == NULL)
|
|
|
|
ret = (struct macho_sym_hash_entry *) bfd_hash_allocate (table,
|
|
|
|
sizeof (* ret));
|
|
|
|
if (ret == NULL)
|
|
|
|
return NULL;
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Call the allocation method of the superclass. */
|
|
|
|
ret = (struct macho_sym_hash_entry *)
|
|
|
|
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string);
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
if (ret)
|
2011-07-01 18:36:36 +00:00
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Initialize the local fields. */
|
|
|
|
ret->sym = NULL;
|
|
|
|
}
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
return (struct bfd_hash_entry *) ret;
|
|
|
|
}
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Get the value of SYM from the minimal symtab of MAIN_OBJFILE. This is used
|
|
|
|
to get the value of global and common symbols. */
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
static CORE_ADDR
|
|
|
|
macho_resolve_oso_sym_with_minsym (struct objfile *main_objfile, asymbol *sym)
|
|
|
|
{
|
|
|
|
/* For common symbol and global symbols, use the min symtab. */
|
use bound_minsym as result for lookup_minimal_symbol et al
This patch changes a few minimal symbol lookup functions to return a
bound_minimal_symbol rather than a pointer to the minsym. This change
helps prepare gdb for computing a minimal symbol's address at the
point of use.
Note that this changes even those functions that ostensibly search a
single objfile. That was necessary because, in fact, those functions
can search an objfile and its separate debug objfiles; and it is
important for the caller to know in which objfile the minimal symbol
was actually found.
The bulk of this patch is mechanical.
2014-02-26 Tom Tromey <tromey@redhat.com>
* ada-lang.c (ada_update_initial_language): Update.
(ada_main_name, ada_has_this_exception_support): Update.
* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
* arm-tdep.c (arm_skip_stub): Update.
* auxv.c (ld_so_xfer_auxv): Update.
* avr-tdep.c (avr_scan_prologue): Update.
* ax-gdb.c (gen_var_ref): Update.
* breakpoint.c (struct breakpoint_objfile_data)
<overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change
type to bound_minimal_symbol.
(create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Update.
* bsd-uthread.c (bsd_uthread_lookup_address): Update.
* c-exp.y (classify_name): Update.
* coffread.c (coff_symfile_read): Update.
* common/agent.c (agent_look_up_symbols): Update.
* d-lang.c (d_main_name): Update.
* dbxread.c (find_stab_function_addr, end_psymtab): Update.
* dec-thread.c (enable_dec_thread): Update.
* dwarf2loc.c (call_site_to_target_addr): Update.
* elfread.c (elf_gnu_ifunc_resolve_by_got): Update.
* eval.c (evaluate_subexp_standard): Update.
* findvar.c (struct minsym_lookup_data) <result>: Change type
to bound_minimal_symbol.
<objfile>: Remove.
(minsym_lookup_iterator_cb, default_read_var_value): Update.
* frame.c (inside_main_func): Update.
* frv-tdep.c (frv_frame_this_id): Update.
* gcore.c (call_target_sbrk): Update.
* glibc-tdep.c (glibc_skip_solib_resolver): Update.
* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
Update.
* go-lang.c (go_main_name): Update.
* hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code)
(hppa_hpux_find_import_stub_for_addr): Update.
* hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol):
Update. Change return type.
* hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return
type.
* jit.c (jit_breakpoint_re_set_internal): Update.
* linux-fork.c (inferior_call_waitpid, checkpoint_command):
Update.
* linux-nat.c (get_signo): Update.
* linux-thread-db.c (inferior_has_bug): Update
* m32c-tdep.c (m32c_return_value)
(m32c_m16c_address_to_pointer): Update.
* m32r-tdep.c (m32r_frame_this_id): Update.
* m68hc11-tdep.c (m68hc11_get_register_info): Update.
* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
* minsyms.c (lookup_minimal_symbol_internal): Rename to
lookup_minimal_symbol. Change return type.
(lookup_minimal_symbol): Remove.
(lookup_bound_minimal_symbol): Update.
(lookup_minimal_symbol_text): Change return type.
(lookup_minimal_symbol_solib_trampoline): Change return type.
* minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text)
(lookup_minimal_symbol_solib_trampoline): Change return type.
* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(value_nsstring, find_imps): Update.
* obsd-tdep.c (obsd_skip_solib_resolver): Update.
* p-lang.c (pascal_main_name): Update.
* ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update.
* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
* proc-service.c (ps_pglobal_lookup): Update.
* ravenscar-thread.c (get_running_thread_msymbol): Change
return type.
(has_ravenscar_runtime, get_running_thread_id): Update.
* remote.c (remote_check_symbols): Update.
* sol-thread.c (ps_pglobal_lookup): Update.
* sol2-tdep.c (sol2_skip_solib_resolver): Update.
* solib-dsbt.c (lm_base): Update.
* solib-frv.c (lm_base, frv_relocate_section_addresses):
Update.
* solib-irix.c (locate_base): Update.
* solib-som.c (som_solib_create_inferior_hook)
(som_solib_desire_dynamic_linker_symbols, link_map_start):
Update.
* solib-spu.c (spu_enable_break): Update.
* solib-svr4.c (elf_locate_base, enable_break): Update.
* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
(flush_ea_cache): Update.
* stabsread.c (define_symbol): Update.
* symfile.c (simple_read_overlay_table): Update.
* symtab.c (find_pc_sect_line): Update.
* tracepoint.c (scope_info): Update.
* tui-disasm.c (tui_get_begin_asm_address): Update.
* value.c (value_static_field): Update.
2013-10-15 01:53:29 +00:00
|
|
|
struct bound_minimal_symbol msym;
|
2011-11-24 16:26:25 +00:00
|
|
|
const char *name = sym->name;
|
|
|
|
|
|
|
|
if (name[0] == bfd_get_symbol_leading_char (main_objfile->obfd))
|
|
|
|
++name;
|
|
|
|
msym = lookup_minimal_symbol (name, NULL, main_objfile);
|
use bound_minsym as result for lookup_minimal_symbol et al
This patch changes a few minimal symbol lookup functions to return a
bound_minimal_symbol rather than a pointer to the minsym. This change
helps prepare gdb for computing a minimal symbol's address at the
point of use.
Note that this changes even those functions that ostensibly search a
single objfile. That was necessary because, in fact, those functions
can search an objfile and its separate debug objfiles; and it is
important for the caller to know in which objfile the minimal symbol
was actually found.
The bulk of this patch is mechanical.
2014-02-26 Tom Tromey <tromey@redhat.com>
* ada-lang.c (ada_update_initial_language): Update.
(ada_main_name, ada_has_this_exception_support): Update.
* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
* arm-tdep.c (arm_skip_stub): Update.
* auxv.c (ld_so_xfer_auxv): Update.
* avr-tdep.c (avr_scan_prologue): Update.
* ax-gdb.c (gen_var_ref): Update.
* breakpoint.c (struct breakpoint_objfile_data)
<overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change
type to bound_minimal_symbol.
(create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Update.
* bsd-uthread.c (bsd_uthread_lookup_address): Update.
* c-exp.y (classify_name): Update.
* coffread.c (coff_symfile_read): Update.
* common/agent.c (agent_look_up_symbols): Update.
* d-lang.c (d_main_name): Update.
* dbxread.c (find_stab_function_addr, end_psymtab): Update.
* dec-thread.c (enable_dec_thread): Update.
* dwarf2loc.c (call_site_to_target_addr): Update.
* elfread.c (elf_gnu_ifunc_resolve_by_got): Update.
* eval.c (evaluate_subexp_standard): Update.
* findvar.c (struct minsym_lookup_data) <result>: Change type
to bound_minimal_symbol.
<objfile>: Remove.
(minsym_lookup_iterator_cb, default_read_var_value): Update.
* frame.c (inside_main_func): Update.
* frv-tdep.c (frv_frame_this_id): Update.
* gcore.c (call_target_sbrk): Update.
* glibc-tdep.c (glibc_skip_solib_resolver): Update.
* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
Update.
* go-lang.c (go_main_name): Update.
* hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code)
(hppa_hpux_find_import_stub_for_addr): Update.
* hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol):
Update. Change return type.
* hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return
type.
* jit.c (jit_breakpoint_re_set_internal): Update.
* linux-fork.c (inferior_call_waitpid, checkpoint_command):
Update.
* linux-nat.c (get_signo): Update.
* linux-thread-db.c (inferior_has_bug): Update
* m32c-tdep.c (m32c_return_value)
(m32c_m16c_address_to_pointer): Update.
* m32r-tdep.c (m32r_frame_this_id): Update.
* m68hc11-tdep.c (m68hc11_get_register_info): Update.
* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
* minsyms.c (lookup_minimal_symbol_internal): Rename to
lookup_minimal_symbol. Change return type.
(lookup_minimal_symbol): Remove.
(lookup_bound_minimal_symbol): Update.
(lookup_minimal_symbol_text): Change return type.
(lookup_minimal_symbol_solib_trampoline): Change return type.
* minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text)
(lookup_minimal_symbol_solib_trampoline): Change return type.
* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(value_nsstring, find_imps): Update.
* obsd-tdep.c (obsd_skip_solib_resolver): Update.
* p-lang.c (pascal_main_name): Update.
* ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update.
* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
* proc-service.c (ps_pglobal_lookup): Update.
* ravenscar-thread.c (get_running_thread_msymbol): Change
return type.
(has_ravenscar_runtime, get_running_thread_id): Update.
* remote.c (remote_check_symbols): Update.
* sol-thread.c (ps_pglobal_lookup): Update.
* sol2-tdep.c (sol2_skip_solib_resolver): Update.
* solib-dsbt.c (lm_base): Update.
* solib-frv.c (lm_base, frv_relocate_section_addresses):
Update.
* solib-irix.c (locate_base): Update.
* solib-som.c (som_solib_create_inferior_hook)
(som_solib_desire_dynamic_linker_symbols, link_map_start):
Update.
* solib-spu.c (spu_enable_break): Update.
* solib-svr4.c (elf_locate_base, enable_break): Update.
* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
(flush_ea_cache): Update.
* stabsread.c (define_symbol): Update.
* symfile.c (simple_read_overlay_table): Update.
* symtab.c (find_pc_sect_line): Update.
* tracepoint.c (scope_info): Update.
* tui-disasm.c (tui_get_begin_asm_address): Update.
* value.c (value_static_field): Update.
2013-10-15 01:53:29 +00:00
|
|
|
if (msym.minsym == NULL)
|
2011-11-24 16:26:25 +00:00
|
|
|
{
|
|
|
|
warning (_("can't find symbol '%s' in minsymtab"), name);
|
|
|
|
return 0;
|
2011-07-01 18:36:36 +00:00
|
|
|
}
|
2011-11-24 16:26:25 +00:00
|
|
|
else
|
start change to progspace independence
This patch starts changing minimal symbols to be independent of the
program space.
Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS
and changes all the code to use it. This is needed so we can change
gdb to apply the section offset when a minsym's address is computed,
as opposed to baking the offsets into the symbol itself.
A few spots still need the unrelocated address. For these, we
introduce MSYMBOL_VALUE_RAW_ADDRESS.
As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS,
which computes the address of a bound minimal symbol. This just does
the obvious thing with the fields.
Note that this change does not actually enable program space
independence. That requires more changes to gdb. However, to ensure
that these changes compile properly, this patch does add the needed
section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has
no effect at runtime by multiplying the offset by 0.
2014-02-26 Tom Tromey <tromey@redhat.com>
* ada-lang.c (ada_main_name): Update.
(ada_add_standard_exceptions): Update.
* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
* arm-tdep.c (skip_prologue_function, arm_skip_stub): Update.
* auxv.c (ld_so_xfer_auxv): Update.
* avr-tdep.c (avr_scan_prologue): Update.
* ax-gdb.c (gen_var_ref): Update.
* blockframe.c (get_pc_function_start)
(find_pc_partial_function_gnu_ifunc): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Update.
* bsd-uthread.c (bsd_uthread_lookup_address): Update.
* c-valprint.c (c_val_print): Update.
* coff-pe-read.c (add_pe_forwarded_sym): Update.
* common/agent.c (agent_look_up_symbols): Update.
* dbxread.c (find_stab_function_addr, end_psymtab): Update.
* dwarf2loc.c (call_site_to_target_addr): Update.
* dwarf2read.c (dw2_find_pc_sect_symtab): Update.
* elfread.c (elf_gnu_ifunc_record_cache)
(elf_gnu_ifunc_resolve_by_got): Update.
* findvar.c (default_read_var_value): Update.
* frame.c (inside_main_func): Update.
* frv-tdep.c (frv_frame_this_id): Update.
* glibc-tdep.c (glibc_skip_solib_resolver): Update.
* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
Update.
* hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence)
(hppa_hpux_find_dummy_bpaddr): Update.
* hppa-tdep.c (hppa_symbol_address): Update.
* infcmd.c (until_next_command): Update.
* jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal):
Update.
* linespec.c (minsym_found, add_minsym): Update.
* linux-nat.c (get_signo): Update.
* linux-thread-db.c (inferior_has_bug): Update.
* m32c-tdep.c (m32c_return_value)
(m32c_m16c_address_to_pointer): Update.
* m32r-tdep.c (m32r_frame_this_id): Update.
* m68hc11-tdep.c (m68hc11_get_register_info): Update.
* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
* maint.c (maintenance_translate_address): Update.
* minsyms.c (lookup_minimal_symbol_by_pc_name): Update.
(frob_address): New function.
(lookup_minimal_symbol_by_pc_section_1): Use raw addresses,
frob_address. Rename parameter to "pc_in".
(compare_minimal_symbols, compact_minimal_symbols): Use raw
addresses.
(find_solib_trampoline_target, minimal_symbol_upper_bound):
Update.
* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
* mips-tdep.c (mips_skip_pic_trampoline_code): Update.
* objc-lang.c (find_objc_msgsend): Update.
* objfiles.c (objfile_relocate1): Update.
* obsd-tdep.c (obsd_skip_solib_resolver): Update.
* p-valprint.c (pascal_val_print): Update.
* parse.c (write_exp_msymbol): Update.
* ppc-linux-tdep.c (ppc_linux_spe_context_lookup)
(ppc_elfv2_skip_entrypoint): Update.
* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
* printcmd.c (build_address_symbolic, msym_info)
(address_info): Update.
* proc-service.c (ps_pglobal_lookup): Update.
* psymtab.c (find_pc_sect_psymtab_closer)
(find_pc_sect_psymtab, find_pc_sect_symtab_from_partial):
Change msymbol parameter to bound_minimal_symbol.
* ravenscar-thread.c (get_running_thread_id): Update.
* remote.c (remote_check_symbols): Update.
* sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw
address.
* sol2-tdep.c (sol2_skip_solib_resolver): Update.
* solib-dsbt.c (lm_base): Update.
* solib-frv.c (lm_base, main_got): Update.
* solib-irix.c (locate_base): Update.
* solib-som.c (som_solib_create_inferior_hook)
(link_map_start): Update.
* solib-spu.c (spu_enable_break, ocl_enable_break): Update.
* solib-svr4.c (elf_locate_base, enable_break): Update.
* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
(flush_ea_cache): Update.
* stabsread.c (define_symbol, scan_file_globals): Update.
* stack.c (find_frame_funname): Update.
* symfile-debug.c (debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_symtab): Update.
* symfile.c (simple_read_overlay_table)
(simple_overlay_update): Update.
* symfile.h (struct quick_symbol_functions)
<find_pc_sect_symtab>: Change type of msymbol to
bound_minimal_symbol.
* symmisc.c (dump_msymbols): Update.
* symtab.c (find_pc_sect_symtab_via_partial)
(find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal)
(search_symbols, print_msymbol_info): Update.
* symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro.
(MSYMBOL_VALUE_ADDRESS): Redefine.
(BMSYMBOL_VALUE_ADDRESS): New macro.
* tracepoint.c (scope_info): Update.
* tui/tui-disasm.c (tui_find_disassembly_address)
(tui_get_begin_asm_address): Update.
* valops.c (find_function_in_inferior): Update.
* value.c (value_static_field, value_fn_field): Update.
2013-08-15 14:46:35 +00:00
|
|
|
return BMSYMBOL_VALUE_ADDRESS (msym);
|
2011-07-01 18:36:36 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Add oso file OSO/ABFD as a symbol file. */
|
2009-10-13 09:42:57 +00:00
|
|
|
|
|
|
|
static void
|
2013-09-24 14:00:06 +00:00
|
|
|
macho_add_oso_symfile (oso_el *oso, bfd *abfd, const char *name,
|
2010-01-14 12:47:44 +00:00
|
|
|
struct objfile *main_objfile, int symfile_flags)
|
2009-10-13 09:42:57 +00:00
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
int storage;
|
2009-10-13 09:42:57 +00:00
|
|
|
int i;
|
2011-11-24 16:26:25 +00:00
|
|
|
asymbol **symbol_table;
|
|
|
|
asymbol **symp;
|
|
|
|
struct bfd_hash_table table;
|
|
|
|
int nbr_sections;
|
2012-07-23 14:58:44 +00:00
|
|
|
struct cleanup *cleanup;
|
2011-11-24 16:26:25 +00:00
|
|
|
|
|
|
|
/* Per section flag to mark which section have been rebased. */
|
|
|
|
unsigned char *sections_rebased;
|
2009-10-13 09:42:57 +00:00
|
|
|
|
|
|
|
if (mach_o_debug_level > 0)
|
2011-11-24 16:26:25 +00:00
|
|
|
printf_unfiltered
|
|
|
|
(_("Loading debugging symbols from oso: %s\n"), oso->name);
|
2010-02-04 12:45:49 +00:00
|
|
|
|
2009-10-13 09:42:57 +00:00
|
|
|
if (!bfd_check_format (abfd, bfd_object))
|
|
|
|
{
|
|
|
|
warning (_("`%s': can't read symbols: %s."), oso->name,
|
|
|
|
bfd_errmsg (bfd_get_error ()));
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (abfd);
|
2009-10-13 09:42:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
if (abfd->my_archive == NULL && oso->mtime != bfd_get_mtime (abfd))
|
|
|
|
{
|
|
|
|
warning (_("`%s': file time stamp mismatch."), oso->name);
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (abfd);
|
2011-11-24 16:26:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bfd_hash_table_init_n (&table, macho_sym_hash_newfunc,
|
|
|
|
sizeof (struct macho_sym_hash_entry),
|
|
|
|
oso->nbr_syms))
|
|
|
|
{
|
|
|
|
warning (_("`%s': can't create hash table"), oso->name);
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (abfd);
|
2011-11-24 16:26:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-13 09:42:57 +00:00
|
|
|
bfd_set_cacheable (abfd, 1);
|
2010-02-09 15:53:00 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Read symbols table. */
|
|
|
|
storage = bfd_get_symtab_upper_bound (abfd);
|
|
|
|
symbol_table = (asymbol **) xmalloc (storage);
|
|
|
|
bfd_canonicalize_symtab (abfd, symbol_table);
|
2009-10-13 09:42:57 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Init section flags. */
|
|
|
|
nbr_sections = bfd_count_sections (abfd);
|
|
|
|
sections_rebased = (unsigned char *) alloca (nbr_sections);
|
|
|
|
for (i = 0; i < nbr_sections; i++)
|
|
|
|
sections_rebased[i] = 0;
|
2009-10-13 09:42:57 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Put symbols for the OSO file in the hash table. */
|
|
|
|
for (symp = oso->oso_sym; symp != oso->end_sym; symp++)
|
2009-10-13 09:42:57 +00:00
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
const asymbol *sym = *symp;
|
|
|
|
bfd_mach_o_asymbol *mach_o_sym = (bfd_mach_o_asymbol *)sym;
|
2010-02-09 15:53:00 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
switch (mach_o_sym->n_type)
|
2010-02-09 15:53:00 +00:00
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
case N_ENSYM:
|
|
|
|
case N_BNSYM:
|
|
|
|
case N_GSYM:
|
|
|
|
sym = NULL;
|
|
|
|
break;
|
|
|
|
case N_FUN:
|
|
|
|
if (sym->name == NULL || sym->name[0] == 0)
|
|
|
|
sym = NULL;
|
|
|
|
break;
|
|
|
|
case N_STSYM:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sym = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (sym != NULL)
|
|
|
|
{
|
|
|
|
struct macho_sym_hash_entry *ent;
|
|
|
|
|
|
|
|
ent = (struct macho_sym_hash_entry *)
|
|
|
|
bfd_hash_lookup (&table, sym->name, TRUE, FALSE);
|
|
|
|
if (ent->sym != NULL)
|
|
|
|
complaint (&symfile_complaints,
|
|
|
|
_("Duplicated symbol %s in symbol table"), sym->name);
|
|
|
|
else
|
2010-02-09 15:53:00 +00:00
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
if (mach_o_debug_level > 4)
|
|
|
|
{
|
|
|
|
struct gdbarch *arch = get_objfile_arch (main_objfile);
|
|
|
|
printf_unfiltered
|
|
|
|
(_("Adding symbol %s (addr: %s)\n"),
|
|
|
|
sym->name, paddress (arch, sym->value));
|
|
|
|
}
|
|
|
|
ent->sym = sym;
|
2010-02-09 15:53:00 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-24 16:26:25 +00:00
|
|
|
}
|
2010-02-09 15:53:00 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Relocate symbols of the OSO. */
|
|
|
|
for (i = 0; symbol_table[i]; i++)
|
|
|
|
{
|
|
|
|
asymbol *sym = symbol_table[i];
|
|
|
|
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)
|
2010-02-09 15:53:00 +00:00
|
|
|
{
|
2011-11-24 16:26:25 +00:00
|
|
|
/* For common symbol use the min symtab and modify the OSO
|
|
|
|
symbol table. */
|
|
|
|
CORE_ADDR res;
|
|
|
|
|
|
|
|
res = macho_resolve_oso_sym_with_minsym (main_objfile, sym);
|
|
|
|
if (res != 0)
|
|
|
|
{
|
2012-05-05 03:05:32 +00:00
|
|
|
sym->section = bfd_com_section_ptr;
|
2011-11-24 16:26:25 +00:00
|
|
|
sym->value = res;
|
|
|
|
}
|
2010-02-09 15:53:00 +00:00
|
|
|
}
|
2011-11-24 16:26:25 +00:00
|
|
|
else if ((mach_o_sym->n_type & BFD_MACH_O_N_TYPE) == BFD_MACH_O_N_SECT)
|
|
|
|
{
|
|
|
|
/* Normal symbol. */
|
|
|
|
asection *sec = sym->section;
|
|
|
|
bfd_mach_o_section *msec;
|
|
|
|
unsigned int sec_type;
|
|
|
|
|
|
|
|
/* Skip buggy ones. */
|
|
|
|
if (sec == NULL || sections_rebased[sec->index] != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Only consider regular, non-debugging sections. */
|
|
|
|
msec = bfd_mach_o_get_mach_o_section (sec);
|
|
|
|
sec_type = msec->flags & BFD_MACH_O_SECTION_TYPE_MASK;
|
|
|
|
if ((sec_type == BFD_MACH_O_S_REGULAR
|
|
|
|
|| sec_type == BFD_MACH_O_S_ZEROFILL)
|
|
|
|
&& (msec->flags & BFD_MACH_O_S_ATTR_DEBUG) == 0)
|
|
|
|
{
|
|
|
|
CORE_ADDR addr = 0;
|
|
|
|
|
|
|
|
if ((mach_o_sym->n_type & BFD_MACH_O_N_EXT) != 0)
|
|
|
|
{
|
|
|
|
/* Use the min symtab for global symbols. */
|
|
|
|
addr = macho_resolve_oso_sym_with_minsym (main_objfile, sym);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct macho_sym_hash_entry *ent;
|
|
|
|
|
|
|
|
ent = (struct macho_sym_hash_entry *)
|
|
|
|
bfd_hash_lookup (&table, sym->name, FALSE, FALSE);
|
|
|
|
if (ent != NULL)
|
|
|
|
addr = bfd_asymbol_value (ent->sym);
|
|
|
|
}
|
2010-02-09 15:53:00 +00:00
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
/* Adjust the section. */
|
|
|
|
if (addr != 0)
|
|
|
|
{
|
|
|
|
CORE_ADDR res = addr - sym->value;
|
|
|
|
|
|
|
|
if (mach_o_debug_level > 3)
|
|
|
|
{
|
|
|
|
struct gdbarch *arch = get_objfile_arch (main_objfile);
|
|
|
|
printf_unfiltered
|
|
|
|
(_("resolve sect %s with %s (set to %s)\n"),
|
|
|
|
sec->name, sym->name,
|
|
|
|
paddress (arch, res));
|
|
|
|
}
|
|
|
|
bfd_set_section_vma (abfd, sec, res);
|
|
|
|
sections_rebased[sec->index] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Mark the section as never rebased. */
|
|
|
|
sections_rebased[sec->index] = 2;
|
|
|
|
}
|
|
|
|
}
|
2009-10-13 09:42:57 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 16:26:25 +00:00
|
|
|
bfd_hash_table_free (&table);
|
2011-07-01 18:36:36 +00:00
|
|
|
|
2010-01-14 12:47:44 +00:00
|
|
|
/* We need to clear SYMFILE_MAINLINE to avoid interractive question
|
|
|
|
from symfile.c:symbol_file_add_with_addrs_or_offsets. */
|
2012-07-23 14:58:44 +00:00
|
|
|
cleanup = make_cleanup_bfd_unref (abfd);
|
2011-11-24 16:26:25 +00:00
|
|
|
symbol_file_add_from_bfd
|
2013-09-24 14:00:06 +00:00
|
|
|
(abfd, name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL,
|
2010-01-14 12:47:44 +00:00
|
|
|
main_objfile->flags & (OBJF_REORDERED | OBJF_SHARED
|
2011-04-17 18:38:46 +00:00
|
|
|
| OBJF_READNOW | OBJF_USERLOADED),
|
|
|
|
main_objfile);
|
2012-07-23 14:58:44 +00:00
|
|
|
do_cleanups (cleanup);
|
2009-10-13 09:42:57 +00:00
|
|
|
}
|
|
|
|
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
/* Read symbols from the vector of oso files.
|
|
|
|
|
|
|
|
Note that this function sorts OSO_VECTOR_PTR. */
|
2009-10-13 09:42:57 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
static void
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
macho_symfile_read_all_oso (VEC (oso_el) **oso_vector_ptr,
|
|
|
|
struct objfile *main_objfile,
|
|
|
|
int symfile_flags)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
|
|
|
int ix;
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
VEC (oso_el) *vec = *oso_vector_ptr;
|
2008-11-27 09:23:01 +00:00
|
|
|
oso_el *oso;
|
2012-07-18 19:34:57 +00:00
|
|
|
struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2009-10-13 09:42:57 +00:00
|
|
|
/* Sort oso by name so that files from libraries are gathered. */
|
|
|
|
qsort (VEC_address (oso_el, vec), VEC_length (oso_el, vec),
|
|
|
|
sizeof (oso_el), oso_el_compare_name);
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2009-10-13 09:42:57 +00:00
|
|
|
for (ix = 0; VEC_iterate (oso_el, vec, ix, oso);)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
|
|
|
int pfx_len;
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
/* Check if this is a library name. */
|
|
|
|
pfx_len = get_archive_prefix_len (oso->name);
|
|
|
|
if (pfx_len > 0)
|
|
|
|
{
|
|
|
|
bfd *archive_bfd;
|
|
|
|
bfd *member_bfd;
|
2009-10-13 09:42:57 +00:00
|
|
|
char *archive_name = XNEWVEC (char, pfx_len + 1);
|
|
|
|
int last_ix;
|
|
|
|
oso_el *oso2;
|
|
|
|
int ix2;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
|
|
|
memcpy (archive_name, oso->name, pfx_len);
|
|
|
|
archive_name[pfx_len] = '\0';
|
|
|
|
|
2012-07-18 19:34:57 +00:00
|
|
|
make_cleanup (xfree, archive_name);
|
|
|
|
|
2009-10-13 09:42:57 +00:00
|
|
|
/* Compute number of oso for this archive. */
|
|
|
|
for (last_ix = ix;
|
|
|
|
VEC_iterate (oso_el, vec, last_ix, oso2); last_ix++)
|
|
|
|
{
|
|
|
|
if (strncmp (oso2->name, archive_name, pfx_len) != 0)
|
|
|
|
break;
|
|
|
|
}
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
/* Open the archive and check the format. */
|
2012-08-22 16:24:39 +00:00
|
|
|
archive_bfd = gdb_bfd_open (archive_name, gnutarget, -1);
|
2008-11-27 09:23:01 +00:00
|
|
|
if (archive_bfd == NULL)
|
|
|
|
{
|
|
|
|
warning (_("Could not open OSO archive file \"%s\""),
|
|
|
|
archive_name);
|
2009-10-13 09:42:57 +00:00
|
|
|
ix = last_ix;
|
2008-11-27 09:23:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!bfd_check_format (archive_bfd, bfd_archive))
|
|
|
|
{
|
|
|
|
warning (_("OSO archive file \"%s\" not an archive."),
|
|
|
|
archive_name);
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (archive_bfd);
|
2009-10-13 09:42:57 +00:00
|
|
|
ix = last_ix;
|
2008-11-27 09:23:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-07-18 19:34:57 +00:00
|
|
|
|
* cli/cli-dump.c (bfd_openr_with_cleanup): Use gdb_bfd_openr.
(bfd_openw_with_cleanup): Use gdb_bfd_openw.
* corelow.c (core_open): Use gdb_bfd_fopen.
* dsrec.c (load_srec): Use gdb_bfd_openr.
* exec.c (exec_file_attach): Use gdb_bfd_fopen.
* gcore.c (gcore_memory_sections): Use gdb_bfd_openw.
* gdb_bfd.c (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
(gdb_bfd_fdopenr): New functions.
* gdb_bfd.h (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
(gdb_bfd_fdopenr): Declare.
* jit.c (bfd_open_from_target_memory): Use gdb_bfd_openr_iovec.
* m32-rom.c (m32r_load, m32r_upload_command): Use gdb_bfd_openr.
* machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_openr,
gdb_bfd_openr_next_archived_file.
(macho_check_dsym): Use gdb_bfd_openr.
(macho_add_oso_symfile): Don't call gdb_bfd_stash_filename.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_fdopenr.
* remote-m32r-sdi.c (m32r_load): Use gdb_bfd_openr.
* remote-mips.c (mips_load_srec, pmon_load_fast): Use
gdb_bfd_openr.
* remote.c (remote_bfd_open): Use gdb_bfd_openr_iovec.
* rs6000-nat.c (add_vmap): Use gdb_bfd_openr, gdb_bfd_fdopenr,
gdb_bfd_openr_next_archived_file.
* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
Use gdb_bfd_openr.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use
gdb_bfd_openr.
* solib-spu.c (spu_bfd_fopen): Use gdb_bfd_openr_iovec.
* solib.c (solib_bfd_fopen): Use gdb_bfd_fopen.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_openr_iovec.
* symfile.c (bfd_open_maybe_remote): Use gdb_bfd_openr.
(symfile_bfd_open): Use gdb_bfd_fopen.
(generic_load): Use gdb_bfd_openr.
* windows-nat.c (windows_make_so): Use gdb_bfd_openr.
2012-07-23 14:57:58 +00:00
|
|
|
member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd, NULL);
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
if (member_bfd == NULL)
|
|
|
|
{
|
|
|
|
warning (_("Could not read archive members out of "
|
|
|
|
"OSO archive \"%s\""), archive_name);
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (archive_bfd);
|
2009-10-13 09:42:57 +00:00
|
|
|
ix = last_ix;
|
2008-11-27 09:23:01 +00:00
|
|
|
continue;
|
|
|
|
}
|
2009-10-13 09:42:57 +00:00
|
|
|
|
|
|
|
/* Load all oso in this library. */
|
2008-11-27 09:23:01 +00:00
|
|
|
while (member_bfd != NULL)
|
|
|
|
{
|
2009-10-13 09:42:57 +00:00
|
|
|
bfd *prev;
|
2008-11-27 09:23:01 +00:00
|
|
|
const char *member_name = member_bfd->filename;
|
2009-10-13 09:42:57 +00:00
|
|
|
int member_len = strlen (member_name);
|
|
|
|
|
2009-11-18 14:10:47 +00:00
|
|
|
/* If this member is referenced, add it as a symfile. */
|
2009-10-13 09:42:57 +00:00
|
|
|
for (ix2 = ix; ix2 < last_ix; ix2++)
|
|
|
|
{
|
|
|
|
oso2 = VEC_index (oso_el, vec, ix2);
|
|
|
|
|
|
|
|
if (oso2->name
|
|
|
|
&& strlen (oso2->name) == pfx_len + member_len + 2
|
|
|
|
&& !memcmp (member_name, oso2->name + pfx_len + 1,
|
|
|
|
member_len))
|
|
|
|
{
|
2010-01-14 12:47:44 +00:00
|
|
|
macho_add_oso_symfile (oso2, member_bfd,
|
2013-09-24 14:00:06 +00:00
|
|
|
bfd_get_filename (member_bfd),
|
2010-01-14 12:47:44 +00:00
|
|
|
main_objfile, symfile_flags);
|
2009-10-13 09:42:57 +00:00
|
|
|
oso2->name = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
prev = member_bfd;
|
* cli/cli-dump.c (bfd_openr_with_cleanup): Use gdb_bfd_openr.
(bfd_openw_with_cleanup): Use gdb_bfd_openw.
* corelow.c (core_open): Use gdb_bfd_fopen.
* dsrec.c (load_srec): Use gdb_bfd_openr.
* exec.c (exec_file_attach): Use gdb_bfd_fopen.
* gcore.c (gcore_memory_sections): Use gdb_bfd_openw.
* gdb_bfd.c (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
(gdb_bfd_fdopenr): New functions.
* gdb_bfd.h (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
(gdb_bfd_fdopenr): Declare.
* jit.c (bfd_open_from_target_memory): Use gdb_bfd_openr_iovec.
* m32-rom.c (m32r_load, m32r_upload_command): Use gdb_bfd_openr.
* machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_openr,
gdb_bfd_openr_next_archived_file.
(macho_check_dsym): Use gdb_bfd_openr.
(macho_add_oso_symfile): Don't call gdb_bfd_stash_filename.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_fdopenr.
* remote-m32r-sdi.c (m32r_load): Use gdb_bfd_openr.
* remote-mips.c (mips_load_srec, pmon_load_fast): Use
gdb_bfd_openr.
* remote.c (remote_bfd_open): Use gdb_bfd_openr_iovec.
* rs6000-nat.c (add_vmap): Use gdb_bfd_openr, gdb_bfd_fdopenr,
gdb_bfd_openr_next_archived_file.
* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
Use gdb_bfd_openr.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use
gdb_bfd_openr.
* solib-spu.c (spu_bfd_fopen): Use gdb_bfd_openr_iovec.
* solib.c (solib_bfd_fopen): Use gdb_bfd_fopen.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_openr_iovec.
* symfile.c (bfd_open_maybe_remote): Use gdb_bfd_openr.
(symfile_bfd_open): Use gdb_bfd_fopen.
(generic_load): Use gdb_bfd_openr.
* windows-nat.c (windows_make_so): Use gdb_bfd_openr.
2012-07-23 14:57:58 +00:00
|
|
|
member_bfd = gdb_bfd_openr_next_archived_file (archive_bfd,
|
|
|
|
member_bfd);
|
2009-11-18 14:10:47 +00:00
|
|
|
|
|
|
|
/* Free previous member if not referenced by an oso. */
|
|
|
|
if (ix2 >= last_ix)
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (prev);
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
2009-10-13 09:42:57 +00:00
|
|
|
for (ix2 = ix; ix2 < last_ix; ix2++)
|
|
|
|
{
|
|
|
|
oso_el *oso2 = VEC_index (oso_el, vec, ix2);
|
|
|
|
|
|
|
|
if (oso2->name != NULL)
|
|
|
|
warning (_("Could not find specified archive member "
|
|
|
|
"for OSO name \"%s\""), oso->name);
|
|
|
|
}
|
|
|
|
ix = last_ix;
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-13 09:42:57 +00:00
|
|
|
bfd *abfd;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2012-08-22 16:24:39 +00:00
|
|
|
abfd = gdb_bfd_open (oso->name, gnutarget, -1);
|
2008-11-27 09:23:01 +00:00
|
|
|
if (!abfd)
|
2009-10-13 09:42:57 +00:00
|
|
|
warning (_("`%s': can't open to read symbols: %s."), oso->name,
|
|
|
|
bfd_errmsg (bfd_get_error ()));
|
|
|
|
else
|
2013-09-24 14:00:06 +00:00
|
|
|
macho_add_oso_symfile (oso, abfd, oso->name, main_objfile,
|
|
|
|
symfile_flags);
|
2009-10-13 09:42:57 +00:00
|
|
|
|
|
|
|
ix++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-18 19:34:57 +00:00
|
|
|
do_cleanups (cleanup);
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* DSYM (debug symbols) files contain the debug info of an executable.
|
|
|
|
This is a separate file created by dsymutil(1) and is similar to debug
|
|
|
|
link feature on ELF.
|
|
|
|
DSYM files are located in a subdirectory. Append DSYM_SUFFIX to the
|
|
|
|
executable name and the executable base name to get the DSYM file name. */
|
|
|
|
#define DSYM_SUFFIX ".dSYM/Contents/Resources/DWARF/"
|
|
|
|
|
2013-09-24 14:00:06 +00:00
|
|
|
/* Check if a dsym file exists for OBJFILE. If so, returns a bfd for it
|
|
|
|
and return *FILENAMEP with its original xmalloc-ated filename.
|
|
|
|
Return NULL if no valid dsym file is found (FILENAMEP is not used in
|
|
|
|
such case). */
|
2009-10-13 09:42:57 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
static bfd *
|
2013-09-24 14:00:06 +00:00
|
|
|
macho_check_dsym (struct objfile *objfile, char **filenamep)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 13:57:38 +00:00
|
|
|
size_t name_len = strlen (objfile_name (objfile));
|
2008-11-27 09:23:01 +00:00
|
|
|
size_t dsym_len = strlen (DSYM_SUFFIX);
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 13:57:38 +00:00
|
|
|
const char *base_name = lbasename (objfile_name (objfile));
|
2008-11-27 09:23:01 +00:00
|
|
|
size_t base_len = strlen (base_name);
|
|
|
|
char *dsym_filename = alloca (name_len + dsym_len + base_len + 1);
|
|
|
|
bfd *dsym_bfd;
|
2009-12-15 09:41:16 +00:00
|
|
|
bfd_mach_o_load_command *main_uuid;
|
|
|
|
bfd_mach_o_load_command *dsym_uuid;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 13:57:38 +00:00
|
|
|
strcpy (dsym_filename, objfile_name (objfile));
|
2008-11-27 09:23:01 +00:00
|
|
|
strcpy (dsym_filename + name_len, DSYM_SUFFIX);
|
|
|
|
strcpy (dsym_filename + name_len + dsym_len, base_name);
|
|
|
|
|
|
|
|
if (access (dsym_filename, R_OK) != 0)
|
|
|
|
return NULL;
|
|
|
|
|
2009-12-15 09:41:16 +00:00
|
|
|
if (bfd_mach_o_lookup_command (objfile->obfd,
|
|
|
|
BFD_MACH_O_LC_UUID, &main_uuid) == 0)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 13:57:38 +00:00
|
|
|
warning (_("can't find UUID in %s"), objfile_name (objfile));
|
2008-11-27 09:23:01 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
* cli/cli-dump.c (bfd_openr_with_cleanup): Use gdb_bfd_openr.
(bfd_openw_with_cleanup): Use gdb_bfd_openw.
* corelow.c (core_open): Use gdb_bfd_fopen.
* dsrec.c (load_srec): Use gdb_bfd_openr.
* exec.c (exec_file_attach): Use gdb_bfd_fopen.
* gcore.c (gcore_memory_sections): Use gdb_bfd_openw.
* gdb_bfd.c (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
(gdb_bfd_fdopenr): New functions.
* gdb_bfd.h (gdb_bfd_fopen, gdb_bfd_openr, gdb_bfd_openw)
(gdb_bfd_openr_iovec, gdb_bfd_openr_next_archived_file)
(gdb_bfd_fdopenr): Declare.
* jit.c (bfd_open_from_target_memory): Use gdb_bfd_openr_iovec.
* m32-rom.c (m32r_load, m32r_upload_command): Use gdb_bfd_openr.
* machoread.c (macho_symfile_read_all_oso): Use gdb_bfd_openr,
gdb_bfd_openr_next_archived_file.
(macho_check_dsym): Use gdb_bfd_openr.
(macho_add_oso_symfile): Don't call gdb_bfd_stash_filename.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_fdopenr.
* remote-m32r-sdi.c (m32r_load): Use gdb_bfd_openr.
* remote-mips.c (mips_load_srec, pmon_load_fast): Use
gdb_bfd_openr.
* remote.c (remote_bfd_open): Use gdb_bfd_openr_iovec.
* rs6000-nat.c (add_vmap): Use gdb_bfd_openr, gdb_bfd_fdopenr,
gdb_bfd_openr_next_archived_file.
* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
Use gdb_bfd_openr.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use
gdb_bfd_openr.
* solib-spu.c (spu_bfd_fopen): Use gdb_bfd_openr_iovec.
* solib.c (solib_bfd_fopen): Use gdb_bfd_fopen.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_openr_iovec.
* symfile.c (bfd_open_maybe_remote): Use gdb_bfd_openr.
(symfile_bfd_open): Use gdb_bfd_fopen.
(generic_load): Use gdb_bfd_openr.
* windows-nat.c (windows_make_so): Use gdb_bfd_openr.
2012-07-23 14:57:58 +00:00
|
|
|
dsym_bfd = gdb_bfd_openr (dsym_filename, gnutarget);
|
2008-11-27 09:23:01 +00:00
|
|
|
if (dsym_bfd == NULL)
|
|
|
|
{
|
|
|
|
warning (_("can't open dsym file %s"), dsym_filename);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bfd_check_format (dsym_bfd, bfd_object))
|
|
|
|
{
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (dsym_bfd);
|
2008-11-27 09:23:01 +00:00
|
|
|
warning (_("bad dsym file format: %s"), bfd_errmsg (bfd_get_error ()));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-12-15 09:41:16 +00:00
|
|
|
if (bfd_mach_o_lookup_command (dsym_bfd,
|
|
|
|
BFD_MACH_O_LC_UUID, &dsym_uuid) == 0)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
|
|
|
warning (_("can't find UUID in %s"), dsym_filename);
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (dsym_bfd);
|
2008-11-27 09:23:01 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-12-15 09:41:16 +00:00
|
|
|
if (memcmp (dsym_uuid->command.uuid.uuid, main_uuid->command.uuid.uuid,
|
|
|
|
sizeof (main_uuid->command.uuid.uuid)))
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 13:57:38 +00:00
|
|
|
warning (_("dsym file UUID doesn't match the one in %s"),
|
|
|
|
objfile_name (objfile));
|
* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
gdb_bfd_unref.
(free_dwo_file): Use gdb_bfd_unref.
* cli/cli-dump.c: Include gdb_bfd.h.
(bfd_openw_with_cleanup): Use gdb_bfd_ref.
(bfd_openr_with_cleanup): Likewise.
* windows-nat.c (windows_make_so): Use gdb_bfd_ref,
gdb_bfd_unref.
* utils.c: Include gdb_bfd.h.
(do_bfd_close_cleanup): Use gdb_bfd_unref.
* symfile.c: Include gdb_bfd.h.
(separate_debug_file_exists): Use gdb_bfd_unref.
(bfd_open_maybe_remote): Use gdb_bfd_ref.
(symfile_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
(generic_load): Use gdb_bfd_ref.
(reread_symbols): Use gdb_bfd_unref.
* symfile-mem.c: Include gdb_bfd.h.
(symbol_file_add_from_memory): Use make_cleanup_bfd_close.
* spu-linux-nat.c (spu_bfd_open): Use gdb_bfd_ref, gdb_bfd_unref.
* solib.c: Include gdb_bfd.h.
(solib_bfd_fopen): Use gdb_bfd_ref.
(solib_bfd_open): Use gdb_bfd_unref.
(free_so_symbols): Use gdb_bfd_unref.
(reload_shared_libraries_1): Use gdb_bfd_unref.
* solib-spu.c: Include gdb_bfd.h.
(spu_bfd_fopen): Use gdb_bfd_ref, gdb_bfd_unref.
* solib-pa64.c (pa64_solib_create_inferior_hook): Use gdb_bfd_ref,
gdb_bfd_unref.
* solib-frv.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-dsbt.c: Include gdb_bfd.h.
(enable_break2): Use gdb_bfd_unref.
* solib-darwin.c: Include gdb_bfd.h.
(darwin_solib_get_all_image_info_addr_at_init): Use gdb_bfd_ref,
gdb_bfd_unref.
(darwin_bfd_open): Use gdb_bfd_unref.
* rs6000-nat.c (add_vmap): Use gdb_bfd_ref, gdb_bfd_unref.
* remote-mips.c: Include gdb_bfd.h.
(mips_load_srec): Use gdb_bfd_ref.
(pmon_load_fast): Use gdb_bfd_ref.
* remote-m32r-sdi.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
* record.c: Include gdb_bfd.h.
(record_save_cleanups): Use gdb_bfd_unref.
(cmd_record_save): Use gdb_bfd_unref.
* procfs.c (insert_dbx_link_bpt_in_file): Use gdb_bfd_ref,
gdb_bfd_unref.
* objfiles.h (gdb_bfd_close_or_warn): Remove.
(gdb_bfd_ref, gdb_bfd_unref): Move to gdb_bfd.h.
* objfiles.c: Include gdb_bfd.h.
(free_objfile): Use gdb_bfd_unref.
(gdb_bfd_close_or_warn, gdb_bfd_ref, gdb_bfd_unref): Move to
gdb_bfd.c.
* machoread.c (macho_add_oso_symfile): Use gdb_bfd_unref.
(macho_symfile_read_all_oso): Use gdb_bfd_ref, gdb_bfd_unref.
(macho_check_dsym): Likewise.
* m32r-rom.c: Include gdb_bfd.h.
(m32r_load): Use gdb_bfd_ref.
(m32r_upload_command): Use gdb_bfd_ref.
* jit.c: Include gdb_bfd.h.
(jit_bfd_try_read_symtab): Use gdb_bfd_ref, gdb_bfd_unref.
* gdb_bfd.h: New file.
* gdb_bfd.c: New file.
* gcore.c: Include gdb_bfd.h.
(create_gcore_bfd): Use gdb_bfd_ref.
(do_bfd_delete_cleanup): Use gdb_bfd_unref.
(gcore_command): Use gdb_bfd_unref.
* exec.c: Include gdb_bfd.h.
(exec_close): Use gdb_bfd_unref.
(exec_close_1): Use gdb_bfd_unref.
(exec_file_attach): Use gdb_bfd_ref.
* elfread.c: Include gdb_bfd.h.
(build_id_verify): Use gdb_bfd_unref.
* dsrec.c: Include gdb_bfd.h.
(load_srec): Use gdb_bfd_ref.
* corelow.c: Include gdb_bfd.h.
(core_close): Use gdb_bfd_unref.
(core_open): Use gdb_bfd_ref.
* bfd-target.c: Include gdb_bfd.h.
(target_bfd_xclose): Use gdb_bfd_unref.
(target_bfd_reopen): Use gdb_bfd_ref.
* Makefile.in (SFILES): Add gdb_bfd.c.
(HFILES_NO_SRCDIR): Add gdb_bfd.h.
(COMMON_OBS): Add gdb_bfd.o.
2012-07-18 19:33:34 +00:00
|
|
|
gdb_bfd_unref (dsym_bfd);
|
2008-11-27 09:23:01 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2013-09-24 14:00:06 +00:00
|
|
|
*filenamep = xstrdup (dsym_filename);
|
2008-11-27 09:23:01 +00:00
|
|
|
return dsym_bfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-12-07 09:47:40 +00:00
|
|
|
macho_symfile_read (struct objfile *objfile, int symfile_flags)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
|
|
|
bfd *abfd = objfile->obfd;
|
|
|
|
CORE_ADDR offset;
|
|
|
|
long storage_needed;
|
|
|
|
bfd *dsym_bfd;
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
VEC (oso_el) *oso_vector = NULL;
|
|
|
|
struct cleanup *old_chain = make_cleanup (VEC_cleanup (oso_el), &oso_vector);
|
2008-11-27 09:23:01 +00:00
|
|
|
|
|
|
|
/* Get symbols from the symbol table only if the file is an executable.
|
|
|
|
The symbol table of object files is not relocated and is expected to
|
|
|
|
be in the executable. */
|
2009-02-04 08:47:56 +00:00
|
|
|
if (bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC))
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
2013-09-24 14:00:06 +00:00
|
|
|
char *dsym_filename;
|
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
/* Process the normal symbol table first. */
|
|
|
|
storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
|
|
|
|
if (storage_needed < 0)
|
|
|
|
error (_("Can't read symbols from %s: %s"),
|
|
|
|
bfd_get_filename (objfile->obfd),
|
|
|
|
bfd_errmsg (bfd_get_error ()));
|
|
|
|
|
|
|
|
if (storage_needed > 0)
|
|
|
|
{
|
|
|
|
asymbol **symbol_table;
|
|
|
|
long symcount;
|
|
|
|
|
|
|
|
symbol_table = (asymbol **) xmalloc (storage_needed);
|
2013-06-03 13:22:29 +00:00
|
|
|
make_cleanup (xfree, symbol_table);
|
2011-11-24 16:26:25 +00:00
|
|
|
|
|
|
|
init_minimal_symbol_collection ();
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
make_cleanup_discard_minimal_symbols ();
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table);
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
if (symcount < 0)
|
|
|
|
error (_("Can't read symbols from %s: %s"),
|
|
|
|
bfd_get_filename (objfile->obfd),
|
|
|
|
bfd_errmsg (bfd_get_error ()));
|
2011-11-24 16:26:25 +00:00
|
|
|
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
macho_symtab_read (objfile, symcount, symbol_table, &oso_vector);
|
2011-11-24 16:26:25 +00:00
|
|
|
|
|
|
|
install_minimal_symbols (objfile);
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
|
2009-02-04 08:47:56 +00:00
|
|
|
/* Try to read .eh_frame / .debug_frame. */
|
|
|
|
/* First, locate these sections. We ignore the result status
|
|
|
|
as it only checks for debug info. */
|
2011-05-26 07:47:10 +00:00
|
|
|
dwarf2_has_info (objfile, NULL);
|
2009-02-04 08:47:56 +00:00
|
|
|
dwarf2_build_frame_info (objfile);
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
/* Check for DSYM file. */
|
2013-09-24 14:00:06 +00:00
|
|
|
dsym_bfd = macho_check_dsym (objfile, &dsym_filename);
|
2008-11-27 09:23:01 +00:00
|
|
|
if (dsym_bfd != NULL)
|
|
|
|
{
|
|
|
|
int ix;
|
|
|
|
oso_el *oso;
|
2009-12-15 09:56:23 +00:00
|
|
|
struct bfd_section *asect, *dsect;
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2013-09-24 14:00:06 +00:00
|
|
|
make_cleanup (xfree, dsym_filename);
|
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
if (mach_o_debug_level > 0)
|
|
|
|
printf_unfiltered (_("dsym file found\n"));
|
|
|
|
|
2009-12-15 09:56:23 +00:00
|
|
|
/* Set dsym section size. */
|
|
|
|
for (asect = objfile->obfd->sections, dsect = dsym_bfd->sections;
|
|
|
|
asect && dsect;
|
|
|
|
asect = asect->next, dsect = dsect->next)
|
|
|
|
{
|
|
|
|
if (strcmp (asect->name, dsect->name) != 0)
|
|
|
|
break;
|
|
|
|
bfd_set_section_size (dsym_bfd, dsect,
|
|
|
|
bfd_get_section_size (asect));
|
|
|
|
}
|
|
|
|
|
2009-12-09 14:53:25 +00:00
|
|
|
/* Add the dsym file as a separate file. */
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
make_cleanup_bfd_unref (dsym_bfd);
|
2013-09-24 14:00:06 +00:00
|
|
|
symbol_file_add_separate (dsym_bfd, dsym_filename, symfile_flags,
|
|
|
|
objfile);
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2009-02-04 08:47:56 +00:00
|
|
|
/* Don't try to read dwarf2 from main file or shared libraries. */
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
do_cleanups (old_chain);
|
2009-12-09 14:53:25 +00:00
|
|
|
return;
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-26 07:47:10 +00:00
|
|
|
if (dwarf2_has_info (objfile, NULL))
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
|
|
|
/* DWARF 2 sections */
|
2009-12-02 11:44:35 +00:00
|
|
|
dwarf2_build_psymtabs (objfile);
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Then the oso. */
|
|
|
|
if (oso_vector != NULL)
|
[Darwin] Fix cleanup leak in machoread.c:macho_symfile_read
This patch fixes a cleanup leak in macho_symfile_read (symbol_table):
symbol_table = (asymbol **) xmalloc (storage_needed);
make_cleanup (xfree, symbol_table);
Unfortunately, fixing the leak alone triggers a crash which occurs
while loading the symbols from an executable:
% gdb
(gdb) file g_exe
[SIGSEGV]
The crash is caused by the fact that performing the cleanup
right after the call to macho_symtab_read, as currently done,
is too early.
Indeed, references to this symbol_table get saved in the oso_vector
global during the call to macho_symtab_read via calls to
macho_register_oso, and those references then get accessed
later on, when processing all the OSOs that got pushed (see
call to macho_symfile_read_all_oso).
This patch prevents this by using one single cleanup queue for
the entire function, rather than having additional separate
cleanup queues (Eg: for the handling of the minimal symbols),
thus preventing the premature free'ing of the minimal_symbols
array.
Secondly, this patch takes this opportunity for avoiding the use
of the oso_vector global, thus making it simpler to track its
lifetime.
gdb/ChangeLog:
* machoread.c (oso_vector): Delete this global.
(macho_register_oso): Add new parameter "oso_vector_ptr".
Use it instead of the "oso_vector" global.
(macho_symtab_read, macho_symfile_read_all_oso): Likewise.
(macho_symfile_read): Use a local oso_vector, to be free'ed
at the end of this function, in place of the old "oso_vector"
global. Update various function calls accordingly. Use one
single cleanup chain for the entire function.
2013-06-18 23:35:37 +00:00
|
|
|
macho_symfile_read_all_oso (&oso_vector, objfile, symfile_flags);
|
|
|
|
|
|
|
|
do_cleanups (old_chain);
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|
|
|
|
|
2010-02-09 15:53:00 +00:00
|
|
|
static bfd_byte *
|
|
|
|
macho_symfile_relocate (struct objfile *objfile, asection *sectp,
|
|
|
|
bfd_byte *buf)
|
|
|
|
{
|
|
|
|
bfd *abfd = objfile->obfd;
|
|
|
|
|
|
|
|
/* We're only interested in sections with relocation
|
|
|
|
information. */
|
|
|
|
if ((sectp->flags & SEC_RELOC) == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (mach_o_debug_level > 0)
|
|
|
|
printf_unfiltered (_("Relocate section '%s' of %s\n"),
|
Code cleanup: Add objfile_name accessor
gdb/
2013-09-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup: Add objfile_name accessor function.
* ada-lang.c (is_known_support_routine): Use objfile_name.
* auto-load.c (source_gdb_script_for_objfile)
(auto_load_objfile_script): Likewise.
* coffread.c (coff_symtab_read, read_one_sym): Likewise.
* dbxread.c (dbx_symfile_read): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* dwarf2loc.c (locexpr_describe_location_piece): Likewise.
* dwarf2read.c (dwarf2_get_dwz_file, dwarf2_read_index)
(dw2_symtab_iter_next, dw2_expand_symtabs_matching)
(lookup_dwp_signatured_type, lookup_dwo_unit)
(dwarf2_build_psymtabs_hard, scan_partial_symbols, process_queue)
(fixup_go_packaging, process_imported_unit_die, dwarf2_physname)
(read_import_statement, create_dwo_cu, open_and_init_dwp_file)
(lookup_dwo_cutu, read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, read_common_block, read_typedef)
(read_subrange_type, load_partial_dies, read_partial_die)
(read_addr_index_1, read_str_index, dwarf_decode_lines_1)
(die_containing_type, build_error_marker_type, lookup_die_type)
(follow_die_ref_or_sig, follow_die_ref, dwarf2_fetch_die_loc_sect_off)
(dwarf2_fetch_constant_bytes, follow_die_sig, get_signatured_type)
(get_DW_AT_signature_type, write_psymtabs_to_index)
(save_gdb_index_command): Likewise.
* elfread.c (find_separate_debug_file_by_buildid, elf_symfile_read):
Likewise.
* expprint.c (dump_subexp_body_standard): Likewise.
* gdbtypes.c (type_name_no_tag_or_error): Likewise.
* jit.c (jit_object_close_impl): Use the objfile field name renamed to
original_name.
* linux-thread-db.c (try_thread_db_load_from_pdir_1): New variable
obj_name, use objfile_name for it, use the variable.
(try_thread_db_load_from_pdir, has_libpthread, thread_db_new_objfile):
Use objfile_name.
* machoread.c (macho_symtab_read, macho_check_dsym)
(macho_symfile_relocate): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minidebug.c (find_separate_debug_file_in_section): Likewise.
* minsyms.c (install_minimal_symbols): Likewise.
* objfiles.c (allocate_objfile): Use the objfile field name renamed to
original_name.
(filter_overlapping_sections): Use objfile_name.
(objfile_name): New function.
* objfiles.h (struct objfile): Rename field name to original_name.
(objfile_name): New prototype.
* printcmd.c (sym_info, address_info): Use objfile_name.
* probe.c (parse_probes, collect_probes, compare_probes)
(info_probes_for_ops): Likewise.
* progspace.c (clone_program_space): Likewise.
* psymtab.c (require_partial_symbols, dump_psymtab, allocate_psymtab)
(maintenance_info_psymtabs): Likewise.
* python/py-auto-load.c (gdbpy_load_auto_script_for_objfile)
(source_section_scripts): Likewise.
* python/py-objfile.c (objfpy_get_filename): Likewise.
* python/py-progspace.c (pspy_get_filename): Likewise.
* solib-aix.c (solib_aix_get_toc_value): Likewise.
* solib-som.c (match_main, som_solib_section_offsets): Likewise.
* solib.c (solib_read_symbols): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (symbol_file_clear, separate_debug_file_exists)
(find_separate_debug_file_by_debuglink): Likewise.
(reread_symbols): Likewise. Use the objfile field name renamed to
original_name.
(allocate_symtab): Use objfile_name.
* symmisc.c (print_symbol_bcache_statistics, print_objfile_statistics)
(dump_objfile, dump_msymbols, dump_symtab_1)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs): Likewise.
* target.c (target_translate_tls_address, target_info): Likewise.
* xcoffread.c (xcoff_initial_scan): Make variable name const. Use
objfile_name.
2013-09-24 13:57:38 +00:00
|
|
|
sectp->name, objfile_name (objfile));
|
2010-02-09 15:53:00 +00:00
|
|
|
|
|
|
|
return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL);
|
|
|
|
}
|
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
static void
|
|
|
|
macho_symfile_finish (struct objfile *objfile)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
macho_symfile_offsets (struct objfile *objfile,
|
2013-05-06 19:38:04 +00:00
|
|
|
const struct section_addr_info *addrs)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int num_sections;
|
|
|
|
struct obj_section *osect;
|
|
|
|
|
|
|
|
/* Allocate section_offsets. */
|
|
|
|
objfile->num_sections = bfd_count_sections (objfile->obfd);
|
|
|
|
objfile->section_offsets = (struct section_offsets *)
|
|
|
|
obstack_alloc (&objfile->objfile_obstack,
|
|
|
|
SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
|
|
|
|
memset (objfile->section_offsets, 0,
|
|
|
|
SIZEOF_N_SECTION_OFFSETS (objfile->num_sections));
|
|
|
|
|
|
|
|
/* This code is run when we first add the objfile with
|
|
|
|
symfile_add_with_addrs_or_offsets, when "addrs" not "offsets" are
|
|
|
|
passed in. The place in symfile.c where the addrs are applied
|
|
|
|
depends on the addrs having section names. But in the dyld code
|
|
|
|
we build an anonymous array of addrs, so that code is a no-op.
|
|
|
|
Because of that, we have to apply the addrs to the sections here.
|
|
|
|
N.B. if an objfile slides after we've already created it, then it
|
|
|
|
goes through objfile_relocate. */
|
|
|
|
|
|
|
|
for (i = 0; i < addrs->num_sections; i++)
|
|
|
|
{
|
|
|
|
ALL_OBJFILE_OSECTIONS (objfile, osect)
|
|
|
|
{
|
|
|
|
const char *bfd_sect_name = osect->the_bfd_section->name;
|
|
|
|
|
|
|
|
if (strcmp (bfd_sect_name, addrs->other[i].name) == 0)
|
|
|
|
{
|
|
|
|
obj_section_offset (osect) = addrs->other[i].addr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
objfile->sect_index_text = 0;
|
|
|
|
|
|
|
|
ALL_OBJFILE_OSECTIONS (objfile, osect)
|
|
|
|
{
|
|
|
|
const char *bfd_sect_name = osect->the_bfd_section->name;
|
2013-04-08 20:04:42 +00:00
|
|
|
int sect_index = osect - objfile->sections;;
|
2011-11-24 16:26:25 +00:00
|
|
|
|
2009-02-04 08:47:56 +00:00
|
|
|
if (strncmp (bfd_sect_name, "LC_SEGMENT.", 11) == 0)
|
|
|
|
bfd_sect_name += 11;
|
|
|
|
if (strcmp (bfd_sect_name, "__TEXT") == 0
|
|
|
|
|| strcmp (bfd_sect_name, "__TEXT.__text") == 0)
|
2008-11-27 09:23:01 +00:00
|
|
|
objfile->sect_index_text = sect_index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-30 19:14:30 +00:00
|
|
|
static const struct sym_fns macho_sym_fns = {
|
2011-01-05 22:22:53 +00:00
|
|
|
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 */
|
2011-03-07 16:17:29 +00:00
|
|
|
NULL, /* sym_read_psymbols */
|
2011-01-05 22:22:53 +00:00
|
|
|
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. */
|
2012-04-27 20:47:57 +00:00
|
|
|
NULL, /* sym_get_probes */
|
2010-09-30 19:14:30 +00:00
|
|
|
&psym_functions
|
2008-11-27 09:23:01 +00:00
|
|
|
};
|
|
|
|
|
2012-03-14 01:46:59 +00:00
|
|
|
/* -Wmissing-prototypes */
|
|
|
|
extern initialize_file_ftype _initialize_machoread;
|
|
|
|
|
2008-11-27 09:23:01 +00:00
|
|
|
void
|
2013-07-01 19:52:32 +00:00
|
|
|
_initialize_machoread (void)
|
2008-11-27 09:23:01 +00:00
|
|
|
{
|
2013-09-25 22:48:19 +00:00
|
|
|
add_symtab_fns (bfd_target_mach_o_flavour, &macho_sym_fns);
|
2008-11-27 09:23:01 +00:00
|
|
|
|
2012-08-02 09:36:40 +00:00
|
|
|
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);
|
2008-11-27 09:23:01 +00:00
|
|
|
}
|