Exemplo n.º 1
0
ErrorCode PTrace::step(ProcessThreadId const &ptid, ProcessInfo const &pinfo,
                       int signal, Address const &address) {
  pid_t pid;

  if (!ptid.valid())
    return kErrorInvalidArgument;

  if (!(ptid.tid <= kAnyThreadId)) {
    pid = ptid.tid;
  } else {
    pid = ptid.pid;
  }

  //
  // Continuation from address?
  //
  if (address.valid()) {
    Architecture::CPUState state;
    ErrorCode error = readCPUState(ptid, pinfo, state);
    if (error != kSuccess)
      return error;

    state.setPC(address);

    error = writeCPUState(ptid, pinfo, state);
    if (error != kSuccess)
      return error;
  }

  // (caddr_t)1 indicate that execution is to pick up where it left off.
  if (wrapPtrace(PT_STEP, pid, (caddr_t)1, signal) < 0)
    return Platform::TranslateError();

  return kSuccess;
}
Exemplo n.º 2
0
Arquivo: PTrace.cpp Projeto: sas/ds2
ErrorCode PTrace::prepareAddressForResume(ProcessThreadId const &ptid,
                                          ProcessInfo const &pinfo,
                                          Address const &address) {
  if (address.valid()) {
    Architecture::CPUState state;
    ErrorCode error = readCPUState(ptid, pinfo, state);
    if (error != kSuccess) {
      return error;
    }

    state.setPC(address);

    error = writeCPUState(ptid, pinfo, state);
    if (error != kSuccess) {
      return error;
    }
  }

  return kSuccess;
}