Ejemplo n.º 1
0
// Parse a return statement.
//
//    return-stmt -> 'return' expr ';'
Stmt*
Parser::return_stmt()
{
  term_ = semicolon_tok;
  require(return_kw);
  Expr* e = expr();
  match(semicolon_tok);
  return on_return(e);
}
Ejemplo n.º 2
0
bool
trace_syscall(pid_t pid, bool until_sync)
{
  PfnOnEntry on_entry = on_entry_print;
  PfnOnReturn on_return = on_return_print;
  if (until_sync)
  {
    on_entry = on_entry_sync;
    on_return = on_return_nothing;
  }
  for(;;)
  {
    int sysc_nr;
    int sysc_rc;
    bool is_errno;

    /* trace until we reach next syscall */
    if (-1 == msg_ptrace(pid, PTRACE_SYSCALL, 0, 0))
      return false;
    if (!msg_wait(VOODOO_SIGTRAP, pid))
      return false;
    if (!msg_get_syscall(pid, &sysc_nr))
      return false;
    if (!on_entry(sysc_nr))
      break;

    /* get return value of syscall */
    if (-1 == msg_ptrace(pid, PTRACE_SYSCALL, 0, 0))
      return false;
    if (!msg_wait(VOODOO_SIGTRAP, pid))
      return false;
    is_errno = msg_get_errno(pid, &sysc_rc);
    if (!on_return(sysc_rc, is_errno))
      break;
  }
  return true;
}