old-cross-binutils/gdb/objfiles.h
Pedro Alves 6c95b8df7f 2009-10-19 Pedro Alves <pedro@codesourcery.com>
Stan Shebs	<stan@codesourcery.com>

	Add base multi-executable/process support to GDB.

	gdb/
	* Makefile.in (SFILES): Add progspace.c.
	(COMMON_OBS): Add progspace.o.
	* progspace.h: New.
	* progspace.c: New.

	* breakpoint.h (struct bp_target_info) <placed_address_space>: New
	field.
	(struct bp_location) <pspace>: New field.
	(struct breakpoint) <pspace>: New field.
	(bpstat_stop_status, breakpoint_here_p)
	(moribund_breakpoint_here_p, breakpoint_inserted_here_p)
	(regular_breakpoint_inserted_here_p)
	(software_breakpoint_inserted_here_p, breakpoint_thread_match)
	(set_default_breakpoint): Adjust prototypes.
	(remove_breakpoints_pid, breakpoint_program_space_exit): Declare.
	(insert_single_step_breakpoint, deprecated_insert_raw_breakpoint):
	Adjust prototypes.
	* breakpoint.c (executing_startup): Delete.
	(default_breakpoint_sspace): New.
	(breakpoint_restore_shadows): Skip if the address space doesn't
	match.
	(update_watchpoint): Record the frame's program space in the
	breakpoint location.
	(insert_bp_location): Record the address space in target_info.
	Adjust to pass the symbol space to solib_name_from_address.
	(breakpoint_program_space_exit): New.
	(insert_breakpoint_locations): Switch the symbol space and thread
	when inserting breakpoints.  Don't insert breakpoints in a vfork
	parent waiting for vfork done if we're not attached to the vfork
	child.
	(remove_breakpoints_pid): New.
	(reattach_breakpoints): Switch to a thread of PID.  Ignore
	breakpoints of other symbol spaces.
	(create_internal_breakpoint): Store the symbol space in the sal.
	(create_longjmp_master_breakpoint): Iterate over all symbol
	spaces.
	(update_breakpoints_after_exec): Ignore breakpoints for other
	symbol spaces.
	(remove_breakpoint): Rename to ...
	(remove_breakpoint_1): ... this.  Pass the breakpoints symbol
	space to solib_name_from_address.
	(remove_breakpoint): New.
	(mark_breakpoints_out): Ignore breakpoints from other symbol
	spaces.
	(breakpoint_init_inferior): Ditto.
	(breakpoint_here_p): Add an address space argument and adjust to
	use breakpoint_address_match.
	(moribund_breakpoint_here_p): Ditto.
	(regular_breakpoint_inserted_here_p): Ditto.
	(breakpoint_inserted_here_p): Ditto.
	(software_breakpoint_inserted_here_p): Ditto.
	(breakpoint_thread_match): Ditto.
	(bpstat_check_location): Ditto.
	(bpstat_stop_status): Ditto.
	(print_breakpoint_location): If there's a location to print,
	switch the current symbol space.
	(print_one_breakpoint_location): Add `allflag' argument.
	(print_one_breakpoint): Ditto.	Adjust.
	(do_captured_breakpoint_query): Adjust.
	(breakpoint_1): Adjust.
	(breakpoint_has_pc): Also match the symbol space.
	(describe_other_breakpoints): Add a symbol space argument and
	adjust.
	(set_default_breakpoint): Add a symbol space argument.	Set
	default_breakpoint_sspace.
	(breakpoint_address_match): New.
	(check_duplicates_for): Add an address space argument, and adjust.
	(set_raw_breakpoint): Record the symbol space in the location and
	in the breakpoint.
	(set_longjmp_breakpoint): Skip longjmp master breakpoints from
	other symbol spaces.
	(remove_thread_event_breakpoints, remove_solib_event_breakpoints)
	(disable_breakpoints_in_shlibs): Skip breakpoints from other
	symbol spaces.
	(disable_breakpoints_in_unloaded_shlib): Match symbol spaces.
	(create_catchpoint): Set the symbol space in the sal.
	(disable_breakpoints_before_startup): Skip breakpoints from other
	symbol spaces.	Set executing_startup in the current symbol space.
	(enable_breakpoints_after_startup): Clear executing_startup in the
	current symbol space.  Skip breakpoints from other symbol spaces.
	(clone_momentary_breakpoint): Also copy the symbol space.
	(add_location_to_breakpoint): Set the location's symbol space.
	(bp_loc_is_permanent): Switch thread and symbol space.
	(create_breakpoint): Adjust.
	(expand_line_sal_maybe): Expand comment to mention symbol spaces.
	Switch thread and symbol space when reading memory.
	(parse_breakpoint_sals): Set the symbol space in the sal.
	(break_command_really): Ditto.
	(skip_prologue_sal): Switch and space.
	(resolve_sal_pc): Ditto.
	(watch_command_1): Record the symbol space in the sal.
	(create_ada_exception_breakpoint): Adjust.
	(clear_command): Adjust.  Match symbol spaces.
	(update_global_location_list): Use breakpoint_address_match.
	(breakpoint_re_set_one): Switch thread and space.
	(breakpoint_re_set): Save symbol space.
	(breakpoint_re_set_thread): Also reset the symbol space.
	(deprecated_insert_raw_breakpoint): Add an address space argument.
	Adjust.
	(insert_single_step_breakpoint): Ditto.
	(single_step_breakpoint_inserted_here_p): Ditto.
	(clear_syscall_counts): New.
	(_initialize_breakpoint): Install it as inferior_exit observer.

	* exec.h: Include "progspace.h".
	(exec_bfd, exec_bfd_mtime): New defines.
	(exec_close): Declare.
	* exec.c: Include "gdbthread.h" and "progspace.h".
	(exec_bfd, exec_bfd_mtime, current_target_sections_1): Delete.
	(using_exec_ops): New.
	(exec_close_1): Rename to exec_close, and make public.
	(exec_close): Rename to exec_close_1, and adjust all callers.  Add
	description.  Remove target sections and close executables from
	all program spaces.
	(exec_file_attach): Add comment.
	(add_target_sections): Check on `using_exec_ops' to check if the
	target should be pushed.
	(remove_target_sections): Only unpush the target if there are no
	more target sections in any symbol space.
	* gdbcore.h: Include "exec.h".
	(exec_bfd, exec_bfd_mtime): Remove declarations.

	* frame.h (get_frame_program_space, get_frame_address_space)
	(frame_unwind_program_space): Declare.
	* frame.c (struct frame_info) <pspace, aspace>: New fields.
	(create_sentinel_frame): Add program space argument.  Set the
	pspace and aspace fields of the frame object.
	(get_current_frame, create_new_frame): Adjust.
	(get_frame_program_space): New.
	(frame_unwind_program_space): New.
	(get_frame_address_space): New.
	* stack.c (print_frame_info): Adjust.
	(print_frame): Use the frame's program space.

	* gdbthread.h (any_live_thread_of_process): Declare.
	* thread.c (any_live_thread_of_process): New.
	(switch_to_thread): Switch the program space as well.
	(restore_selected_frame): Don't warn if trying to restore frame
	level 0.

	* inferior.h: Include "progspace.h".
	(detach_fork): Declare.
	(struct inferior) <removable, aspace, pspace>
	<vfork_parent, vfork_child, pending_detach>
	<waiting_for_vfork_done>: New fields.
	<terminal_info>: Remove field.
	<data, num_data>: New fields.
	(register_inferior_data, register_inferior_data_with_cleanup)
	(clear_inferior_data, set_inferior_data, inferior_data): Declare.
	(exit_inferior, exit_inferior_silent, exit_inferior_num_silent)
	(inferior_appeared): Declare.
	(find_inferior_pid): Typo.
	(find_inferior_id, find_inferior_for_program_space): Declare.
	(set_current_inferior, save_current_inferior, prune_inferiors)
	(number_of_inferiors): Declare.
	(inferior_list): Declare.
	* inferior.c: Include "gdbcore.h" and "symfile.h".
	(inferior_list): Make public.
	(delete_inferior_1): Always delete thread silently.
	(find_inferior_id): Make public.
	(current_inferior_): New.
	(current_inferior): Use it.
	(set_current_inferior): New.
	(restore_inferior): New.
	(save_current_inferior): New.
	(free_inferior): Free the per-inferior data.
	(add_inferior_silent): Allocate per-inferior data.
	Call inferior_appeared.
	(delete_threads_of_inferior): New.
	(delete_inferior_1): Adjust interface to take an inferior pointer.
	(delete_inferior): Adjust.
	(delete_inferior_silent): Adjust.
	(exit_inferior_1): New.
	(exit_inferior): New.
	(exit_inferior_silent): New.
	(exit_inferior_num_silent): New.
	(detach_inferior): Adjust.
	(inferior_appeared): New.
	(discard_all_inferiors): Adjust.
	(find_inferior_id): Make public.  Assert pid is not zero.
	(find_inferior_for_program_space): New.
	(have_inferiors): Check if we have any inferior with pid not zero.
	(have_live_inferiors): Go over all pushed targets looking for
	process_stratum.
	(prune_inferiors): New.
	(number_of_inferiors): New.
	(print_inferior): Add executable column.  Print vfork parent/child
	relationships.
	(inferior_command): Adjust to cope with not running inferiors.
	(remove_inferior_command): New.
	(add_inferior_command): New.
	(clone_inferior_command): New.
	(struct inferior_data): New.
	(struct inferior_data_registration): New.
	(struct inferior_data_registry): New.
	(inferior_data_registry): New.
	(register_inferior_data_with_cleanup): New.
	(register_inferior_data): New.
	(inferior_alloc_data): New.
	(inferior_free_data): New.
	(clear_inferior_data): New.
	(set_inferior_data): New.
	(inferior_data): New.
	(initialize_inferiors): New.
	(_initialize_inferiors): Register "add-inferior",
	"remove-inferior" and "clone-inferior" commands.

	* objfiles.h: Include "progspace.h".
	(struct objfile) <pspace>: New field.
	(symfile_objfile, object_files): Don't declare.
	(ALL_PSPACE_OBJFILES): New.
	(ALL_PSPACE_OBJFILES_SAFE): New.
	(ALL_OBJFILES, ALL_OBJFILES_SAFE): Adjust.
	(ALL_PSPACE_SYMTABS): New.
	(ALL_PRIMARY_SYMTABS): Adjust.
	(ALL_PSPACE_PRIMARY_SYMTABS): New.
	(ALL_PSYMTABS): Adjust.
	(ALL_PSPACE_PSYMTABS): New.
	* objfiles.c (object_files, symfile_objfile): Delete.
	(struct objfile_sspace_info): New.
	(objfiles_pspace_data): New.
	(objfiles_pspace_data_cleanup): New.
	(get_objfile_pspace_data): New.
	(objfiles_changed_p): Delete.
	(allocate_objfile): Set the objfile's program space.  Adjust to
	reference objfiles_changed_p in pspace data.
	(free_objfile): Adjust to reference objfiles_changed_p in pspace
	data.
	(objfile_relocate): Ditto.
	(update_section_map): Add pspace argument.  Adjust to iterate over
	objfiles in the passed in pspace.
	(find_pc_section): Delete sections and num_sections statics.
	Adjust to refer to program space's objfiles_changed_p.	Adjust to
	refer to sections and num_sections store in the objfile's pspace
	data.
	(objfiles_changed): Adjust to reference objfiles_changed_p in
	pspace data.
	(_initialize_objfiles): New.
	* linespec.c (decode_all_digits, decode_dollar): Set the sal's
	program space.
	* source.c (current_source_pspace): New.
	(get_current_source_symtab_and_line): Set the sal's program space.
	(set_current_source_symtab_and_line): Set current_source_pspace.
	(select_source_symtab): Ditto.	Use ALL_OBJFILES.
	(forget_cached_source_info): Iterate over all program spaces.
	* symfile.c (clear_symtab_users): Adjust.
	* symmisc.c (print_symbol_bcache_statistics): Iterate over all
	program spaces.
	(print_objfile_statistics): Ditto.
	(maintenance_print_msymbols): Ditto.
	(maintenance_print_objfiles): Ditto.
	(maintenance_info_symtabs): Ditto.
	(maintenance_info_psymtabs): Ditto.
	* symtab.h (SYMTAB_PSPACE): New.
	(struct symtab_and_line) <pspace>: New field.
	* symtab.c (init_sal): Clear the sal's program space.
	(find_pc_sect_symtab): Set the sal's program space.  Switch thread
	and space.
	(append_expanded_sal): Add program space argument.  Iterate over
	all program spaces.
	(expand_line_sal): Iterate over all program spaces.  Switch
	program space.

	* target.h (enum target_waitkind) <TARGET_WAITKIND_VFORK_DONE>: New.
	(struct target_ops) <to_thread_address_space>: New field.
	(target_thread_address_space): Define.
	* target.c (target_detach): Only remove breakpoints from the
	inferior we're detaching.
	(target_thread_address_space): New.

	* defs.h (initialize_progspace): Declare.
	* top.c (gdb_init): Call it.

	* solist.h (struct so_list) <sspace>: New field.
	* solib.h (struct program_space): Forward declare.
	(solib_name_from_address): Adjust prototype.
	* solib.c (so_list_head): Replace with a macro referencing the
	program space.
	(update_solib_list): Set the so's program space.
	(solib_name_from_address): Add a program space argument and adjust.

	* solib-svr4.c (struct svr4_info) <pid>: Delete field.
	<interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low>
	<interp_plt_sect_high>: New fields.
	(svr4_info_p, svr4_info): Delete.
	(solib_svr4_sspace_data): New.
	(get_svr4_info): Rewrite.
	(svr4_sspace_data_cleanup): New.
	(open_symbol_file_object): Adjust.
	(svr4_default_sos): Adjust.
	(svr4_fetch_objfile_link_map): Adjust.
	(interp_text_sect_low, interp_text_sect_high, interp_plt_sect_low)
	(interp_plt_sect_high): Delete.
	(svr4_in_dynsym_resolve_code): Adjust.
	(enable_break): Adjust.
	(svr4_clear_solib): Revert bit that removed the svr4_info here,
	and reinstate clearing debug_base, debug_loader_offset_p,
	debug_loader_offset and debug_loader_name.
	(_initialize_svr4_solib): Register solib_svr4_pspace_data.  Don't
	install an inferior_exit observer anymore.

	* printcmd.c (struct display) <pspace>: New field.
	(display_command): Set the display's sspace.
	(do_one_display): Match the display's sspace.
	(display_uses_solib_p): Ditto.

	* linux-fork.c (detach_fork): Moved to infrun.c.
	(_initialize_linux_fork): Moved "detach-on-fork" command to
	infrun.c.
	* infrun.c (detach_fork): Moved from linux-fork.c.
	(proceed_after_vfork_done): New.
	(handle_vfork_child_exec_or_exit): New.
	(follow_exec_mode_replace, follow_exec_mode_keep)
	(follow_exec_mode_names, follow_exec_mode_string)
	(show_follow_exec_mode_string): New.
	(follow_exec): New.  Reinstate the mark_breakpoints_out call.
	Remove shared libraries before attaching new executable.  If user
	wants to keep the inferior, keep it.
	(displaced_step_fixup): Adjust to pass an address space to the
	breakpoints module.
	(resume): Ditto.
	(clear_proceed_status): In all-stop mode, always clear the proceed
	status of all threads.
	(prepare_to_proceed): Adjust to pass an address space to the
	breakpoints module.
	(proceed): Ditto.
	(adjust_pc_after_break): Ditto.
	(handle_inferior_event): When handling a process exit, switch the
	program space to the inferior's that had exited.  Call
	handle_vfork_child_exec_or_exit.  Adjust to pass an address space
	to the breakpoints module.  In non-stop mode, when following a
	fork and detach-fork is off, also resume the other branch.  Handle
	TARGET_WAITKIND_VFORK_DONE.  Set the program space in sals.
	(normal_stop): Prune inferiors.
	(_initialize_infrun): Install the new "follow-exec-mode" command.
	"detach-on-fork" moved here.

	* regcache.h (get_regcache_aspace): Declare.
	* regcache.c (struct regcache) <aspace>: New field.
	(regcache_xmalloc): Clear the aspace.
	(get_regcache_aspace): New.
	(regcache_cpy): Copy the aspace field.
	(regcache_cpy_no_passthrough): Ditto.
	(get_thread_regcache): Fetch the thread's address space from the
	target, and store it in the regcache.

	* infcall.c (call_function_by_hand): Set the sal's pspace.

	* arch-utils.c (default_has_shared_address_space): New.
	* arch-utils.h (default_has_shared_address_space): Declare.

	* gdbarch.sh (has_shared_address_space): New.
	* gdbarch.h, gdbarch.c: Regenerate.

	* linux-tdep.c: Include auxv.h, target.h, elf/common.h.
	(linux_has_shared_address_space): New.
	(_initialize_linux_tdep): Declare.

	* arm-tdep.c (arm_software_single_step): Pass the frame's address
	space to insert_single_step_breakpoint.
	* arm-linux-tdep.c (arm_linux_software_single_step): Pass the
	frame's pspace to breakpoint functions.
	* cris-tdep.c (crisv32_single_step_through_delay): Ditto.
	(cris_software_single_step): Ditto.
	* mips-tdep.c (deal_with_atomic_sequence): Add frame argument.
	Pass the frame's pspace to breakpoint functions.
	(mips_software_single_step): Adjust.
	(mips_single_step_through_delay): Adjust.
	* rs6000-aix-tdep.c (rs6000_software_single_step): Adjust.
	* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Adjust.
	* solib-irix.c (enable_break): Adjust to pass the current frame's
	address space to breakpoint functions.
	* sparc-tdep.c (sparc_software_single_step): Ditto.
	* spu-tdep.c (spu_software_single_step): Ditto.
	* alpha-tdep.c (alpha_software_single_step): Ditto.
	* record.c (record_wait): Adjust to pass an address space to the
	breakpoints module.

	* fork-child.c (fork_inferior): Set the new inferior's program and
	address spaces.
	* inf-ptrace.c (inf_ptrace_follow_fork): Copy the parent's program
	and address spaces.
	(inf_ptrace_attach): Set the inferior's program and address spaces.
	* linux-nat.c: Include "solib.h".
	(linux_child_follow_fork): Manage parent and child's program and
	address spaces.	 Clone the parent's program space if necessary.
	Don't wait for the vfork to be done here.  Refuse to resume if
	following the vfork parent while leaving the child stopped.
	(resume_callback): Don't resume a vfork parent.
	(linux_nat_resume): Also check for pending events in the
	lp->waitstatus field.
	(linux_handle_extended_wait): Report TARGET_WAITKIND_VFORK_DONE
	events to the core.
	(stop_wait_callback): Don't wait for SIGSTOP on vfork parents.
	(cancel_breakpoint): Adjust.
	* linux-thread-db.c (thread_db_wait): Don't remove thread event
	breakpoints here.
	(thread_db_mourn_inferior): Don't mark breakpoints out here.
	Remove thread event breakpoints after mourning.
	* corelow.c: Include progspace.h.
	(core_open): Set the inferior's program and address spaces.
	* remote.c (remote_add_inferior): Set the new inferior's program
	and address spaces.
	(remote_start_remote): Update address spaces.
	(extended_remote_create_inferior_1): Don't init the thread list if
	we already debugging other inferiors.
	* darwin-nat.c (darwin_attach): Set the new inferior's program and
	address spaces.
	* gnu-nat.c (gnu_attach): Ditto.
	* go32-nat.c (go32_create_inferior): Ditto.
	* inf-ttrace.c (inf_ttrace_follow_fork, inf_ttrace_attach): Ditto.
	* monitor.c (monitor_open): Ditto.
	* nto-procfs.c (procfs_attach, procfs_create_inferior): Ditto.
	* procfs.c (do_attach): Ditto.
	* windows-nat.c (do_initial_windows_stuff): Ditto.

	* inflow.c (inferior_process_group)
	(terminal_init_inferior_with_pgrp, terminal_inferior,
	(terminal_ours_1, inflow_inferior_exit, copy_terminal_info)
	(child_terminal_info, new_tty_postfork, set_sigint_trap): Adjust
	to use per-inferior data instead of inferior->terminal_info.
	(inflow_inferior_data): New.
	(inflow_new_inferior): Delete.
	(inflow_inferior_data_cleanup): New.
	(get_inflow_inferior_data): New.

	* mi/mi-interp.c (mi_new_inferior): Rename to...
	(mi_inferior_appeared): ... this.
	(mi_interpreter_init): Adjust.

	* tui/tui-disasm.c: Include "progspace.h".
	(tui_set_disassem_content): Pass an address space to
	breakpoint_here_p.

	* NEWS: Mention multi-program debugging support.  Mention new
	commands "add-inferior", "clone-inferior", "remove-inferior",
	"maint info program-spaces", and new option "set
	follow-exec-mode".

2009-10-19  Pedro Alves	 <pedro@codesourcery.com>
	    Stan Shebs	<stan@codesourcery.com>

	gdb/doc/
	* observer.texi (new_inferior): Rename to...
	(inferior_appeared): ... this.

2009-10-19  Pedro Alves	 <pedro@codesourcery.com>
	    Stan Shebs	<stan@codesourcery.com>

	gdb/testsuite/
	* gdb.base/foll-vfork.exp: Adjust to spell out "follow-fork".
	* gdb.base/foll-exec.exp: Adjust to expect a process id before
	"Executing new program".
	* gdb.base/foll-fork.exp: Adjust to spell out "follow-fork".
	* gdb.base/multi-forks.exp: Ditto.  Adjust to the inferior being
	left listed after having been killed.
	* gdb.base/attach.exp: Adjust to spell out "symbol-file".
	* gdb.base/maint.exp: Adjust test.

	* Makefile.in (ALL_SUBDIRS): Add gdb.multi.
	* gdb.multi/Makefile.in: New.
	* gdb.multi/base.exp: New.
	* gdb.multi/goodbye.c: New.
	* gdb.multi/hangout.c: New.
	* gdb.multi/hello.c: New.
	* gdb.multi/bkpt-multi-exec.c: New.
	* gdb.multi/bkpt-multi-exec.exp: New.
	* gdb.multi/crashme.c: New.

2009-10-19  Pedro Alves	 <pedro@codesourcery.com>
	    Stan Shebs	<stan@codesourcery.com>

	gdb/doc/
	* gdb.texinfo (Inferiors): Rename node to ...
	(Inferiors and Programs): ... this.  Mention running multiple
	programs in the same debug session.
	<info inferiors>: Mention the new 'Executable' column if "info
	inferiors".  Update examples.  Document the "add-inferior",
	"clone-inferior", "remove-inferior" and "maint info
	program-spaces" commands.
	(Process): Rename node to...
	(Forks): ... this.  Document "set|show follow-exec-mode".
2009-10-19 09:51:43 +00:00

635 lines
25 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Definitions for symbol file management in GDB.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
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
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#if !defined (OBJFILES_H)
#define OBJFILES_H
#include "gdb_obstack.h" /* For obstack internals. */
#include "symfile.h" /* For struct psymbol_allocation_list */
#include "progspace.h"
struct bcache;
struct htab;
struct symtab;
struct objfile_data;
/* This structure maintains information on a per-objfile basis about the
"entry point" of the objfile, and the scope within which the entry point
exists. It is possible that gdb will see more than one objfile that is
executable, each with its own entry point.
For example, for dynamically linked executables in SVR4, the dynamic linker
code is contained within the shared C library, which is actually executable
and is run by the kernel first when an exec is done of a user executable
that is dynamically linked. The dynamic linker within the shared C library
then maps in the various program segments in the user executable and jumps
to the user executable's recorded entry point, as if the call had been made
directly by the kernel.
The traditional gdb method of using this info was to use the
recorded entry point to set the entry-file's lowpc and highpc from
the debugging information, where these values are the starting
address (inclusive) and ending address (exclusive) of the
instruction space in the executable which correspond to the
"startup file", I.E. crt0.o in most cases. This file is assumed to
be a startup file and frames with pc's inside it are treated as
nonexistent. Setting these variables is necessary so that
backtraces do not fly off the bottom of the stack.
NOTE: cagney/2003-09-09: It turns out that this "traditional"
method doesn't work. Corinna writes: ``It turns out that the call
to test for "inside entry file" destroys a meaningful backtrace
under some conditions. E. g. the backtrace tests in the asm-source
testcase are broken for some targets. In this test the functions
are all implemented as part of one file and the testcase is not
necessarily linked with a start file (depending on the target).
What happens is, that the first frame is printed normaly and
following frames are treated as being inside the enttry file then.
This way, only the #0 frame is printed in the backtrace output.''
Ref "frame.c" "NOTE: vinschen/2003-04-01".
Gdb also supports an alternate method to avoid running off the bottom
of the stack.
There are two frames that are "special", the frame for the function
containing the process entry point, since it has no predecessor frame,
and the frame for the function containing the user code entry point
(the main() function), since all the predecessor frames are for the
process startup code. Since we have no guarantee that the linked
in startup modules have any debugging information that gdb can use,
we need to avoid following frame pointers back into frames that might
have been built in the startup code, as we might get hopelessly
confused. However, we almost always have debugging information
available for main().
These variables are used to save the range of PC values which are
valid within the main() function and within the function containing
the process entry point. If we always consider the frame for
main() as the outermost frame when debugging user code, and the
frame for the process entry point function as the outermost frame
when debugging startup code, then all we have to do is have
DEPRECATED_FRAME_CHAIN_VALID return false whenever a frame's
current PC is within the range specified by these variables. In
essence, we set "ceilings" in the frame chain beyond which we will
not proceed when following the frame chain back up the stack.
A nice side effect is that we can still debug startup code without
running off the end of the frame chain, assuming that we have usable
debugging information in the startup modules, and if we choose to not
use the block at main, or can't find it for some reason, everything
still works as before. And if we have no startup code debugging
information but we do have usable information for main(), backtraces
from user code don't go wandering off into the startup code. */
struct entry_info
{
/* The value we should use for this objects entry point.
The illegal/unknown value needs to be something other than 0, ~0
for instance, which is much less likely than 0. */
CORE_ADDR entry_point;
#define INVALID_ENTRY_POINT (~0) /* ~0 will not be in any file, we hope. */
};
/* Sections in an objfile. The section offsets are stored in the
OBJFILE. */
struct obj_section
{
struct bfd_section *the_bfd_section; /* BFD section pointer */
/* Objfile this section is part of. */
struct objfile *objfile;
/* True if this "overlay section" is mapped into an "overlay region". */
int ovly_mapped;
};
/* Relocation offset applied to S. */
#define obj_section_offset(s) \
(((s)->objfile->section_offsets)->offsets[(s)->the_bfd_section->index])
/* The memory address of section S (vma + offset). */
#define obj_section_addr(s) \
(bfd_get_section_vma ((s)->objfile->abfd, s->the_bfd_section) \
+ obj_section_offset (s))
/* The one-passed-the-end memory address of section S
(vma + size + offset). */
#define obj_section_endaddr(s) \
(bfd_get_section_vma ((s)->objfile->abfd, s->the_bfd_section) \
+ bfd_get_section_size ((s)->the_bfd_section) \
+ obj_section_offset (s))
/* The "objstats" structure provides a place for gdb to record some
interesting information about its internal state at runtime, on a
per objfile basis, such as information about the number of symbols
read, size of string table (if any), etc. */
struct objstats
{
int n_minsyms; /* Number of minimal symbols read */
int n_psyms; /* Number of partial symbols read */
int n_syms; /* Number of full symbols read */
int n_stabs; /* Number of ".stabs" read (if applicable) */
int n_types; /* Number of types */
int sz_strtab; /* Size of stringtable, (if applicable) */
};
#define OBJSTAT(objfile, expr) (objfile -> stats.expr)
#define OBJSTATS struct objstats stats
extern void print_objfile_statistics (void);
extern void print_symbol_bcache_statistics (void);
/* Number of entries in the minimal symbol hash table. */
#define MINIMAL_SYMBOL_HASH_SIZE 2039
/* Master structure for keeping track of each file from which
gdb reads symbols. There are several ways these get allocated: 1.
The main symbol file, symfile_objfile, set by the symbol-file command,
2. Additional symbol files added by the add-symbol-file command,
3. Shared library objfiles, added by ADD_SOLIB, 4. symbol files
for modules that were loaded when GDB attached to a remote system
(see remote-vx.c). */
struct objfile
{
/* All struct objfile's are chained together by their next pointers.
The global variable "object_files" points to the first link in this
chain.
FIXME: There is a problem here if the objfile is reusable, and if
multiple users are to be supported. The problem is that the objfile
list is linked through a member of the objfile struct itself, which
is only valid for one gdb process. The list implementation needs to
be changed to something like:
struct list {struct list *next; struct objfile *objfile};
where the list structure is completely maintained separately within
each gdb process. */
struct objfile *next;
/* The object file's name, tilde-expanded and absolute.
Malloc'd; free it if you free this struct. */
char *name;
/* Some flag bits for this objfile. */
unsigned short flags;
/* The program space associated with this objfile. */
struct program_space *pspace;
/* Each objfile points to a linked list of symtabs derived from this file,
one symtab structure for each compilation unit (source file). Each link
in the symtab list contains a backpointer to this objfile. */
struct symtab *symtabs;
/* Each objfile points to a linked list of partial symtabs derived from
this file, one partial symtab structure for each compilation unit
(source file). */
struct partial_symtab *psymtabs;
/* Map addresses to the entries of PSYMTABS. It would be more efficient to
have a map per the whole process but ADDRMAP cannot selectively remove
its items during FREE_OBJFILE. This mapping is already present even for
PARTIAL_SYMTABs which still have no corresponding full SYMTABs read. */
struct addrmap *psymtabs_addrmap;
/* List of freed partial symtabs, available for re-use */
struct partial_symtab *free_psymtabs;
/* The object file's BFD. Can be null if the objfile contains only
minimal symbols, e.g. the run time common symbols for SunOS4. */
bfd *obfd;
/* The gdbarch associated with the BFD. Note that this gdbarch is
determined solely from BFD information, without looking at target
information. The gdbarch determined from a running target may
differ from this e.g. with respect to register types and names. */
struct gdbarch *gdbarch;
/* The modification timestamp of the object file, as of the last time
we read its symbols. */
long mtime;
/* Obstack to hold objects that should be freed when we load a new symbol
table from this object file. */
struct obstack objfile_obstack;
/* A byte cache where we can stash arbitrary "chunks" of bytes that
will not change. */
struct bcache *psymbol_cache; /* Byte cache for partial syms */
struct bcache *macro_cache; /* Byte cache for macros */
/* Hash table for mapping symbol names to demangled names. Each
entry in the hash table is actually two consecutive strings,
both null-terminated; the first one is a mangled or linkage
name, and the second is the demangled name or just a zero byte
if the name doesn't demangle. */
struct htab *demangled_names_hash;
/* Vectors of all partial symbols read in from file. The actual data
is stored in the objfile_obstack. */
struct psymbol_allocation_list global_psymbols;
struct psymbol_allocation_list static_psymbols;
/* Each file contains a pointer to an array of minimal symbols for all
global symbols that are defined within the file. The array is terminated
by a "null symbol", one that has a NULL pointer for the name and a zero
value for the address. This makes it easy to walk through the array
when passed a pointer to somewhere in the middle of it. There is also
a count of the number of symbols, which does not include the terminating
null symbol. The array itself, as well as all the data that it points
to, should be allocated on the objfile_obstack for this file. */
struct minimal_symbol *msymbols;
int minimal_symbol_count;
/* This is a hash table used to index the minimal symbols by name. */
struct minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE];
/* This hash table is used to index the minimal symbols by their
demangled names. */
struct minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE];
/* Structure which keeps track of functions that manipulate objfile's
of the same type as this objfile. I.E. the function to read partial
symbols for example. Note that this structure is in statically
allocated memory, and is shared by all objfiles that use the
object module reader of this type. */
struct sym_fns *sf;
/* The per-objfile information about the entry point, the scope (file/func)
containing the entry point, and the scope of the user's main() func. */
struct entry_info ei;
/* Information about stabs. Will be filled in with a dbx_symfile_info
struct by those readers that need it. */
/* NOTE: cagney/2004-10-23: This has been replaced by per-objfile
data points implemented using "data" and "num_data" below. For
an example of how to use this replacement, see "objfile_data"
in "mips-tdep.c". */
struct dbx_symfile_info *deprecated_sym_stab_info;
/* Hook for information for use by the symbol reader (currently used
for information shared by sym_init and sym_read). It is
typically a pointer to malloc'd memory. The symbol reader's finish
function is responsible for freeing the memory thusly allocated. */
/* NOTE: cagney/2004-10-23: This has been replaced by per-objfile
data points implemented using "data" and "num_data" below. For
an example of how to use this replacement, see "objfile_data"
in "mips-tdep.c". */
void *deprecated_sym_private;
/* Per objfile data-pointers required by other GDB modules. */
/* FIXME: kettenis/20030711: This mechanism could replace
deprecated_sym_stab_info and deprecated_sym_private
entirely. */
void **data;
unsigned num_data;
/* Set of relocation offsets to apply to each section.
Currently on the objfile_obstack (which makes no sense, but I'm
not sure it's harming anything).
These offsets indicate that all symbols (including partial and
minimal symbols) which have been read have been relocated by this
much. Symbols which are yet to be read need to be relocated by
it. */
struct section_offsets *section_offsets;
int num_sections;
/* Indexes in the section_offsets array. These are initialized by the
*_symfile_offsets() family of functions (som_symfile_offsets,
xcoff_symfile_offsets, default_symfile_offsets). In theory they
should correspond to the section indexes used by bfd for the
current objfile. The exception to this for the time being is the
SOM version. */
int sect_index_text;
int sect_index_data;
int sect_index_bss;
int sect_index_rodata;
/* These pointers are used to locate the section table, which
among other things, is used to map pc addresses into sections.
SECTIONS points to the first entry in the table, and
SECTIONS_END points to the first location past the last entry
in the table. Currently the table is stored on the
objfile_obstack (which makes no sense, but I'm not sure it's
harming anything). */
struct obj_section
*sections, *sections_end;
/* Link to objfile that contains the debug symbols for this one.
One is loaded if this file has an debug link to an existing
debug file with the right checksum */
struct objfile *separate_debug_objfile;
/* If this is a separate debug object, this is used as a link to the
actual executable objfile. */
struct objfile *separate_debug_objfile_backlink;
/* Place to stash various statistics about this objfile */
OBJSTATS;
/* A symtab that the C++ code uses to stash special symbols
associated to namespaces. */
/* FIXME/carlton-2003-06-27: Delete this in a few years once
"possible namespace symbols" go away. */
struct symtab *cp_namespace_symtab;
};
/* Defines for the objfile flag word. */
/* When an object file has its functions reordered (currently Irix-5.2
shared libraries exhibit this behaviour), we will need an expensive
algorithm to locate a partial symtab or symtab via an address.
To avoid this penalty for normal object files, we use this flag,
whose setting is determined upon symbol table read in. */
#define OBJF_REORDERED (1 << 0) /* Functions are reordered */
/* Distinguish between an objfile for a shared library and a "vanilla"
objfile. (If not set, the objfile may still actually be a solib.
This can happen if the user created the objfile by using the
add-symbol-file command. GDB doesn't in that situation actually
check whether the file is a solib. Rather, the target's
implementation of the solib interface is responsible for setting
this flag when noticing solibs used by an inferior.) */
#define OBJF_SHARED (1 << 1) /* From a shared library */
/* User requested that this objfile be read in it's entirety. */
#define OBJF_READNOW (1 << 2) /* Immediate full read */
/* This objfile was created because the user explicitly caused it
(e.g., used the add-symbol-file command). This bit offers a way
for run_command to remove old objfile entries which are no longer
valid (i.e., are associated with an old inferior), but to preserve
ones that the user explicitly loaded via the add-symbol-file
command. */
#define OBJF_USERLOADED (1 << 3) /* User loaded */
/* The object file that contains the runtime common minimal symbols
for SunOS4. Note that this objfile has no associated BFD. */
extern struct objfile *rt_common_objfile;
/* When we need to allocate a new type, we need to know which objfile_obstack
to allocate the type on, since there is one for each objfile. The places
where types are allocated are deeply buried in function call hierarchies
which know nothing about objfiles, so rather than trying to pass a
particular objfile down to them, we just do an end run around them and
set current_objfile to be whatever objfile we expect to be using at the
time types are being allocated. For instance, when we start reading
symbols for a particular objfile, we set current_objfile to point to that
objfile, and when we are done, we set it back to NULL, to ensure that we
never put a type someplace other than where we are expecting to put it.
FIXME: Maybe we should review the entire type handling system and
see if there is a better way to avoid this problem. */
extern struct objfile *current_objfile;
/* Declarations for functions defined in objfiles.c */
extern struct objfile *allocate_objfile (bfd *, int);
extern struct gdbarch *get_objfile_arch (struct objfile *);
extern void init_entry_point_info (struct objfile *);
extern CORE_ADDR entry_point_address (void);
extern int build_objfile_section_table (struct objfile *);
extern void terminate_minimal_symbol_table (struct objfile *objfile);
extern void put_objfile_before (struct objfile *, struct objfile *);
extern void objfile_to_front (struct objfile *);
extern void unlink_objfile (struct objfile *);
extern void free_objfile (struct objfile *);
extern struct cleanup *make_cleanup_free_objfile (struct objfile *);
extern void free_all_objfiles (void);
extern void objfile_relocate (struct objfile *, struct section_offsets *);
extern int objfile_has_partial_symbols (struct objfile *objfile);
extern int objfile_has_full_symbols (struct objfile *objfile);
extern int objfile_has_symbols (struct objfile *objfile);
extern int have_partial_symbols (void);
extern int have_full_symbols (void);
extern void objfiles_changed (void);
/* This operation deletes all objfile entries that represent solibs that
weren't explicitly loaded by the user, via e.g., the add-symbol-file
command.
*/
extern void objfile_purge_solibs (void);
/* Functions for dealing with the minimal symbol table, really a misc
address<->symbol mapping for things we don't have debug symbols for. */
extern int have_minimal_symbols (void);
extern struct obj_section *find_pc_section (CORE_ADDR pc);
extern int in_plt_section (CORE_ADDR, char *);
/* Keep a registry of per-objfile data-pointers required by other GDB
modules. */
/* Allocate an entry in the per-objfile registry. */
extern const struct objfile_data *register_objfile_data (void);
/* Allocate an entry in the per-objfile registry.
SAVE and FREE are called when clearing objfile data.
First all registered SAVE functions are called.
Then all registered FREE functions are called.
Either or both of SAVE, FREE may be NULL. */
extern const struct objfile_data *register_objfile_data_with_cleanup
(void (*save) (struct objfile *, void *),
void (*free) (struct objfile *, void *));
extern void clear_objfile_data (struct objfile *objfile);
extern void set_objfile_data (struct objfile *objfile,
const struct objfile_data *data, void *value);
extern void *objfile_data (struct objfile *objfile,
const struct objfile_data *data);
extern struct bfd *gdb_bfd_ref (struct bfd *abfd);
extern void gdb_bfd_unref (struct bfd *abfd);
/* Traverse all object files in the current program space.
ALL_OBJFILES_SAFE works even if you delete the objfile during the
traversal. */
/* Traverse all object files in program space SS. */
#define ALL_PSPACE_OBJFILES(ss, obj) \
for ((obj) = ss->objfiles; (obj) != NULL; (obj) = (obj)->next) \
#define ALL_PSPACE_OBJFILES_SAFE(ss, obj, nxt) \
for ((obj) = ss->objfiles; \
(obj) != NULL? ((nxt)=(obj)->next,1) :0; \
(obj) = (nxt))
#define ALL_OBJFILES(obj) \
for ((obj) = current_program_space->objfiles; \
(obj) != NULL; \
(obj) = (obj)->next)
#define ALL_OBJFILES_SAFE(obj,nxt) \
for ((obj) = current_program_space->objfiles; \
(obj) != NULL? ((nxt)=(obj)->next,1) :0; \
(obj) = (nxt))
/* Traverse all symtabs in one objfile. */
#define ALL_OBJFILE_SYMTABS(objfile, s) \
for ((s) = (objfile) -> symtabs; (s) != NULL; (s) = (s) -> next)
/* Traverse all psymtabs in one objfile. */
#define ALL_OBJFILE_PSYMTABS(objfile, p) \
for ((p) = (objfile) -> psymtabs; (p) != NULL; (p) = (p) -> next)
/* Traverse all minimal symbols in one objfile. */
#define ALL_OBJFILE_MSYMBOLS(objfile, m) \
for ((m) = (objfile) -> msymbols; SYMBOL_LINKAGE_NAME(m) != NULL; (m)++)
/* Traverse all symtabs in all objfiles in the current symbol
space. */
#define ALL_SYMTABS(objfile, s) \
ALL_OBJFILES (objfile) \
ALL_OBJFILE_SYMTABS (objfile, s)
#define ALL_PSPACE_SYMTABS(ss, objfile, s) \
ALL_PSPACE_OBJFILES (ss, objfile) \
ALL_OBJFILE_SYMTABS (objfile, s)
/* Traverse all symtabs in all objfiles in the current program space,
skipping included files (which share a blockvector with their
primary symtab). */
#define ALL_PRIMARY_SYMTABS(objfile, s) \
ALL_OBJFILES (objfile) \
ALL_OBJFILE_SYMTABS (objfile, s) \
if ((s)->primary)
#define ALL_PSPACE_PRIMARY_SYMTABS(pspace, objfile, s) \
ALL_PSPACE_OBJFILES (ss, objfile) \
ALL_OBJFILE_SYMTABS (objfile, s) \
if ((s)->primary)
/* Traverse all psymtabs in all objfiles in the current symbol
space. */
#define ALL_PSYMTABS(objfile, p) \
ALL_OBJFILES (objfile) \
ALL_OBJFILE_PSYMTABS (objfile, p)
#define ALL_PSPACE_PSYMTABS(ss, objfile, p) \
ALL_PSPACE_OBJFILES (ss, objfile) \
ALL_OBJFILE_PSYMTABS (objfile, p)
/* Traverse all minimal symbols in all objfiles in the current symbol
space. */
#define ALL_MSYMBOLS(objfile, m) \
ALL_OBJFILES (objfile) \
ALL_OBJFILE_MSYMBOLS (objfile, m)
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++)
#define ALL_OBJSECTIONS(objfile, osect) \
ALL_OBJFILES (objfile) \
ALL_OBJFILE_OSECTIONS (objfile, osect)
#define SECT_OFF_DATA(objfile) \
((objfile->sect_index_data == -1) \
? (internal_error (__FILE__, __LINE__, _("sect_index_data not initialized")), -1) \
: objfile->sect_index_data)
#define SECT_OFF_RODATA(objfile) \
((objfile->sect_index_rodata == -1) \
? (internal_error (__FILE__, __LINE__, _("sect_index_rodata not initialized")), -1) \
: objfile->sect_index_rodata)
#define SECT_OFF_TEXT(objfile) \
((objfile->sect_index_text == -1) \
? (internal_error (__FILE__, __LINE__, _("sect_index_text not initialized")), -1) \
: objfile->sect_index_text)
/* Sometimes the .bss section is missing from the objfile, so we don't
want to die here. Let the users of SECT_OFF_BSS deal with an
uninitialized section index. */
#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
/* Answer whether there is more than one object file loaded. */
#define MULTI_OBJFILE_P() (object_files && object_files->next)
#endif /* !defined (OBJFILES_H) */