예제 #1
0
파일: debug.c 프로젝트: danilaslau/frotznet
void k_debugger(regs *r,uint32 eip, uint32 cs, uint32 eflags)
{
    char *line;
    uint32 n;
	
    kprintf("OpenBLT Kernel Debugger");

    for(;;){
        krefresh();
        line = kgetline(linebuf,80);

		if(!strncmp(line,"pgroup ",7)) { dumppgroup(readnum(line+7)); continue; }
        if(!strncmp(line,"resource ", 9)) { dumponersrc(line+9); continue; }
        if(!strcmp(line,"resources")) { dumprsrc(&resource_list); continue; }
		if(!strncmp(line,"queue ",6)) { dumpqueue(readnum(line+6)); continue; }
        if(!strcmp(line,"tasks")) { dumptasks(); continue; }
        if(!strcmp(line,"ports")) { dumpports(); continue; }
        if(!strcmp(line,"memory")) { memory_status(); continue; }
        if(!strcmp(line,"trace")) { trace(r->ebp,eip); continue; }
        if(!strcmp(line,"regs")) { print_regs(r,eip,cs,eflags); continue; }
        if(!strncmp(line,"dump ",5)) { dump(readnum(line+5),16); continue; }
        if(!strncmp(line,"aspace ",7)) { dumpaddr(readnum(line+7)); continue; }
        if(!strcmp(line,"reboot")) { reboot(); }
        if(!strncmp(line,"checksum ",9)) { checksum(line+9); continue; }
		if(!strncmp(line,"team ",5)) { dumpteam(readnum(line+5)); continue; }
		if(!strncmp(line,"find ",5)) { findpage(readnum(line+5)); continue; }
		if(!strcmp(line,"teams")) { dumpteams(); continue; }
		
        if(!strcmp(line,"exit")) break;
        if(!strcmp(line,"x")) break;
        if(!strcmp(line,"c")) break;
    }
}
예제 #2
0
파일: search.cpp 프로젝트: ombt/ombt
int
BestFirstSearch(List<NodeType> &startstatelist, 
		BinaryTree_AVL<DataType> &startlist, 
		BinaryTree_AVL<DataType> &otherlist)
{
	int status;

	// track all states created
	BinaryTree_AVL<String> allstates;

	// create open priority queue
	List<Proxy<NodeType> > openpq;

	// copy list of start states
	int nodedepth = 1;
	ListIterator<NodeType> startstateIter(startstatelist);
	for ( ; !startstateIter.done(); startstateIter++)
	{
		// copy start state
		Proxy<NodeType> pstart = &startstateIter();

		// set start node depth
		pstart->setDepth(nodedepth);

		// calculate the heuristic value for this node
		if ((status = pstart->heuristic(startlist, otherlist)) != OK)
		{
			ERRORD("heuristic() failed.", status, errno);
			return(status);
		}

		// insert start state into open queue
		if ((status = openpq.insertOrdered(pstart)) != OK)
		{
			ERRORD("insertOrdered() failed.", status, errno);
			return(status);
		}
	}

	// create closed set
	List<Proxy<NodeType> > closedset;

	// start search loop
	for (Proxy<NodeType> pnode; ! openpq.isEmpty(); )
	{
		// dump queue if verbose mode
		if (verbose)
			dumpqueue(openpq);

		// remove next node from priority open queue
		if ((status = openpq.removeAtFront(pnode)) != OK)
		{
			ERRORD("removeAtFront() failed.", status, errno);
			return(status);
		}

		// get current node depth
		nodedepth = pnode->getDepth();

		// check if we have a goal node or not
		status = pnode->isGoal(startlist, otherlist);
		switch (status)
		{
		case OK:
			break;

		case NOMATCH:
		case MAXDEPTHEXCEEDED:
			// no clauses were generated. skip further
			// processing of this node.
			continue;

		case VALID:
			// goal node, print solution
			PrintSolution(pnode);
			PrintRenameVariables(pnode);

			// check if more than one solutions is required
			solutionsfound += 1;
			statistics[SolutionsFound] += 1;
			totalstatistics[TotalSolutionsFound] += 1;

			if (solutionsfound >= solutionsrequired)
				return(VALID);

			// store node in closed set
			if ((status = closedset.insertAtFront(pnode)) != OK)
			{
				ERRORD("insertAtFront() failed.", 
				status, errno);
				return(status);
			}
			continue;

		case MAXCLAUSEEXCEEDED:
			// check if any solutions were found
			if (solutionsfound > 0)
				return(VALID);
			else
				return(NOTPROVEN);

		default:
			// some type of error
			ERRORD("isGoal() failed.", status, errno);
			return(status);
		}

		// generate the children of the current node
		if ((status = pnode->expand(startlist, otherlist)) != OK)
		{
			ERRORD("expand() failed.", status, errno);
			return(status);
		}

		// set up links to parent and calculate the heuristic value
		ListIterator<Proxy<NodeType> > 
			childrenIter(*pnode->getChildren());
		for ( ; !childrenIter.done(); childrenIter++)
		{
			// pointer to child
			Proxy<NodeType> pchild(childrenIter());

			// set up link to parent
			if (reporttype == ReportParent ||
			    reporttype == ReportBoth)
				pchild->setParent(pnode);

			// calculate the heuristic value
			if ((status = pchild->heuristic(
				startlist, otherlist)) != OK)
			{
				ERRORD("heuristic() failed.", status, errno);
				return(status);
			}

			// insert into open queue
			if (!bfswithchecks)
			{
				pchild->setDepth(nodedepth+1);
				if ((status = openpq.insertOrdered(
					pchild)) != OK)
				{
					ERRORD("insertOrdered() failed.", 
						status, errno);
					return(status);
				}
			}
			else
			{
				statistics[RedundantClauseTestsAttempted] += 1;
				totalstatistics[TotalRedundantClauseTestsAttempted] += 1;
				String newnode(pchild->getNormalizedClauses());
				if (allstates.retrieve(newnode) == NOMATCH)
				{
					pchild->setDepth(nodedepth+1);
					if ((status = openpq.insertOrdered(
							pchild)) != OK)
					{
						ERRORD("insertOrdered() failed.", 
							status, errno);
						return(status);
					}
				}
				else
				{
					statistics[RedundantClausesRejected] += 1;
					totalstatistics[TotalRedundantClausesRejected] += 1;
				}
			}
		}

		// store node in closed set. if the clause has no children,
		// then no reason to save it. just release the memory
		//
		if (!(pnode->getChildren()->isEmpty()))
		{
			if ((status = closedset.insertAtFront(pnode)) != OK)
			{
				ERRORD("insertAtFront() failed.", status, errno);
				return(status);
			}
		}
		if (bfswithchecks)
		{
			if (allstates.insert(pnode->getNormalizedClauses()) != OK)
			{
				ERRORD("insert() failed.", status, errno);
				return(status);
			}
		}
	}

	// check if any solutions were found
	if (solutionsfound > 0)
		return(VALID);
	else
		return(NOTPROVEN);
}