/* GDB routines for manipulating objfiles.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by Cygnus Support, using pieces from other GDB modules.
(*objfile->sf->sym_finish) (objfile);
}
- /* We always close the bfd. */
+ /* Discard any data modules have associated with the objfile. */
+ objfile_free_data (objfile);
+
+ /* We always close the bfd, unless the OBJF_KEEPBFD flag is set. */
- if (objfile->obfd != NULL)
+ if (objfile->obfd != NULL && !(objfile->flags & OBJF_KEEPBFD))
{
char *name = bfd_get_filename (objfile->obfd);
if (!bfd_close (objfile->obfd))
/* The last thing we do is free the objfile struct itself. */
- objfile_free_data (objfile);
if (objfile->name != NULL)
{
xfree (objfile->name);
}
/* Relocate breakpoints as necessary, after things are relocated. */
- breakpoint_re_set ();
+ breakpoint_re_set_objfile (objfile);
}
\f
/* Many places in gdb want to test just to see if we have any partial
return 0;
}
-/* Returns a section whose range includes PC and SECTION, or NULL if
- none found. Note the distinction between the return type, struct
- obj_section (which is defined in gdb), and the input type "struct
- bfd_section" (which is a bfd-defined data type). The obj_section
- contains a pointer to the "struct bfd_section". */
+/* Returns a section whose range includes PC or NULL if none found. */
struct obj_section *
-find_pc_sect_section (CORE_ADDR pc, struct bfd_section *section)
+find_pc_section (CORE_ADDR pc)
{
struct obj_section *s;
struct objfile *objfile;
- ALL_OBJSECTIONS (objfile, s)
- if ((section == 0 || section == s->the_bfd_section)
- && obj_section_addr (s) <= pc && pc < obj_section_endaddr (s))
- return (s);
+ /* Check for mapped overlay section first. */
+ s = find_pc_mapped_section (pc);
+ if (s)
+ return s;
- return (NULL);
-}
-
-/* Returns a section whose range includes PC or NULL if none found.
- Backward compatibility, no section. */
+ ALL_OBJSECTIONS (objfile, s)
+ if (obj_section_addr (s) <= pc && pc < obj_section_endaddr (s))
+ return s;
-struct obj_section *
-find_pc_section (CORE_ADDR pc)
-{
- return find_pc_sect_section (pc, find_pc_mapped_section (pc));
+ return NULL;
}