Example #1
0
void doSomething() {
    int deadbeef = 0xdeadbeef;
    int cafebabe = 0xcafebabe;
    char buffer[BUFF_SIZE];
    char **stack;

    memset(buffer, 0, sizeof(buffer));

    if (DEBUG) {
        puts("Entered function: doSomething\n");
        // Let the person know where the doSomethingDifferent function is
        // located
        printf("The doSomethingDifferent function is located at: %p\n", doSomethingDifferent);

        void *ret =  __builtin_return_address(0);
        stack = (char **) (&stack);
        printDebugInfo(ret, stack, buffer, buffer + BUFF_SIZE);
    }

    // Can you make the next three lines alter the return address?
    printf("Send me something special!: "); fflush(stdout);
    read(0, buffer, 512);
    printf("\n");

    if (DEBUG) {
        void *ret =  __builtin_return_address(0);
        stack = (char **) (&stack);
        printDebugInfo(ret, stack, buffer, buffer + BUFF_SIZE);

        puts("Leaving function: doSomething");
    }
}
Example #2
0
void Expand::act()
{
	printDebugInfo("Acting");
	acting = true;
	builder->expand();
	printDebugInfo("Acting End");
}
Example #3
0
void SatisfyTechRequirement::update()
{
	printDebugInfo("Update");
	if (complete)
		return;

	if (!assigned)
	{
		assign();
		return;
	}

	if (!acting && assigned)
	{
		act();
		return;
	}

	if (acting)
	{
		if (util::game::canResearch(techType))
			succeed();
	}
	printDebugInfo("Update End");
}
Example #4
0
void returnToLibc() {
    char buffer[0];
    char **stack;

    memset(buffer, 0, sizeof(buffer));

    if (DEBUG) {
        puts("Entered function: returnToLibc\n");

        void *ret =  __builtin_return_address(0);
        stack = (char **) (&stack);
        printDebugInfo(ret, stack);
    }

    printf("Can you Return to Libc Bro?: "); fflush(stdout);
    read(0, buffer, 0x100);
    write(1, buffer, 0x100);
    printf("\n");

    if (DEBUG) {
        void *ret =  __builtin_return_address(0);
        stack = (char **) (&stack);
        printDebugInfo(ret, stack);

        puts("Leaving function: returnToLibc");
    }
}
Example #5
0
void Scout::assign()
{
	printDebugInfo("Assign");
	createCoalition();
	assigned = true;
	printDebugInfo("Assign End");
}
Example #6
0
void Scout::update()
{
	printDebugInfo("Update");
	if (complete)
		return;

	if (BWAPI::Broodwar->getFrameCount() - target->getLastVisited() < 5)
	{
		succeed();
		return;
	}

	if (!assigned)
	{
		assign();
		return;
	}

	if (coalition->isActive())
	{
		act();
		return;
	}	

	printDebugInfo("Update End");
}
Example #7
0
void gimmeSomeShellcode() {
    char buffer[BUFF_SIZE];
    char **stack;

    memset(buffer, 0, sizeof(buffer));

    if (DEBUG) {
        puts("Entered function: gimmeSomeShellcode\n");

        void *ret =  __builtin_return_address(0);
        stack = (char **) (&stack);
        printDebugInfo(ret, stack, buffer, buffer + BUFF_SIZE);
    }

    // Can you make the next three lines alter the return address?
    printf("Send whatever you want: "); fflush(stdout);
    fgets(buffer, 0x100, stdin);
    printf("\n");

    if (DEBUG) {
        void *ret =  __builtin_return_address(0);
        stack = (char **) (&stack);
        printDebugInfo(ret, stack, buffer, buffer + BUFF_SIZE);

        puts("Leaving function: gimmeSomeShellcode");
    }
}
Example #8
0
void returnOrientedProgramming() {
    char buffer[0];
    char **stack;

    memset(buffer, 0, sizeof(buffer));

    if (DEBUG) {
        puts("Entered function: returnOrientedProgramming\n");
        
        printf("setCommand is at: %p\n", setCommand);
        printf("setFunction is at: %p\n", setFunction);
        printf("doTheThing is at: %p\n", doTheThing);

        void *ret =  __builtin_return_address(0);
        stack = (char **) (&stack);
        printDebugInfo(ret, stack);
    }

    // Can you make the next three lines alter the return address?
    printf("What do you want me to chain for you?: "); fflush(stdout);
    fgets(buffer, 0x100, stdin);
    printf("\n");

    if (DEBUG) {
        void *ret =  __builtin_return_address(0);
        stack = (char **) (&stack);
        printDebugInfo(ret, stack);

        puts("Leaving function: returnOrientedProgramming");
    }
}
Example #9
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofBackground(100);
    ofSetColor(255);
    
    //Load TMX file
    ofBuffer buffer = ofBufferFromFile("example.tmx");
    map->ParseText(buffer.getText());

    //Check error
    if (map->HasError()) {
		printf("error code: %d\n", map->GetErrorCode());
		printf("error text: %s\n", map->GetErrorText().c_str());
		system("PAUSE");
        
		return map->GetErrorCode();
	}
    
    //Debug info
    printDebugInfo();
    
    //Load images
    for (int i = 0; i < map->GetNumTilesets(); ++i) {
        //tileSheet.loadImage("tmw_desert_spacing.png");
        tileSheets.push_back(ofImage());
        (tileSheets.back()).loadImage( map->GetTileset(i)->GetImage()->GetSource().c_str() );
    }
    
    
}
Example #10
0
void UnwrappedLineParser::addUnwrappedLine() {
  if (Line->Tokens.empty())
    return;
  DEBUG({
    if (CurrentLines == &Lines)
      printDebugInfo(*Line);
  });
Example #11
0
void Expand::fail()
{
	complete = true;
	profit = 0.0;
	printDebugInfo("Failure!", true);

	EconHelper::doneExpanding();
}
Example #12
0
void Expand::succeed()
{
	complete = true;
	profit = 1.0;
	printDebugInfo("Success!", true);

	EconHelper::doneExpanding();
}
Example #13
0
void Scout::succeed()
{
	complete = true;
	profit = 1.0;
	printDebugInfo("Success!", true);

	ArmyHelper::stopScouting();
}
Example #14
0
/** Called from the update thread: takes the wiimote state and
 */
void Wiimote::update()
{
    float normalized_angle = -(m_wiimote_handle->accel.y-128)
                           /  UserConfigParams::m_wiimote_raw_max;

    if(normalized_angle<-1.0f)
        normalized_angle = -1.0f;
    else if(normalized_angle>1.0f)
        normalized_angle = 1.0f;

    // Shape the curve that determines steering depending on wiimote angle.
    // The wiimote value is already normalized to be in [-1,1]. Now use a
    // weighted linear combination to compute the steering value used in game.
    float w1 = UserConfigParams::m_wiimote_weight_linear;
    float w2 = UserConfigParams::m_wiimote_weight_square;
    float wa = UserConfigParams::m_wiimote_weight_asin;
    float ws = UserConfigParams::m_wiimote_weight_sin;

    const float sign = normalized_angle >= 0.0f ? 1.0f : -1.0f;
    const float normalized_angle_2 = w1 * normalized_angle
                                   + w2 * sign*normalized_angle*normalized_angle
                                   + wa * asinf(normalized_angle)*(2.0f/M_PI)
                                   + ws * sinf(normalized_angle*(M_PI/2.0f));

    if(UserConfigParams::m_wiimote_debug)
    {
        Log::verbose("wiimote", "raw %d normal %f result %f",
                     m_wiimote_handle->accel.y,
                     normalized_angle,
                     normalized_angle_2);
    }

    const float JOYSTICK_ABS_MAX_ANGLE = 32766.0f;

    const float angle = normalized_angle_2 * JOYSTICK_ABS_MAX_ANGLE;

    m_irr_event.lock();
    {

        irr::SEvent::SJoystickEvent &ev = m_irr_event.getData().JoystickEvent;
        ev.Axis[SEvent::SJoystickEvent::AXIS_X] =
                 (irr::s16)(irr::core::clamp(angle, -JOYSTICK_ABS_MAX_ANGLE,
                                                    +JOYSTICK_ABS_MAX_ANGLE));
        // --------------------- Wiimote buttons --------------------
        // Copy the wiimote button structure, but mask out the non-button
        // bits (4 bits of the button structure are actually bits for the
        // accelerator).
        ev.ButtonStates = m_wiimote_handle->btns & WIIMOTE_BUTTON_ALL;
    }
    m_irr_event.unlock();

#ifdef DEBUG
    if(UserConfigParams::m_wiimote_debug)
        printDebugInfo();
#endif

}   // update
Example #15
0
void SatisfyTechRequirement::act()
{
	printDebugInfo("Acting");	
	printDebugInfo(techType.c_str());

	if (util::game::getSelf()->allUnitCount(techType.requiredUnit()) < 1)
	{
		CreateUnit* createUnit = new CreateUnit(techType.requiredUnit());
		addSubTask(createUnit);
	}

	if (util::game::getSelf()->allUnitCount(techType.whatResearches()) < 1)
	{
		CreateUnit* createUnit = new CreateUnit(techType.whatResearches());
		addSubTask(createUnit);
	}

	acting = true;
	printDebugInfo("Acting End");
}
 void ProfileVerifierPassT<FType, BType>::debugEntry (DetailedBlockInfo *DI) {
   dbgs() << "TROUBLE: Block " << DI->BB->getNameStr()       << " in "
          << DI->BB->getParent()->getNameStr()               << ":"
          << "BBWeight="  << format("%20.20g",DI->BBWeight)  << ","
          << "inWeight="  << format("%20.20g",DI->inWeight)  << ","
          << "inCount="   << DI->inCount                     << ","
          << "outWeight=" << format("%20.20g",DI->outWeight) << ","
          << "outCount="  << DI->outCount                    << "\n";
   if (!PrintedDebugTree) {
     PrintedDebugTree = true;
     printDebugInfo(&(DI->BB->getParent()->getEntryBlock()));
   }
 }
Example #17
0
bool Selector::init(int serverPort)
{



	bool result = false;
	result = _acceptor.init(serverPort);
	
	if (result == false)
	{
		printDebugInfo("Acceptor initialize failed, please check!");
		
		return false;
	}

	result = _udpAcceptor.init(SM_UDP);
	if (result == false)
	{
		printDebugInfo("udp Acceptor initialize failed , please check!");
		
		_acceptor.getSocket().close();
		return false;
	}
	

	result = _udpAcceptor.bindPort(serverPort);

	if (result == false)
	{
		printDebugInfo("udp Acceptor binding port  failed , please check!");
		
		_udpAcceptor.close();
		
		_acceptor.getSocket().close();
	}

	return true;
	
}
  void ProfileVerifierPassT<FType, BType>::printDebugInfo(const BType *BB) {

    if (BBisPrinted.find(BB) != BBisPrinted.end()) return;

    double BBWeight = PI->getExecutionCount(BB);
    if (BBWeight == ProfileInfoT<FType, BType>::MissingValue) { BBWeight = 0; }
    double inWeight = 0;
    int inCount = 0;
    std::set<const BType*> ProcessedPreds;
    for (const_pred_iterator bbi = pred_begin(BB), bbe = pred_end(BB);
         bbi != bbe; ++bbi ) {
      if (ProcessedPreds.insert(*bbi).second) {
        typename ProfileInfoT<FType, BType>::Edge E = PI->getEdge(*bbi,BB);
        double EdgeWeight = PI->getEdgeWeight(E);
        if (EdgeWeight == ProfileInfoT<FType, BType>::MissingValue) { EdgeWeight = 0; }
        dbgs() << "calculated in-edge " << E << ": " 
               << format("%20.20g",EdgeWeight) << "\n";
        inWeight += EdgeWeight;
        inCount++;
      }
    }
    double outWeight = 0;
    int outCount = 0;
    std::set<const BType*> ProcessedSuccs;
    for ( succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB);
          bbi != bbe; ++bbi ) {
      if (ProcessedSuccs.insert(*bbi).second) {
        typename ProfileInfoT<FType, BType>::Edge E = PI->getEdge(BB,*bbi);
        double EdgeWeight = PI->getEdgeWeight(E);
        if (EdgeWeight == ProfileInfoT<FType, BType>::MissingValue) { EdgeWeight = 0; }
        dbgs() << "calculated out-edge " << E << ": " 
               << format("%20.20g",EdgeWeight) << "\n";
        outWeight += EdgeWeight;
        outCount++;
      }
    }
    dbgs() << "Block " << BB->getNameStr()                << " in " 
           << BB->getParent()->getNameStr()               << ":"
           << "BBWeight="  << format("%20.20g",BBWeight)  << ","
           << "inWeight="  << format("%20.20g",inWeight)  << ","
           << "inCount="   << inCount                     << ","
           << "outWeight=" << format("%20.20g",outWeight) << ","
           << "outCount"   << outCount                    << "\n";

    // mark as visited and recurse into subnodes
    BBisPrinted.insert(BB);
    for ( succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB); 
          bbi != bbe; ++bbi ) {
      printDebugInfo(*bbi);
    }
  }
