From d367c7b4479c01f8d8b9a71776b1c177433488a4 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Thu, 8 Oct 1998 23:04:53 +0000 Subject: [PATCH] * main.c (main): Remove calls to {pre,post}_add_symbol_hooks. There should be sufficient information/hooks now to eliminate this hack. * exec.c (file_command): Add a new hook here to inform ui's when the exec file has changed. Adding it here allows the ui to be informed after symbol reading. * gdbcore.h: Add declaration of file_changed_hook. --- gdb/ChangeLog | 12 +++++++ gdb/exec.c | 91 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 85 insertions(+), 18 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7788cdb088..1e051551ba 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +1998-10-08 Keith Seitz + + * main.c (main): Remove calls to {pre,post}_add_symbol_hooks. + There should be sufficient information/hooks now to eliminate + this hack. + + * exec.c (file_command): Add a new hook here to inform ui's + when the exec file has changed. Adding it here allows the + ui to be informed after symbol reading. + + * gdbcore.h: Add declaration of file_changed_hook. + Thu Oct 8 08:40:42 1998 Mark Alexander * rs6000-tdep.c (get_saved_register): Define only if diff --git a/gdb/exec.c b/gdb/exec.c index fa64163ed7..c39e118d30 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -1,5 +1,6 @@ /* Work with executable files, for GDB. - Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1997 + Free Software Foundation, Inc. This file is part of GDB. @@ -30,7 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #endif -#include #include #include "gdb_string.h" @@ -46,6 +46,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ struct vmap *map_vmap PARAMS ((bfd *, bfd *)); +void (*file_changed_hook) PARAMS ((char *)); + /* Prototypes for local functions */ static void add_to_section_table PARAMS ((bfd *, sec_ptr, PTR)); @@ -187,7 +189,7 @@ exec_file_command (args, from_tty) scratch_chan = openp (getenv ("PATH"), 1, filename, write_files? O_RDWR|O_BINARY: O_RDONLY|O_BINARY, 0, &scratch_pathname); -#if defined(__GO32__) || defined(__WIN32__) +#if defined(__GO32__) || defined(_WIN32) if (scratch_chan < 0) { char *exename = alloca (strlen (filename) + 5); @@ -277,6 +279,7 @@ exec_file_command (args, from_tty) validate_files (); set_endian_from_file (exec_bfd); + set_architecture_from_file (exec_bfd); push_target (&exec_ops); @@ -285,7 +288,7 @@ exec_file_command (args, from_tty) (*exec_file_display_hook) (filename); } else if (from_tty) - printf_unfiltered ("No exec file now.\n"); + printf_unfiltered ("No executable file now.\n"); } /* Set both the exec file and the symbol file, in one command. @@ -301,6 +304,8 @@ file_command (arg, from_tty) the exec file, but that's rough. */ exec_file_command (arg, from_tty); symbol_file_command (arg, from_tty); + if (file_changed_hook) + file_changed_hook (arg); } @@ -367,20 +372,16 @@ bfdsec_to_vmap(abfd, sect, arg3) if (STREQ (bfd_section_name (abfd, sect), ".text")) { - vp->tstart = 0; + vp->tstart = bfd_section_vma (abfd, sect); vp->tend = vp->tstart + bfd_section_size (abfd, sect); - - /* When it comes to this adjustment value, in contrast to our previous - belief shared objects should behave the same as the main load segment. - This is the offset from the beginning of text section to the first - real instruction. */ - - vp->tadj = sect->filepos - bfd_section_vma (abfd, sect); + vp->tvma = bfd_section_vma (abfd, sect); + vp->toffs = sect->filepos; } else if (STREQ (bfd_section_name (abfd, sect), ".data")) { - vp->dstart = 0; + vp->dstart = bfd_section_vma (abfd, sect); vp->dend = vp->dstart + bfd_section_size (abfd, sect); + vp->dvma = bfd_section_vma (abfd, sect); } /* Silently ignore other types of sections. (FIXME?) */ } @@ -445,25 +446,79 @@ xfer_memory (memaddr, myaddr, len, write, target) struct section_table *p; CORE_ADDR nextsectaddr, memend; boolean (*xfer_fn) PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); + asection *section; if (len <= 0) abort(); + if (overlay_debugging) + { + section = find_pc_overlay (memaddr); + if (pc_in_unmapped_range (memaddr, section)) + memaddr = overlay_mapped_address (memaddr, section); + } + memend = memaddr + len; xfer_fn = write ? bfd_set_section_contents : bfd_get_section_contents; nextsectaddr = memend; +#if 0 /* Stu's implementation */ +/* If a section has been specified, try to use it. Note that we cannot use the + specified section directly. This is because it usually comes from the + symbol file, which may be different from the exec or core file. Instead, we + have to lookup the specified section by name in the bfd associated with + to_sections. */ + + if (target_memory_bfd_section) + { + asection *s; + bfd *abfd; + asection *target_section; + bfd *target_bfd; + + s = target_memory_bfd_section; + abfd = s->owner; + + target_bfd = target->to_sections->bfd; + target_section = bfd_get_section_by_name (target_bfd, bfd_section_name (abfd, s)); + + if (target_section) + { + bfd_vma sec_addr; + bfd_size_type sec_size; + + sec_addr = bfd_section_vma (target_bfd, target_section); + sec_size = target_section->_raw_size; + + /* Make sure the requested memory starts inside the section. */ + + if (memaddr >= sec_addr + && memaddr < sec_addr + sec_size) + { + /* Cut back length in case request overflows the end of the section. */ + len = min (len, sec_addr + sec_size - memaddr); + + res = xfer_fn (target_bfd, target_section, myaddr, memaddr - sec_addr, len); + + return res ? len : 0; + } + } + } +#endif /* 0, Stu's implementation */ for (p = target->to_sections; p < target->to_sections_end; p++) { - if (p->addr <= memaddr) - if (p->endaddr >= memend) + if (overlay_debugging && section && p->the_bfd_section && + strcmp (section->name, p->the_bfd_section->name) != 0) + continue; /* not the section we need */ + if (memaddr >= p->addr) + if (memend <= p->endaddr) { /* Entire transfer is within this section. */ res = xfer_fn (p->bfd, p->the_bfd_section, myaddr, memaddr - p->addr, len); return (res != 0) ? len : 0; } - else if (p->endaddr <= memaddr) + else if (memaddr >= p->endaddr) { /* This section ends before the transfer starts. */ continue; @@ -476,8 +531,8 @@ xfer_memory (memaddr, myaddr, len, write, target) memaddr - p->addr, len); return (res != 0) ? len : 0; } - else if (p->addr < nextsectaddr) - nextsectaddr = p->addr; + else + nextsectaddr = min (nextsectaddr, p->addr); } if (nextsectaddr >= memend)