Ejemplo n.º 1
0
std::string
core_target::pid_to_str (ptid_t ptid)
{
  struct inferior *inf;
  int pid;

  /* The preferred way is to have a gdbarch/OS specific
     implementation.  */
  if (m_core_gdbarch != nullptr
      && gdbarch_core_pid_to_str_p (m_core_gdbarch))
    return gdbarch_core_pid_to_str (m_core_gdbarch, ptid);

  /* Otherwise, if we don't have one, we'll just fallback to
     "process", with normal_pid_to_str.  */

  /* Try the LWPID field first.  */
  pid = ptid.lwp ();
  if (pid != 0)
    return normal_pid_to_str (ptid_t (pid));

  /* Otherwise, this isn't a "threaded" core -- use the PID field, but
     only if it isn't a fake PID.  */
  inf = find_inferior_ptid (ptid);
  if (inf != NULL && !inf->fake_pid_p)
    return normal_pid_to_str (ptid);

  /* No luck.  We simply don't have a valid PID to print.  */
  return "<main task>";
}
Ejemplo n.º 2
0
char *
sol2_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
{
  static char buf[80];
  struct inferior *inf;
  int pid;

  /* Check whether we're printing an LWP (gdb thread) or a
     process.  */
  pid = ptid_get_lwp (ptid);
  if (pid != 0)
    {
      /* A thread.  */
      xsnprintf (buf, sizeof buf, "LWP %ld", ptid_get_lwp (ptid));
      return buf;
    }

  /* GDB didn't use to put a NT_PSTATUS note in Solaris cores.  If
     that's missing, then we're dealing with a fake PID corelow.c made
     up.  */
  inf = find_inferior_ptid (ptid);
  if (inf == NULL || inf->fake_pid_p)
    {
      xsnprintf (buf, sizeof buf, "<core>");
      return buf;
    }

  /* Not fake; print as usual.  */
  return normal_pid_to_str (ptid);
}
Ejemplo n.º 3
0
struct gdbarch *
process_stratum_target::thread_architecture (ptid_t ptid)
{
  inferior *inf = find_inferior_ptid (ptid);
  gdb_assert (inf != NULL);
  return inf->gdbarch;
}
Ejemplo n.º 4
0
static void
mi_new_thread (struct thread_info *t)
{
  struct mi_interp *mi = top_level_interpreter_data ();
  struct inferior *inf = find_inferior_ptid (t->ptid);

  gdb_assert (inf);

  fprintf_unfiltered (mi->event_channel, 
		      "thread-created,id=\"%d\",group-id=\"i%d\"",
		      t->num, inf->num);
  gdb_flush (mi->event_channel);
}
Ejemplo n.º 5
0
struct address_space *
process_stratum_target::thread_address_space (ptid_t ptid)
{
  /* Fall-back to the "main" address space of the inferior.  */
  inferior *inf = find_inferior_ptid (ptid);

  if (inf == NULL || inf->aspace == NULL)
    internal_error (__FILE__, __LINE__,
		    _("Can't determine the current "
		      "address space of thread %s\n"),
		    target_pid_to_str (ptid).c_str ());

  return inf->aspace;
}
Ejemplo n.º 6
0
static void
mi_thread_exit (struct thread_info *t, int silent)
{
  struct mi_interp *mi;
  struct inferior *inf;
  struct cleanup *old_chain;

  if (silent)
    return;

  inf = find_inferior_ptid (t->ptid);

  mi = top_level_interpreter_data ();
  old_chain = make_cleanup_restore_target_terminal ();
  target_terminal_ours ();
  fprintf_unfiltered (mi->event_channel, 
		      "thread-exited,id=\"%d\",group-id=\"i%d\"",
		      t->num, inf->num);
  gdb_flush (mi->event_channel);

  do_cleanups (old_chain);
}
Ejemplo n.º 7
0
ps_err_e
ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj,
		   const char *name, psaddr_t *sym_addr)
{
  struct bound_minimal_symbol ms;
  struct cleanup *old_chain = save_current_program_space ();
  struct inferior *inf = find_inferior_ptid (ph->ptid);
  ps_err_e result;

  set_current_program_space (inf->pspace);

  /* FIXME: kettenis/2000-09-03: What should we do with OBJ?  */
  ms = lookup_minimal_symbol (name, NULL, NULL);
  if (ms.minsym == NULL)
    result = PS_NOSYM;
  else
    {
      *sym_addr = core_addr_to_ps_addr (BMSYMBOL_VALUE_ADDRESS (ms));
      result = PS_OK;
    }

  do_cleanups (old_chain);
  return result;
}