Exemple #1
0
static void
child_create_inferior (char *exec_file, char *allargs, char **env,
		       int from_tty)
{
  fork_inferior (exec_file, allargs, env, ptrace_me, ptrace_him, NULL, NULL);

  /* We are at the first instruction we care about.  */
  observer_notify_inferior_created (&current_target, from_tty);
  /* Pedal to the metal... */
  proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
}
static void
inf_ptrace_attach (char *args, int from_tty)
{
  char *exec_file;
  pid_t pid;
  char *dummy;

  if (!args)
    error_no_arg (_("process-id to attach"));

  dummy = args;
  pid = strtol (args, &dummy, 0);
  /* Some targets don't set errno on errors, grrr!  */
  if (pid == 0 && args == dummy)
    error (_("Illegal process-id: %s."), args);

  if (pid == getpid ())		/* Trying to m********e?  */
    error (_("I refuse to debug myself!"));

  if (from_tty)
    {
      exec_file = get_exec_file (0);

      if (exec_file)
	printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
			   target_pid_to_str (pid_to_ptid (pid)));
      else
	printf_unfiltered (_("Attaching to %s\n"),
			   target_pid_to_str (pid_to_ptid (pid)));

      gdb_flush (gdb_stdout);
    }

#ifdef PT_ATTACH
  errno = 0;
  ptrace (PT_ATTACH, pid, (PTRACE_TYPE_ARG3)0, 0);
  if (errno != 0)
    perror_with_name (("ptrace"));
  attach_flag = 1;
#else
  error (_("This system does not support attaching to a process"));
#endif

  inferior_ptid = pid_to_ptid (pid);
  push_target (ptrace_ops_hack);

  /* Do this first, before anything has had a chance to query the
     inferior's symbol table or similar.  */
  observer_notify_inferior_created (&current_target, from_tty);
}
Exemple #3
0
static void
haiku_child_create_inferior (char *exec_file, char *allargs, char **env,
	int from_tty)
{
	TRACE(("haiku_child_create_inferior(`%s', `%s', %p, %d)\n", exec_file,
		allargs, env, from_tty));

	fork_inferior (exec_file, allargs, env, wait_for_debugger,
		haiku_init_debug_create_inferior, NULL, NULL);


observer_notify_inferior_created (&current_target, from_tty);
proceed ((CORE_ADDR) - 1, TARGET_SIGNAL_0, 0);


	// TODO: Anything more to do here?
}
Exemple #4
0
static void
child_attach (char *args, int from_tty)
{
  char *exec_file;
  int pid;
  char *dummy;

  if (!args)
    error_no_arg (_("process-id to attach"));

  dummy = args;
  pid = strtol (args, &dummy, 0);
  /* Some targets don't set errno on errors, grrr! */
  if ((pid == 0) && (args == dummy))
      error (_("Illegal process-id: %s."), args);
  
  if (pid == getpid ())	/* Trying to m********e? */
    error (_("I refuse to debug myself!"));
  
  if (from_tty)
    {
      exec_file = (char *) get_exec_file (0);
      
      if (exec_file)
	printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
			   target_pid_to_str (pid_to_ptid (pid)));
      else
	printf_unfiltered (_("Attaching to %s\n"),
			   target_pid_to_str (pid_to_ptid (pid)));
      
      gdb_flush (gdb_stdout);
    }

  attach (pid);
  
  inferior_ptid = pid_to_ptid (pid);
  push_target (&deprecated_child_ops);

  /* Do this first, before anything has had a chance to query the
     inferior's symbol table or similar.  */
  observer_notify_inferior_created (&current_target, from_tty);
}