Esempio n. 1
0
std::string
SyntaxTree::TreeNode::print(short depth, const std::string &search_string, bool &found)
{
  std::string doc;
  std::string long_name(getLongName());
  std::string name(_syntax_tree.isLongNames() ? long_name : _name);
  std::string out;

  if (depth < 0)
  {
    for (const auto & c_it : _children)
    {
      bool local_found = false;
      std::string local_out (c_it.second->print(depth+1, search_string, local_found));
      found |= local_found;  // Update the current frame's found variable
      if (local_found)
        out += local_out;
    }
    return out;
  }

  // GlobalParamsAction is special - we need to just always print it out
  // if (_name == "GlobalParamsAction")
  //   found = true;

  std::string indent((depth+1)*2, ' ');

  std::multimap<std::string, InputParameters *>::const_iterator it = _moose_object_params.begin();
  do
  {
    bool local_found = false;
    std::string local_out;

    // Compare the block name, if it's matched we are going to pass an empty search string
    // which means match ALL parameters
    std::string local_search_string;
    if (wildCardMatch(name, search_string))
      found = true;
    else
      local_search_string = search_string;

    if (it != _moose_object_params.end())
      doc = it->second->getClassDescription();
    else
      doc = "";

    local_out += _syntax_tree.printBlockOpen(name, depth, doc);

    for (const auto & a_it : _action_params)
      if (a_it.first != "EmptyAction")
      {
        local_out += _syntax_tree.printParams(name, long_name, *(a_it.second), depth, local_search_string, local_found);
        found |= local_found;   // Update the current frame's found variable
        //DEBUG
        // Moose::out << "\n" << indent << "(" << ait->first << ")";
        //DEBUG
      }

    if (it != _moose_object_params.end())
    {
      local_out += _syntax_tree.printParams(name, long_name, *it->second, depth, local_search_string, local_found);
      found |= local_found;
      //DEBUG
      // Moose::out << "\n" << indent << "{" << it->first << "}";
      //DEBUG
    }

    local_out += _syntax_tree.preTraverse(depth);

    for (const auto & c_it : _children)
    {
      bool child_found = false;
      std::string child_out (c_it.second->print(depth+1, local_search_string, child_found));
      found |= child_found;   // Update the current frame's found variable

      if (child_found)
        local_out += child_out;
    }

    local_out += _syntax_tree.printBlockClose(name, depth);

    if (found)
      out += local_out;

    // If there are no moose object params then we have to be careful about how we
    // increment the iterator.  We only want to increment if we aren't already
    // at the end.
  } while (it != _moose_object_params.end() && ++it != _moose_object_params.end());

  return out;
}
Esempio n. 2
0
int			do_trace(pid_t child)
{
	int			status;
	// long		syscall, retval;
	// t_regs		regs;
	unsigned int	nb_arg = 0;

	waitpid(child, NULL, WUNTRACED);

	ptrace(PTRACE_SEIZE, child, 0, PTRACE_O_TRACESYSGOOD);

// signal(SIGHUP, SIG_IGN);
signal(SIGINT, &sig_handler);
// signal(SIGQUIT, SIG_IGN);
// signal(SIGILL, SIG_IGN);
// signal(SIGTRAP, SIG_IGN);
// signal(SIGABRT, SIG_IGN);
// signal(SIGFPE, SIG_IGN);
// signal(SIGKILL, SIG_IGN);
// signal(SIGBUS, SIG_IGN);
// signal(SIGSEGV, SIG_IGN);
// signal(SIGSYS, SIG_IGN);
// signal(SIGPIPE, SIG_IGN);
// signal(SIGALRM, SIG_IGN);
// signal(SIGTERM, SIG_IGN);
// signal(SIGUSR1, SIG_IGN);
// signal(SIGUSR2, SIG_IGN);
// signal(SIGCHLD, SIG_IGN);
// signal(SIGPWR, SIG_IGN);
// signal(SIGWINCH, SIG_IGN);
// signal(SIGURG, SIG_IGN);
// signal(SIGPOLL, SIG_IGN);
// signal(SIGSTOP, SIG_IGN);
// signal(SIGTSTP, SIG_IGN);
// signal(SIGCONT, SIG_IGN);
// signal(SIGTTIN, SIG_IGN);
// signal(SIGTTOU, SIG_IGN);
// signal(SIGVTALRM, SIG_IGN);
// signal(SIGPROF, SIG_IGN);
// signal(SIGXCPU, SIG_IGN);
// signal(SIGXFSZ, SIG_IGN);


	// t_proto		proto;
e_trap trap;
	while (1)
	{
		trap = wait_for_trap(child, &status);
		if (trap == EXIT)
		{
			// dprintf(1, "EXIT\n");
			break;
		}
		else if (trap == SYSCALL) {
			// dprintf(1, "SYSCALL\n");
			if (do_syscall(child, &status)) {
				dprintf(1, "Exit syscall");
				break;
			}
		}
		else if (trap == SIGNAL) {
			// dprintf(1, "SIGNAL\n");
			if (do_signal(child, &status)) {
				dprintf(1, "Exit signal");
				break;
			}
		}

	}
	child_out(status);
	if (WIFSIGNALED(status))
		kill(getpid(), WTERMSIG(status));
	exit(WEXITSTATUS(status));
	return (0);
}