From 07b82ea5f9396811815e8085a4cce5ca03f50fb5 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 3 Jun 2009 18:50:36 +0000 Subject: * target.c: Include "exec.h". (update_current_target): Don't inherit to_sections or to_sections_end. (target_get_section_table): New. (target_section_by_addr): Fetch the section table from the passed in target. (memory_xfer_partial): Handle unmapped overlay sections before anything else. Get the overlay mapped address here. Adjust to use section_table_xfer_memory_partial. (get_target_memory): Request a TARGET_OBJECT_RAW_MEMORY object instead of TARGET_OBJECT_MEMORY. (target_resize_to_sections): Delete. (remove_target_sections): Adjust to remove target sections from `current_target_sections', and use resize_section_table. * target.h (struct target_ops) : Remove fields. : New method. (xfer_memory, print_section_info): Delete declarations. (struct target_section_table): New type. (target_get_section_table): Declare. (target_resize_to_sections): Delete declaration. (remove_target_sections): Delete declaration. * bfd-target.c (target_bfd_xfer_partial): Get the section table from to_data. (target_bfd_get_section_table): New. (target_bfd_xclose): Adjust. (target_bfd_reopen): Store the section table in the to_data field. * corelow.c (core_data): New. (core_close): Adjust to release core_data and its sections. (core_open): Allocate core_data, and build its target sections table. (deprecated_core_resize_section_table): New. (core_files_info): Pass core_data to print_section_info. (core_xfer_partial): Adjust to use section_table_xfer_memory_partial for TARGET_OBJECT_MEMORY xfers. (init_core_ops): Do not install a deprecated_xfer_memory callback anymore. * solib.c (update_solib_list): Add the shared library sections to the current target sections table. * exec.c (current_target_sections_1): New global. (current_target_sections): New global. (exec_close_1): New function, refactored from exec_close. Remove the exec_bfd's sections from the current target sections table. Adjust to not use to_sections. (exec_close): Remove all target sections. Call exec_close_1. (exec_file_clear): Use exec_close_1 instead of unpushing the target. (exec_file_attach): Likewise. Adjust to not use to_sections. Add exec_bfd's sections to the current target sections table. Don't push the exec_ops target here. (resize_section_table): New. (add_target_sections): New. (remove_target_sections): Moved here. (section_table_xfer_memory): Adjust to implement the xfer_partial interface, and rename to... (section_table_xfer_memory_partial): ... this, replacing the current function of that same name. (exec_get_section_table): New. (exec_xfer_partial): New. (xfer_memory): Delete. (print_section_info): Replace the target_ops parameter by a target_section_table parameter. (exec_files_info, set_section_command, exec_set_section_address): Adjust to use the current sections table. (init_exec_ops): Do not register a deprecated_xfer_memory callback. Register to_xfer_partial and to_get_section_table callbacks. * infrun.c (handle_inferior_event): Update comments around solib_add. * rs6000-nat.c (xcoff_relocate_core): Adjust to use deprecated_core_resize_section_table. * exec.h (resize_section_table): Declare. (section_table_xfer_memory_partial): Add const char * argument. (remove_target_sections): Declare here. (add_target_sections): Declare. (print_section_info): Declare here. * gdbcore.h (deprecated_core_resize_section_table): Declare. --- gdb/corelow.c | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'gdb/corelow.c') diff --git a/gdb/corelow.c b/gdb/corelow.c index ffaf04c..947fe1f 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -67,6 +67,14 @@ static struct core_fns *core_vec = NULL; struct gdbarch *core_gdbarch = NULL; +/* Per-core data. Currently, only the section table. Note that these + target sections are *not* mapped in the current address spaces' set + of target sections --- those should come only from pure executable + or shared library bfds. The core bfd sections are an + implementation detail of the core target, just like ptrace is for + unix child targets. */ +static struct target_section_table *core_data; + static void core_files_info (struct target_ops *); static struct core_fns *sniff_core_bfd (bfd *); @@ -203,18 +211,16 @@ core_close (int quitting) comments in clear_solib in solib.c. */ clear_solib (); + xfree (core_data->sections); + xfree (core_data); + core_data = NULL; + name = bfd_get_filename (core_bfd); if (!bfd_close (core_bfd)) warning (_("cannot close \"%s\": %s"), name, bfd_errmsg (bfd_get_error ())); xfree (name); core_bfd = NULL; - if (core_ops.to_sections) - { - xfree (core_ops.to_sections); - core_ops.to_sections = NULL; - core_ops.to_sections_end = NULL; - } } core_vec = NULL; core_gdbarch = NULL; @@ -347,9 +353,11 @@ core_open (char *filename, int from_tty) validate_files (); + core_data = XZALLOC (struct target_section_table); + /* Find the data section */ - if (build_section_table (core_bfd, &core_ops.to_sections, - &core_ops.to_sections_end)) + if (build_section_table (core_bfd, + &core_data->sections, &core_data->sections_end)) error (_("\"%s\": Can't find sections: %s"), bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ())); @@ -434,6 +442,23 @@ core_detach (struct target_ops *ops, char *args, int from_tty) printf_filtered (_("No core file now.\n")); } +#ifdef DEPRECATED_IBM6000_TARGET + +/* Resize the core memory's section table, by NUM_ADDED. Returns a + pointer into the first new slot. This will not be necessary when + the rs6000 target is converted to use the standard solib + framework. */ + +struct target_section * +deprecated_core_resize_section_table (int num_added) +{ + int old_count; + + old_count = resize_section_table (core_data, num_added); + return core_data->sections + old_count; +} + +#endif /* Try to retrieve registers from a section in core_bfd, and supply them to core_vec->core_read_registers, as the register set numbered @@ -562,7 +587,7 @@ get_core_registers (struct target_ops *ops, static void core_files_info (struct target_ops *t) { - print_section_info (t, core_bfd); + print_section_info (core_data, core_bfd); } static LONGEST @@ -573,13 +598,11 @@ core_xfer_partial (struct target_ops *ops, enum target_object object, switch (object) { case TARGET_OBJECT_MEMORY: - if (readbuf) - return (*ops->deprecated_xfer_memory) (offset, readbuf, - len, 0/*read*/, NULL, ops); - if (writebuf) - return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf, - len, 1/*write*/, NULL, ops); - return -1; + return section_table_xfer_memory_partial (readbuf, writebuf, + offset, len, + core_data->sections, + core_data->sections_end, + NULL); case TARGET_OBJECT_AUXV: if (readbuf) @@ -738,7 +761,6 @@ init_core_ops (void) core_ops.to_detach = core_detach; core_ops.to_fetch_registers = get_core_registers; core_ops.to_xfer_partial = core_xfer_partial; - core_ops.deprecated_xfer_memory = xfer_memory; core_ops.to_files_info = core_files_info; core_ops.to_insert_breakpoint = ignore; core_ops.to_remove_breakpoint = ignore; -- cgit v1.1