Exemplo n.º 1
0
static void
exec_close_1 (void)
{
  using_exec_ops = 0;

  {
    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);
  }
}
Exemplo n.º 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);
  }
}
Exemplo n.º 3
0
void
add_target_sections (void *owner,
		     struct target_section *sections,
		     struct target_section *sections_end)
{
  int count;
  struct target_section_table *table = current_target_sections;

  count = sections_end - sections;

  if (count > 0)
    {
      int space = resize_section_table (table, count);
      int i;

      for (i = 0; i < count; ++i)
	{
	  table->sections[space + i] = sections[i];
	  table->sections[space + i].owner = owner;
	}

      /* If these are the first file sections we can provide memory
	 from, push the file_stratum target.  */
      if (!using_exec_ops)
	{
	  using_exec_ops = 1;
	  push_target (&exec_ops);
	}
    }
}
Exemplo n.º 4
0
void
add_target_sections (struct target_section *sections,
		     struct target_section *sections_end)
{
  int count;
  struct target_section_table *table = current_target_sections;

  count = sections_end - sections;

  if (count > 0)
    {
      int space = resize_section_table (table, count);

      memcpy (table->sections + space,
	      sections, count * sizeof (sections[0]));

      /* If these are the first file sections we can provide memory
	 from, push the file_stratum target.  */
      if (!using_exec_ops)
	{
	  using_exec_ops = 1;
	  push_target (&exec_ops);
	}
    }
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
Arquivo: exec.c Projeto: asdlei00/gdb
static void
exec_close_1 (int quitting)
{
    struct vmap *vp, *nxt;

    using_exec_ops = 0;

    for (nxt = vmap; nxt != NULL;)
    {
        vp = nxt;
        nxt = vp->nxt;

        if (vp->objfile)
            free_objfile (vp->objfile);

        gdb_bfd_unref (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);
    }
}
Exemplo n.º 7
0
void
add_target_sections_of_objfile (struct objfile *objfile)
{
  struct target_section_table *table = current_target_sections;
  struct obj_section *osect;
  int space;
  unsigned count = 0;
  struct target_section *ts;

  if (objfile == NULL)
    return;

  /* Compute the number of sections to add.  */
  ALL_OBJFILE_OSECTIONS (objfile, osect)
    {
      if (bfd_get_section_size (osect->the_bfd_section) == 0)
	continue;
      count++;
    }

  if (count == 0)
    return;

  space = resize_section_table (table, count);

  ts = table->sections + space;

  ALL_OBJFILE_OSECTIONS (objfile, osect)
    {
      if (bfd_get_section_size (osect->the_bfd_section) == 0)
	continue;

      gdb_assert (ts < table->sections + space + count);

      ts->addr = obj_section_addr (osect);
      ts->endaddr = obj_section_endaddr (osect);
      ts->the_bfd_section = osect->the_bfd_section;
      ts->owner = (void *) objfile;

      ts++;
    }
}
Exemplo n.º 8
0
void
remove_target_sections (void *owner)
{
  struct target_section *src, *dest;
  struct target_section_table *table = current_target_sections;

  gdb_assert (owner != NULL);

  dest = table->sections;
  for (src = table->sections; src < table->sections_end; src++)
    if (src->owner != owner)
      {
	/* Keep this section.  */
	if (dest < src)
	  *dest = *src;
	dest++;
      }

  /* If we've dropped any sections, resize the section table.  */
  if (dest < src)
    {
      int old_count;

      old_count = resize_section_table (table, dest - src);

      /* If we don't have any more sections to read memory from,
	 remove the file_stratum target from the stack.  */
      if (old_count + (dest - src) == 0)
	{
	  struct program_space *pspace;

	  ALL_PSPACES (pspace)
	    if (pspace->target_sections.sections
		!= pspace->target_sections.sections_end)
	      return;

	  unpush_target (&exec_ops);
	}
    }