Exemple #1
0
/* Return a borrowed reference to the Python object of type Inferior
   representing INFERIOR.  If the object has already been created,
   return it,  otherwise, create it.  Return NULL on failure.  */
PyObject *
inferior_to_inferior_object (struct inferior *inferior)
{
    inferior_object *inf_obj;

    inf_obj = inferior_data (inferior, infpy_inf_data_key);
    if (!inf_obj)
    {
        struct cleanup *cleanup;
        cleanup = ensure_python_env (python_gdbarch, python_language);

        inf_obj = PyObject_New (inferior_object, &inferior_object_type);
        if (!inf_obj)
        {
            do_cleanups (cleanup);
            return NULL;
        }

        inf_obj->inferior = inferior;
        inf_obj->threads = NULL;
        inf_obj->nthreads = 0;

        set_inferior_data (inferior, infpy_inf_data_key, inf_obj);

        do_cleanups (cleanup);
    }

    return (PyObject *) inf_obj;
}
static struct terminal_info *
get_inflow_inferior_data (struct inferior *inf)
{
  struct terminal_info *info;

  info = inferior_data (inf, inflow_inferior_data);
  if (info == NULL)
    {
      info = XZALLOC (struct terminal_info);
      set_inferior_data (inf, inflow_inferior_data, info);
    }
Exemple #3
0
static struct solib_aix_inferior_data *
get_solib_aix_inferior_data (struct inferior *inf)
{
  struct solib_aix_inferior_data *data;

  data = inferior_data (inf, solib_aix_inferior_data_handle);
  if (data == NULL)
    {
      data = XZALLOC (struct solib_aix_inferior_data);
      set_inferior_data (inf, solib_aix_inferior_data_handle, data);
    }
Exemple #4
0
static struct solib_aix_inferior_data *
get_solib_aix_inferior_data (struct inferior *inf)
{
  struct solib_aix_inferior_data *data;

  data = ((struct solib_aix_inferior_data *)
	  inferior_data (inf, solib_aix_inferior_data_handle));
  if (data == NULL)
    {
      data = XCNEW (struct solib_aix_inferior_data);
      set_inferior_data (inf, solib_aix_inferior_data_handle, data);
    }
Exemple #5
0
static struct sim_inferior_data *
get_sim_inferior_data (struct inferior *inf, int sim_instance_needed)
{
  SIM_DESC sim_desc = NULL;
  struct sim_inferior_data *sim_data
    = (struct sim_inferior_data *) inferior_data (inf, sim_inferior_data_key);

  /* Try to allocate a new sim instance, if needed.  We do this ahead of
     a potential allocation of a sim_inferior_data struct in order to
     avoid needlessly allocating that struct in the event that the sim
     instance allocation fails.  */
  if (sim_instance_needed == SIM_INSTANCE_NEEDED
      && (sim_data == NULL || sim_data->gdbsim_desc == NULL))
    {
      struct inferior *idup;
      sim_desc = sim_open (SIM_OPEN_DEBUG, &gdb_callback, exec_bfd, sim_argv);
      if (sim_desc == NULL)
	error (_("Unable to create simulator instance for inferior %d."),
	       inf->num);

      idup = iterate_over_inferiors (check_for_duplicate_sim_descriptor,
				     sim_desc);
      if (idup != NULL)
	{
	  /* We don't close the descriptor due to the fact that it's
	     shared with some other inferior.  If we were to close it,
	     that might needlessly muck up the other inferior.  Of
	     course, it's possible that the damage has already been
	     done...  Note that it *will* ultimately be closed during
	     cleanup of the other inferior.  */
	  sim_desc = NULL;
	  error (
 _("Inferior %d and inferior %d would have identical simulator state.\n"
   "(This simulator does not support the running of more than one inferior.)"),
		 inf->num, idup->num);
	}
    }

  if (sim_data == NULL)
    {
      sim_data = XCNEW(struct sim_inferior_data);
      set_inferior_data (inf, sim_inferior_data_key, sim_data);

      /* Allocate a ptid for this inferior.  */
      sim_data->remote_sim_ptid = ptid_build (next_pid, 0, next_pid);
      next_pid++;

      /* Initialize the other instance variables.  */
      sim_data->program_loaded = 0;
      sim_data->gdbsim_desc = sim_desc;
      sim_data->resume_siggnal = GDB_SIGNAL_0;
      sim_data->resume_step = 0;
    }
Exemple #6
0
static void
auxv_inferior_data_cleanup (struct inferior *inf, void *arg)
{
  struct auxv_info *info;

  info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data);
  if (info != NULL)
    {
      delete info;
      set_inferior_data (inf, auxv_inferior_data, NULL);
    }
}
static struct catch_syscall_inferior_data*
get_catch_syscall_inferior_data (struct inferior *inf)
{
  struct catch_syscall_inferior_data *inf_data;

  inf_data = ((struct catch_syscall_inferior_data *)
	      inferior_data (inf, catch_syscall_inferior_data));
  if (inf_data == NULL)
    {
      inf_data = XCNEW (struct catch_syscall_inferior_data);
      set_inferior_data (inf, catch_syscall_inferior_data, inf_data);
    }
Exemple #8
0
static void
auxv_inferior_data_cleanup (struct inferior *inf, void *arg)
{
  struct auxv_info *info;

  info = inferior_data (inf, auxv_inferior_data);
  if (info != NULL)
    {
      xfree (info->data);
      xfree (info);
      set_inferior_data (inf, auxv_inferior_data, NULL);
    }
}
static htab_t
frscm_inferior_frame_map (struct inferior *inferior)
{
    htab_t htab = inferior_data (inferior, frscm_inferior_data_key);

    if (htab == NULL)
    {
        htab = gdbscm_create_eqable_gsmob_ptr_map (frscm_hash_frame_smob,
                frscm_eq_frame_smob);
        set_inferior_data (inferior, frscm_inferior_data_key, htab);
    }

    return htab;
}
Exemple #10
0
static struct auxv_info *
get_auxv_inferior_data (struct target_ops *ops)
{
  struct auxv_info *info;
  struct inferior *inf = current_inferior ();

  info = inferior_data (inf, auxv_inferior_data);
  if (info == NULL)
    {
      info = XZALLOC (struct auxv_info);
      info->length = target_read_alloc (ops, TARGET_OBJECT_AUXV,
					NULL, &info->data);
      set_inferior_data (inf, auxv_inferior_data, info);
    }
Exemple #11
0
static struct auxv_info *
get_auxv_inferior_data (struct target_ops *ops)
{
  struct auxv_info *info;
  struct inferior *inf = current_inferior ();

  info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data);
  if (info == NULL)
    {
      info = new auxv_info;
      info->data = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL);
      set_inferior_data (inf, auxv_inferior_data, info);
    }

  return info;
}
Exemple #12
0
/* Return a reference to the Python object of type Inferior
   representing INFERIOR.  If the object has already been created,
   return it and increment the reference count,  otherwise, create it.
   Return NULL on failure.  */
PyObject *
inferior_to_inferior_object (struct inferior *inferior)
{
  inferior_object *inf_obj;

  inf_obj = inferior_data (inferior, infpy_inf_data_key);
  if (!inf_obj)
    {
      inf_obj = PyObject_New (inferior_object, &inferior_object_type);
      if (!inf_obj)
	  return NULL;

      inf_obj->inferior = inferior;
      inf_obj->threads = NULL;
      inf_obj->nthreads = 0;

      set_inferior_data (inferior, infpy_inf_data_key, inf_obj);

    }
  else
    Py_INCREF ((PyObject *)inf_obj);

  return (PyObject *) inf_obj;
}