Example #19
0
void Expand::update()
{
	printDebugInfo("Update");
	if (complete)
		return;

	if (!assigned)
	{
		assign();
		return;
	}

	if (coalition->isActive())
	{
		if(!builder)
			builder = (*coalition->getAgentSet().begin());

		if ((*coalition->getUnitSet().begin())->exists() && !complete)
			act();
	}

	printDebugInfo("Update End");
}
Example #20
0
LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line,
                                                 StringRef Prefix = "") {
  llvm::dbgs() << Prefix << "Line(" << Line.Level << ")"
               << (Line.InPPDirective ? " MACRO" : "") << ": ";
  for (std::list<UnwrappedLineNode>::const_iterator I = Line.Tokens.begin(),
                                                    E = Line.Tokens.end();
       I != E; ++I) {
    llvm::dbgs() << I->Tok->Tok.getName() << "[" << I->Tok->Type << "] ";
  }
  for (std::list<UnwrappedLineNode>::const_iterator I = Line.Tokens.begin(),
                                                    E = Line.Tokens.end();
       I != E; ++I) {
    const UnwrappedLineNode &Node = *I;
    for (SmallVectorImpl<UnwrappedLine>::const_iterator
             I = Node.Children.begin(),
             E = Node.Children.end();
         I != E; ++I) {
      printDebugInfo(*I, "\nChild: ");
    }
  }
  llvm::dbgs() << "\n";
}
Example #21
0
void Scout::act()
{
	printDebugInfo("Acting");	
	acting = coalition->getUnitSet().move(target->getRegion()->getCenter());
	printDebugInfo("Acting End");
}
Example #22
0
//===========================================================================
void Intersector::compute(bool compute_at_boundary)
//===========================================================================
{
    // Purpose: Compute the topology of the current intersection

    // Make sure that no "dead intersection points" exist in the pool,
    // i.e. points that have been removed when compute() has been run
    // on sibling subintersectors.
    int_results_->synchronizePool();

    // Make sure that all intersection points at the
    // boundary/boundaries of the current object are already computed
    if (compute_at_boundary)
	getBoundaryIntersections();

    // Remove inner points in constant parameter intersection
    // links
    // (vsk, 0609) and isolated points identical to the existing ones
    int_results_->cleanUpPool();
    int nmb_orig = int_results_->numIntersectionPoints();

    if (getenv("DEBUG") && *(getenv("DEBUG")) == '1') {
	try {
	    printDebugInfo();
	} catch (...) {
	    MESSAGE("Failed printing debug info, continuing.");
	}
    }

    // Check if any intersections are possible in the inner of the
    // objects
    int status_intercept = performInterception();

    // Branch on the outcome of the interseption test
    if (status_intercept == 0) {
	// No intersection is possible
    } else if (status_intercept == 2) {
	// Both objects are too small for further processing.
	// Handle micro case
	microCase();
    } else if (degTriangleSimple()) {
	// This situation is currently relevant only for intersections
	// between two parametric surfaces. It will probably at some
	// stage be relevant for two-parametric functions.
	// All the necessary connections are made
    } else if (checkCoincidence()) {
	// The two objects coincide. The representation is already
	// updated according to this situation
    } else {
	// status_intercept == 1

	// Intersections might exist. Check for simple case. 0 = Maybe
	// simple case; 1 = Confirmed simple case.
	int status_simplecase = simpleCase();

	if (status_simplecase == 1) {
	    // Confirmed simple case.
	    // Compute intersection points or curves according to the
	    // properties of this particular intersection
	    updateIntersections();
	} else if (isLinear()) {
	    // Linearity is a simple case, but it is important to
	    // check for coincidence before trying to find/connect
	    // intersections as the simple case criteria is not
	    // satisfied
	    updateIntersections();
	}
	else if (complexIntercept())
	{
	    // Interception by more complex algorithms is performed
	    // (implicitization). No further intersectsions are found
	    // to be possible
	}
	else if (complexSimpleCase())
	{
	    // Simple case test by more complex algorithms is performed
	    // (implicitization). A simple case is found.
	    updateIntersections();
	} else if (!complexityReduced()) {
	    // For the time being, write documentation of the
	    // situation to a file
	    handleComplexity();
	} else {
	    // It is necessary to subdivide the current objects
	    doSubdivide();
	    
	    int nsubint = int(sub_intersectors_.size());
	    for (int ki = 0; ki < nsubint; ki++) {
		sub_intersectors_[ki]->getIntPool()
		    ->includeCoveredNeighbourPoints();
		sub_intersectors_[ki]->compute();
	    }
	}
    }

//     // Write intersection point diagnostics
//     if (numParams() == 4) {
// 	writeIntersectionPoints();
//     }

    if (prev_intersector_ && prev_intersector_->numParams() > numParams())
    {
	// Remove inner points in constant parameter intersection
	// links
	// (vsk, 0609) and isolated points identical to the existing ones
	int_results_->cleanUpPool(nmb_orig);

	// No more recursion at this level. Post iterate the intersection points
	doPostIterate();
    }

    // Prepare output intersection results
    if (prev_intersector_ == 0 || prev_intersector_->isSelfIntersection())
    {
	/*if (getenv("DEBUG_FINISH") && *(getenv("DEBUG_FINISH")) == '1') {
	    cout << "Status after cleaning up pool:" << endl;
	    writeIntersectionPoints();
	    }*/

	// Remove loose ends of intersection links in the inner
	//int_results_->weedOutClutterPoints();
	if (getenv("DEBUG_FINISH") && *(getenv("DEBUG_FINISH")) == '1') 
	{
	    cout << "Status after removing clutter points:" << endl;
	    writeIntersectionPoints();
	    int_results_->writeDebug();
	}

	// Remove loose ends of intersection links in the inner
	//int_results_->weedOutClutterPoints();
	int_results_->cleanUpPool(0);

	if (true /*getenv("DO_REPAIR") && *(getenv("DO_REPAIR")) == '1'*/) 
	{
	    if (getenv("DEBUG_FINISH") && *(getenv("DEBUG_FINISH")) == '1') 
	    {
		cout << "Starting repair" << endl;
	    }
	    repairIntersections();

	    if (getenv("DEBUG_FINISH") && *(getenv("DEBUG_FINISH")) == '1') 
	    {
		cout << "Status after repairing intersections:" << endl;
		writeIntersectionPoints();
	    }
	}
    }

    if (prev_intersector_ == 0) {
	// Top level intersector
	/*if (getenv("DEBUG_FINISH") && *(getenv("DEBUG_FINISH")) == '1') {
	    cout << "Status after removing clutter points:" << endl;
	    writeIntersectionPoints();
	    }*/

// 	if (/*true */getenv("DO_REPAIR") && *(getenv("DO_REPAIR")) == '1') {
// 	    repairIntersections();

// 	    if (getenv("DEBUG_FINISH") && *(getenv("DEBUG_FINISH")) == '1') {
// 		cout << "Status after repairing intersections:" << endl;
// 		writeIntersectionPoints();
// 	    }
// 	}

	if (getenv("DEBUG_FINISH") && *(getenv("DEBUG_FINISH")) == '1') {
	    int_results_->writeDebug();
	}

	int_results_->makeIntersectionCurves();
    }
}
Example #23
0
void TbTrace::onItem(unsigned traceIndex,
            const s2e::plugins::ExecutionTraceItemHeader &hdr,
            void *item)
{
    //m_output << "Trace index " << std::dec << traceIndex << std::endl;
    if (hdr.type == s2e::plugins::TRACE_MOD_LOAD) {
        const s2e::plugins::ExecutionTraceModuleLoad &load = *(s2e::plugins::ExecutionTraceModuleLoad*)item;
        m_output << "Loaded module " << load.name
                 << " at 0x" << std::hex << load.loadBase;
        m_output << std::endl;
        return;
    }

    if (hdr.type == s2e::plugins::TRACE_MOD_UNLOAD) {
        const s2e::plugins::ExecutionTraceModuleUnload &unload = *(s2e::plugins::ExecutionTraceModuleUnload*)item;
        m_output << "Unloaded module at 0x" << unload.loadBase;
        m_output << std::endl;
        return;
    }

    if (hdr.type == s2e::plugins::TRACE_PAGEFAULT) {
        const s2e::plugins::ExecutionTracePageFault &fault = *(s2e::plugins::ExecutionTracePageFault*)item;
        m_output << "PF @" << std::hex << fault.pc << " addr=" <<  fault.address << " isWrite=" << (int) fault.isWrite;
        m_output << std::endl;
        return;
    }

    if (hdr.type == s2e::plugins::TRACE_EXCEPTION) {
        const s2e::plugins::ExecutionTraceException &fault = *(s2e::plugins::ExecutionTraceException*)item;
        m_output << "EXCP @" << std::hex << fault.pc << " vec=" <<  fault.vector;
        m_output << std::endl;
        return;
    }

    if (hdr.type == s2e::plugins::TRACE_STATE_SWITCH) {
        const s2e::plugins::ExecutionTraceStateSwitch &s = *(s2e::plugins::ExecutionTraceStateSwitch*)item;
        m_output << "State switch " << hdr.stateId << " => " << s.newStateId;
        m_output << std::endl;
        return;
    }

    if (hdr.type == s2e::plugins::TRACE_FORK) {
        s2e::plugins::ExecutionTraceFork *f = (s2e::plugins::ExecutionTraceFork*)item;
        m_output << "Forked at 0x" << std::hex << f->pc << " - ";
        printDebugInfo(hdr.pid, f->pc, 0, false);
        m_output << std::endl;
        return;
    }

    if (hdr.type == s2e::plugins::TRACE_TB_START) {
        const s2e::plugins::ExecutionTraceTb *te =
                (const s2e::plugins::ExecutionTraceTb*) item;

        m_output << "0x" << std::hex << te->pc<< " - ";

        if (PrintRegisters) {
            m_output << std::endl << "    ";
            printRegisters(te);
            m_output << std::endl << "    ";
        }

        printDebugInfo(hdr.pid, te->pc, te->size, true);

        m_output << std::endl;
        m_hasItems = true;
        return;
    }

    if (PrintMemory && (hdr.type == s2e::plugins::TRACE_MEMORY)) {
        const s2e::plugins::ExecutionTraceMemory *te =
                (const s2e::plugins::ExecutionTraceMemory*) item;
        std::string type;

        type += te->flags & EXECTRACE_MEM_SYMBHOSTADDR ? "H" : "-";
        type += te->flags & EXECTRACE_MEM_SYMBADDR ? "A" : "-";
        type += te->flags & EXECTRACE_MEM_SYMBVAL ? "S" : "-";
        type += te->flags & EXECTRACE_MEM_WRITE   ? "W" : "R";
        m_output << "S=" << std::dec << hdr.stateId << " P=0x" << std::hex << hdr.pid << " PC=0x" << std::hex << te->pc << " " << type << (int)te->size << "[0x"
                << std::hex << te->address << "]=0x" << std::setw(10) << std::setfill('0') << te->value;

        if (te->flags & EXECTRACE_MEM_HASHOSTADDR) {
           m_output << " hostAddr=0x" << te->hostAddress << " ";
        }

        if (te->flags & EXECTRACE_MEM_OBJECTSTATE) {
           m_output << " cb=0x" << te->concreteBuffer << " ";
        }

        m_output << "\t";

        printDebugInfo(hdr.pid, te->pc, 0, false);
        m_output << std::setfill(' ');
        m_output << std::endl;
       return;
    }

    if (PrintMemoryChecker && (hdr.type == s2e::plugins::TRACE_MEM_CHECKER)) {
        const s2e::plugins::ExecutionTraceMemChecker::Serialized *te =
                (const s2e::plugins::ExecutionTraceMemChecker::Serialized*) item;
        printMemoryChecker(te);
    }
}
Example #24
0
BOOL LLFace::verify(const U32* indices_array) const
{
	BOOL ok = TRUE;

	if( mVertexBuffer.isNull() )
	{
		if( mGeomCount )
		{
			// This happens before teleports as faces are torn down.
			// Stop the crash in DEV-31893 with a null pointer check,
			// but present this info.
			// To clean up the log, the geometry could be cleared, or the
			// face could otherwise be marked for no ::verify.
			//AIFIXME: llinfos << "Face with no vertex buffer and " << mGeomCount << " mGeomCount" << llendl;
		}
		return TRUE;
	}
	
	// First, check whether the face data fits within the pool's range.
	if ((mGeomIndex + mGeomCount) > mVertexBuffer->getRequestedVerts())
	{
		ok = FALSE;
		llinfos << "Face references invalid vertices!" << llendl;
	}

	S32 indices_count = (S32)getIndicesCount();
	
	if (!indices_count)
	{
		return TRUE;
	}
	
	if (indices_count > LL_MAX_INDICES_COUNT)
	{
		ok = FALSE;
		llinfos << "Face has bogus indices count" << llendl;
	}
	
	if (mIndicesIndex + mIndicesCount > (U32)mVertexBuffer->getRequestedIndices())
	{
		ok = FALSE;
		llinfos << "Face references invalid indices!" << llendl;
	}

#if 0
	S32 geom_start = getGeomStart();
	S32 geom_count = mGeomCount;

	const U32 *indicesp = indices_array ? indices_array + mIndicesIndex : getRawIndices();

	for (S32 i = 0; i < indices_count; i++)
	{
		S32 delta = indicesp[i] - geom_start;
		if (0 > delta)
		{
			llwarns << "Face index too low!" << llendl;
			llinfos << "i:" << i << " Index:" << indicesp[i] << " GStart: " << geom_start << llendl;
			ok = FALSE;
		}
		else if (delta >= geom_count)
		{
			llwarns << "Face index too high!" << llendl;
			llinfos << "i:" << i << " Index:" << indicesp[i] << " GEnd: " << geom_start + geom_count << llendl;
			ok = FALSE;
		}
	}
#endif

	if (!ok)
	{
		printDebugInfo();
	}
	return ok;
}
Example #25
0
void Selector::run()
{
	int result = 0;
	timeval tv = {3, 0};
	FD_SET readFds;
	FD_ZERO(&readFds);

	SessionManager *sm = SessionManager::getInstance();

	CommunicatioInformation tcpCi = _acceptor.getSocket().getCommunicationInformation();
	
	CommunicatioInformation udpCi = _udpAcceptor.getCommunicationInformation();
	
	_connectSessons.insert(make_pair(tcpCi.generateKeyForSocket(), _acceptor.getSocket()));
	
	_connectSessons.insert(make_pair(udpCi.generateKeyForSocket(), _udpAcceptor));

	map<string, SocketSession>::iterator iter  = _connectSessons.begin();
	
	isRunning = true;
	
	while (isRunning)
	{
		FD_ZERO(&readFds);

		
		
		iter  = _connectSessons.begin();
			
		while (iter != _connectSessons.end())
		{
			FD_SET(iter->second.getSession().getHandle(), &readFds);
			iter++;
		}

		result = select(0, &readFds, NULL, NULL, &tv);
		if (result == 0)
		{
			continue;
		}

		if (isRunning == false)
		{
			break;
		}


		if (FD_ISSET(_acceptor.getSocket().getHandle(), &readFds))
		{
			printDebugInfo("New Connection By TCP Service Accept");

			AsyncSocket session = _acceptor.acceptSession();
			
			CommunicatioInformation sCi = session.getCommunicationInformation();
			
			//iter = _connectSessons.find(sCi.generateKeyForSocket());
			//if (iter != _connectSessons.end())
			//{
			//	iter->second.getSession().close();
			//	printDebugInfo("Öظ´Á¬½Ó..........");
			//	_connectSessons.erase(iter);
			//}

			_connectSessons.insert(make_pair(sCi.generateKeyForSocket(), session));
			
			printDebugInfo("New Connection By TCP Server Accept");
			
		
		
		}else if (FD_ISSET(_udpAcceptor.getHandle(), &readFds))
		{
			printDebugInfo("New Message By UDP Server Accept");
			
			SocketSession ss(_udpAcceptor);
			
			handleData(ss);
		}
		else
		{
			iter = _connectSessons.begin();
			
			printDebugInfo("Client send message to the server in tcp mode");
			
			while (iter != _connectSessons.end())
			{
				SocketSession ss = iter->second;

				if (FD_ISSET(ss.session.getHandle(), &readFds))
				{
					handleData(ss);

				}
				iter++;
			}

			clearDisconnectionSession();

		}

		
	}

	clearSessions();
}
Example #26
0
void SingleIncident::printDebugInfoDetailed() const
{
	printDebugInfo();
	EpPrintDebugInfoAll( m_trigger );
	EpPrintDebugInfoAll( m_action );
}