Ejemplo n.º 1
0
void next_handle_exception
(struct next_inferior_status *inferior, msg_header_t *message, struct target_waitstatus *status)
{
  next_exception_data* msg = (next_exception_data*) message;

  CHECK_FATAL (inferior != NULL);

  next_debug_exception (msg);

  if (msg->task != inferior->task) {
    inferior_debug ("ignoring exception forwarded from subprocess\n");
    next_exception_forwarded_reply (inferior, msg);
    return;
  }

  inferior->last_thread = msg->thread;

  if (inferior_handle_exceptions_flag) {

    next_inferior_suspend_mach (inferior);

    next_exception_internal_reply (inferior, msg);

    status->kind = TARGET_WAITKIND_STOPPED;

    switch (msg->exception) {
    case EXC_BAD_ACCESS:
      status->value.sig = TARGET_EXC_BAD_ACCESS;
      break;
    case EXC_BAD_INSTRUCTION:
      status->value.sig = TARGET_EXC_BAD_INSTRUCTION;
      break;
    case EXC_ARITHMETIC:
      status->value.sig = TARGET_EXC_ARITHMETIC;
      break;
    case EXC_EMULATION:
      status->value.sig = TARGET_EXC_EMULATION;
      break;
    case EXC_SOFTWARE:
      status->value.sig = TARGET_EXC_SOFTWARE;
      break;
    case EXC_BREAKPOINT:
      status->value.sig = TARGET_EXC_BREAKPOINT;
      status->value.sig = TARGET_SIGNAL_TRAP;
      break;
    default:
      status->value.sig = TARGET_SIGNAL_UNKNOWN;
      break;
    }

  } else {
    next_exception_forwarded_reply (inferior, msg);
  }
}
void next_inferior_suspend_ptrace (next_inferior_status *s)
{
  struct target_waitstatus status;

  CHECK (s != NULL);
  CHECK (s->attached_in_ptrace);
  CHECK (next_inferior_valid (s));
  next_inferior_check_stopped (s);
  CHECK (! s->stopped_in_ptrace);

  next_inferior_suspend_mach (s);
  kill (s->pid, SIGSTOP);
  next_inferior_resume_mach (s, -1);

  next_wait (s, &status, NULL);
  CHECK (status.kind == TARGET_WAITKIND_STOPPED);
  CHECK (status.value.sig == TARGET_SIGNAL_STOP);
}
void next_inferior_resume_ptrace (next_inferior_status *s, int nsignal, int val)
{
  CHECK (s != NULL);
  CHECK ((val == PTRACE_DETACH) || (val == PTRACE_CONT));

  CHECK (s->attached_in_ptrace);
  CHECK (next_inferior_valid (s));
  next_inferior_check_stopped (s);
  CHECK (s->stopped_in_ptrace);

  next_inferior_suspend_mach (s);

  if (call_ptrace(val, s->pid, (caddr_t)1, nsignal) != 0) {
    error("Error calling ptrace (%d, %d, %d, %d): %s\n",
	  val, s->pid, 1, nsignal, xstrerror(errno));
  }

  s->stopped_in_ptrace = 0;
  if (val == PTRACE_DETACH) {
    s->attached_in_ptrace = 0;
  }
}