X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fexec.c;h=f550194b18ff012bb7a9f6812362b9739ae66f8c;hb=460014f572f44fe3e8deb146cb92fd312c4c3339;hp=540c27132b8b398e61699097f1275e8b9ecf6498;hpb=a4453b7e0b9b84dd18c844ef43fbb9f6e2e75433;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/exec.c b/gdb/exec.c index 540c27132b..f550194b18 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -1,6 +1,6 @@ /* Work with executable files, for GDB. - Copyright (C) 1988-2003, 2007-2012 Free Software Foundation, Inc. + Copyright (C) 1988-2013 Free Software Foundation, Inc. This file is part of GDB. @@ -107,7 +107,7 @@ exec_close (void) exec_bfd = NULL; exec_bfd_mtime = 0; - remove_target_sections (abfd); + remove_target_sections (&exec_bfd, abfd); } } @@ -115,9 +115,8 @@ exec_close (void) sections and closes all executable bfds from all program spaces. */ static void -exec_close_1 (int quitting) +exec_close_1 (void) { - int need_symtab_cleanup = 0; struct vmap *vp, *nxt; using_exec_ops = 0; @@ -127,16 +126,10 @@ exec_close_1 (int quitting) vp = nxt; nxt = vp->nxt; - /* if there is an objfile associated with this bfd, - free_objfile() will do proper cleanup of objfile *and* bfd. */ - if (vp->objfile) - { - free_objfile (vp->objfile); - need_symtab_cleanup = 1; - } - else if (vp->bfd != exec_bfd) - gdb_bfd_unref (vp->bfd); + free_objfile (vp->objfile); + + gdb_bfd_unref (vp->bfd); xfree (vp); } @@ -228,14 +221,16 @@ exec_file_attach (char *filename, int from_tty) &scratch_pathname); } #endif + if (scratch_chan < 0) + perror_with_name (filename); cleanups = make_cleanup (xfree, scratch_pathname); - if (scratch_chan < 0) - perror_with_name (filename); - exec_bfd = gdb_bfd_ref (bfd_fopen (scratch_pathname, gnutarget, - write_files ? FOPEN_RUB : FOPEN_RB, - scratch_chan)); + if (write_files) + exec_bfd = gdb_bfd_fopen (scratch_pathname, gnutarget, + FOPEN_RUB, scratch_chan); + else + exec_bfd = gdb_bfd_open (scratch_pathname, gnutarget, scratch_chan); if (!exec_bfd) { @@ -253,8 +248,6 @@ exec_file_attach (char *filename, int from_tty) gdb_bfd_errmsg (bfd_get_error (), matching)); } - gdb_bfd_stash_filename (exec_bfd); - /* FIXME - This should only be run for RS6000, but the ifdef is a poor way to accomplish. */ #ifdef DEPRECATED_IBM6000_TARGET @@ -289,7 +282,7 @@ exec_file_attach (char *filename, int from_tty) /* Add the executable's sections to the current address spaces' list of sections. This possibly pushes the exec_ops target. */ - add_target_sections (sections, sections_end); + add_target_sections (&exec_bfd, sections, sections_end); xfree (sections); /* Tell display code (if any) about the changed file name. */ @@ -383,6 +376,7 @@ add_to_section_table (bfd *abfd, struct bfd_section *asect, if (!(aflag & SEC_ALLOC)) return; + (*table_pp)->key = NULL; (*table_pp)->bfd = abfd; (*table_pp)->the_bfd_section = asect; (*table_pp)->addr = bfd_section_vma (abfd, asect); @@ -393,11 +387,9 @@ add_to_section_table (bfd *abfd, struct bfd_section *asect, int resize_section_table (struct target_section_table *table, int num_added) { - struct target_section *old_value; int old_count; int new_count; - old_value = table->sections; old_count = table->sections_end - table->sections; new_count = num_added + old_count; @@ -443,7 +435,8 @@ build_section_table (struct bfd *some_bfd, struct target_section **start, current set of target sections. */ void -add_target_sections (struct target_section *sections, +add_target_sections (void *key, + struct target_section *sections, struct target_section *sections_end) { int count; @@ -454,9 +447,13 @@ add_target_sections (struct target_section *sections, if (count > 0) { int space = resize_section_table (table, count); + int i; - memcpy (table->sections + space, - sections, count * sizeof (sections[0])); + for (i = 0; i < count; ++i) + { + table->sections[space + i] = sections[i]; + table->sections[space + i].key = key; + } /* If these are the first file sections we can provide memory from, push the file_stratum target. */ @@ -471,14 +468,14 @@ add_target_sections (struct target_section *sections, /* Remove all target sections taken from ABFD. */ void -remove_target_sections (bfd *abfd) +remove_target_sections (void *key, bfd *abfd) { struct target_section *src, *dest; struct target_section_table *table = current_target_sections; dest = table->sections; for (src = table->sections; src < table->sections_end; src++) - if (src->bfd != abfd) + if (src->key != key || src->bfd != abfd) { /* Keep this section. */ if (dest < src) @@ -550,6 +547,7 @@ map_vmap (bfd *abfd, bfd *arch) memset ((char *) vp, '\0', sizeof (*vp)); vp->nxt = 0; vp->bfd = abfd; + gdb_bfd_ref (abfd); vp->name = bfd_get_filename (arch ? arch : abfd); vp->member = arch ? bfd_get_filename (abfd) : ""; @@ -763,7 +761,7 @@ exec_files_info (struct target_ops *t) if (vmap) { - int addr_size = gdbarch_addr_bit (target_gdbarch) / 8; + int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8; struct vmap *vp; printf_unfiltered (_("\tMapping info for file `%s'.\n"), vmap->name);