Пример #1
0
static void
core_close (int quitting)
{
  char *name;

  if (core_bfd)
    {
      int pid = ptid_get_pid (inferior_ptid);
      inferior_ptid = null_ptid;    /* Avoid confusion from thread
				       stuff.  */
      if (pid != 0)
	exit_inferior_silent (pid);

      /* Clear out solib state while the bfd is still open.  See
         comments in clear_solib in solib.c.  */
      clear_solib ();

      if (core_data)
	{
	  xfree (core_data->sections);
	  xfree (core_data);
	  core_data = NULL;
	}

      name = bfd_get_filename (core_bfd);
      gdb_bfd_close_or_warn (core_bfd);
      xfree (name);
      core_bfd = NULL;
    }
  core_vec = NULL;
  core_gdbarch = NULL;
}
Пример #2
0
static void
exec_close_1 (int quitting)
{
  int need_symtab_cleanup = 0;
  struct vmap *vp, *nxt;

  using_exec_ops = 0;

  for (nxt = vmap; nxt != NULL;)
    {
      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)
	/* FIXME-leak: We should be freeing vp->name too, I think.  */
	gdb_bfd_close_or_warn (vp->bfd);

      xfree (vp);
    }

  vmap = NULL;

  {
    struct program_space *ss;
    struct cleanup *old_chain;

    old_chain = save_current_program_space ();
    ALL_PSPACES (ss)
    {
      set_current_program_space (ss);

      /* Delete all target sections.  */
      resize_section_table
	(current_target_sections,
	 -resize_section_table (current_target_sections, 0));

      exec_close ();
    }

    do_cleanups (old_chain);
  }
}
Пример #3
0
void
exec_close (void)
{
  if (exec_bfd)
    {
      bfd *abfd = exec_bfd;
      char *name = bfd_get_filename (abfd);

      gdb_bfd_close_or_warn (abfd);
      xfree (name);

      /* Removing target sections may close the exec_ops target.
	 Clear exec_bfd before doing so to prevent recursion.  */
      exec_bfd = NULL;
      exec_bfd_mtime = 0;

      remove_target_sections (abfd);
    }
}