示例#1
0
void gp_fault(unsigned long cs, unsigned long eip, unsigned long error)
{
	ReversibleString<256> s;

	Formatter::fPrintf(&s, "General Protection Fault (%x) at %x:%x", error, cs, eip);
	a.Panic(s.GetString());
}
示例#2
0
文件: Events.C 项目: FeCastle/arum
//
// returns true if parseEvent successfully completed an event and if the
// new node could be created; otherwise returns false
//
bool
Events::addNode(Arch & a)
{
    bool rv;

    EventNode * add = new EventNode;
    if (add == NULL) { // no memory
        rv = false;
    } else {
        add->setCount = 0;
        rv = a.parseEvent(add);
        if (rv != true) {
           //printf ("EVENTS:addNode: call to parseEvent returned false!!\n");
           delete add;
        }
        if (rv == true) {
           add->next = NULL;
           add->index = this->count;
           this->count++;
           if (this->head == NULL) {
               this->head = add;
           } else {
               this->tail->next = add;
           }
           this->tail = add;
        }
    }
    return rv;
}
示例#3
0
void
IdentifierInfo::DoInsnLookup(const Arch& arch,
                             SourceLocation source,
                             DiagnosticsEngine& diags)
{
    if (m_flags & DID_INSN_LOOKUP)
        return;
    ++num_insn_lookup;
    m_flags &= ~(IS_INSN | IS_PREFIX);
    Arch::InsnPrefix ip = arch.ParseCheckInsnPrefix(getName(), source, diags);
    switch (ip.getType())
    {
        case Arch::InsnPrefix::INSN:
            ++num_insn_lookup_insn;
            m_insn = const_cast<Arch::InsnInfo*>(ip.getInsn());
            m_flags |= IS_INSN;
            break;
        case Arch::InsnPrefix::PREFIX:
            ++num_insn_lookup_prefix;
            m_insn = const_cast<Prefix*>(ip.getPrefix());
            m_flags |= IS_PREFIX;
            break;
        default:
            ++num_insn_lookup_none;
            break;
    }
    m_flags |= DID_INSN_LOOKUP;
}
示例#4
0
文件: arch.cpp 项目: nfrey/qreal
Arch::Arch(Arch const &other)
    :Item()
{
    mNeedScalingRect = other.mNeedScalingRect ;
    mPen = other.mPen;
    mBrush = other.mBrush;
    mDomElementType = pictureType;
    mX1 = other.mX1;
    mX2 = other.mX2;
    mY1 = other.mY1;
    mY2 = other.mY2;
    mSpanAngle = other.mSpanAngle;
    mStartAngle = other.mStartAngle;
    mRect = other.mRect;
    mListScalePoint = other.mListScalePoint;
    setPos(other.x(), other.y());
}
示例#5
0
int
main(int argc, char** argv) 
{
#if SYSAPI_WIN32
	// record window instance for tray icon, etc
	ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
#endif
	
	Arch arch;
	arch.init();

	Log log;
	EventQueue events;

	ClientApp app(&events, createTaskBarReceiver);
	return app.run(argc, argv);
}
示例#6
0
int Linearizator::FindMinString(SuffixTree* tree, int inputStringLength)
{
	int checkedLength = 0;
	int lastIndex = inputStringLength + inputStringLength;

	Vertex* root = tree->GetRoot();
	Arch* nextArch = root->FindMinOutcomeArch();

	while (checkedLength + nextArch->GetLength(lastIndex) < inputStringLength)
	{
		int realLength = nextArch->GetLength(lastIndex);
		checkedLength += realLength;
		nextArch = nextArch->nextVertex->FindMinOutcomeArch();
	}

	int number = tree->FindLeafArchNumber(nextArch);

	delete tree;
	return number >= inputStringLength ? number - inputStringLength : number;
}
示例#7
0
int
main(int argc, char **argv)
{
#if SYSAPI_WIN32
    // record window instance for tray icon, etc
    ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
#endif

    Arch arch;
    arch.init();
    
    Log log;
    log.setFilter(kDEBUG2);

    string lockFile;
    for (int i = 0; i < argc; i++) {
        if (string(argv[i]).compare("--lock-file") == 0) {
            lockFile = argv[i + 1];
        }
    }

    if (!lockFile.empty()) {
        lock(lockFile);
    }


    testing::InitGoogleTest(&argc, argv);

    int result = RUN_ALL_TESTS();

    if (!lockFile.empty()) {
        unlock(lockFile);
    }
  
  // gtest seems to randomly finish with error codes (e.g. -1, -1073741819)
  // even when no tests have failed. not sure what causes this, but it
  // happens on all platforms and  keeps leading to false positives.
  // according to the documentation, 1 is a failure, so we should be
  // able to trust that code.
  return (result == 1) ? 1 : 0;
}
示例#8
0
int
main(int argc, char **argv)
{
#if SYSAPI_WIN32
    // HACK: shouldn't be needed, but logging fails without this.
    ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
#endif

    Arch arch;
    arch.init();
    
    Log log;
    log.setFilter(kDEBUG4);

    testing::InitGoogleTest(&argc, argv);
  
  // gtest seems to randomly finish with error codes (e.g. -1, -1073741819)
  // even when no tests have failed. not sure what causes this, but it
  // happens on all platforms and  keeps leading to false positives.
  // according to the documentation, 1 is a failure, so we should be
  // able to trust that code.
  return (RUN_ALL_TESTS() == 1) ? 1 : 0;
}
示例#9
0
void
IdentifierInfo::DoRegLookup(const Arch& arch,
                            SourceLocation source,
                            DiagnosticsEngine& diags)
{
    if (m_flags & DID_REG_LOOKUP)
        return;
    ++num_reg_lookup;
    m_flags &= ~(IS_REGISTER | IS_REGGROUP | IS_SEGREG | IS_TARGETMOD);
    Arch::RegTmod regtmod = arch.ParseCheckRegTmod(getName(), source, diags);
    switch (regtmod.getType())
    {
        case Arch::RegTmod::REG:
            ++num_reg_lookup_reg;
            m_reg = const_cast<Register*>(regtmod.getReg());
            m_flags |= IS_REGISTER;
            break;
        case Arch::RegTmod::REGGROUP:
            ++num_reg_lookup_reggroup;
            m_reg = const_cast<RegisterGroup*>(regtmod.getRegGroup());
            m_flags |= IS_REGGROUP;
            break;
        case Arch::RegTmod::SEGREG:
            ++num_reg_lookup_segreg;
            m_reg = const_cast<SegmentRegister*>(regtmod.getSegReg());
            m_flags |= IS_SEGREG;
            break;
        case Arch::RegTmod::TARGETMOD:
            ++num_reg_lookup_targetmod;
            m_reg = const_cast<TargetModifier*>(regtmod.getTargetMod());
            m_flags |= IS_TARGETMOD;
            break;
        default:
            ++num_reg_lookup_none;
            break;
    }
    m_flags |= DID_REG_LOOKUP;
}
示例#10
0
int
DaemonApp::run(int argc, char** argv)
{
#if SYSAPI_WIN32
	// win32 instance needed for threading, etc.
	ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
#endif
	
	Arch arch;
	arch.init();

	Log log;
	EventQueue events;
	m_events = &events;

	bool uninstall = false;
	try
	{
#if SYSAPI_WIN32
		// sends debug messages to visual studio console window.
		log.insert(new MSWindowsDebugOutputter());
#endif

		// default log level to system setting.
		string logLevel = arch.setting("LogLevel");
		if (logLevel != "")
			log.setFilter(logLevel.c_str());

		bool foreground = false;

		for (int i = 1; i < argc; ++i) {
			string arg(argv[i]);

			if (arg == "/f" || arg == "-f") {
				foreground = true;
			}
#if SYSAPI_WIN32
			else if (arg == "/install") {
				uninstall = true;
				arch.installDaemon();
				return kExitSuccess;
			}
			else if (arg == "/uninstall") {
				arch.uninstallDaemon();
				return kExitSuccess;
			}
#endif
			else {
				stringstream ss;
				ss << "Unrecognized argument: " << arg;
				foregroundError(ss.str().c_str());
				return kExitArgs;
			}
		}

		if (foreground) {
			// run process in foreground instead of daemonizing.
			// useful for debugging.
			mainLoop(false);
		}
		else {
#if SYSAPI_WIN32
			arch.daemonize("Synergy", winMainLoopStatic);
#elif SYSAPI_UNIX
			arch.daemonize("Synergy", unixMainLoopStatic);
#endif
		}

		return kExitSuccess;
	}
	catch (XArch& e) {
		String message = e.what();
		if (uninstall && (message.find("The service has not been started") != String::npos)) {
			// TODO: if we're keeping this use error code instead (what is it?!).
			// HACK: this message happens intermittently, not sure where from but
			// it's quite misleading for the user. they thing something has gone
			// horribly wrong, but it's just the service manager reporting a false
			// positive (the service has actually shut down in most cases).
		}
		else {
			foregroundError(message.c_str());
		}
		return kExitFailed;
	}
	catch (std::exception& e) {
		foregroundError(e.what());
		return kExitFailed;
	}
	catch (...) {
		foregroundError("Unrecognized error.");
		return kExitFailed;
	}
}
示例#11
0
void VirtMemManager::ResolvePageFault(uintptr fault_address, bool write_error, bool protection_error, bool user_mode)
{
	// If its a page not present fault, check for a matching section
	if(!protection_error) {
		int i, c;
		c = CurrentThread->proc->Sections->Count();
		Section::Extent ae;
		ae.Lower = fault_address;
		ae.Upper = fault_address;

		protection_error = true; // Set this back to false if we find a valid section

		for(i = 0; i < c; i++) {
			Section::Extent se;
			Section &s = CurrentThread->proc->Sections->GetItem(i);
			if(s.CheckExtents(&se)) {
				if(ae == se) {
					// Its part of this section.  Allow expanding sections
					if(s.Flags & Section::AutoExpand) {
						if((fault_address < s.Base) && ((s.Base - fault_address) <= s.ExpandDown)) {
							s.ExpandDown -= (s.Base - fault_address);
							s.Base = fault_address;
							protection_error = false;
						}
						if((fault_address >= (s.Base + s.Length)) && ((fault_address - (s.Base + s.Length)) <= s.ExpandUp)) {
							s.ExpandUp -= (fault_address - (s.Base + s.Length));
							s.Length = fault_address - s.Base + 1;
							protection_error = false;
						}
					} 
					if((fault_address >= s.Base) && (fault_address < (s.Base + s.Length)))
						protection_error = false;

					if(!protection_error) {
						// Map the page
						physaddr_t paddr = NULL;
						if(s.Flags & Section::Bits)
							paddr = (fault_address - s.Base + s.MemSource) & GetPageMask();
		
						MapPage(fault_address & GetPageMask(), NULL, false, NULL,
							(fault_address - s.Base + s.MemSource) & GetPageMask(),
							(s.Flags & Section::KernelSection) ? false : true,
							(s.Flags & Section::Write) ? true : false);

						break;
					}
				}
			}
		}
	}
			
	// Check for errors
	if(protection_error) {
		// A bad error
		a.kconsole->Printf("PAGE FAULT! Invalid attempt by ");
		if(user_mode)
			a.kconsole->Printf("process ");
		else
			a.kconsole->Printf("kernel ");
		a.kconsole->Printf("to ");
		if(write_error)
			a.kconsole->Printf("write to ");
		else
			a.kconsole->Printf("read from ");
		a.kconsole->Printf("address %x whilst executing %s\n", fault_address, CurrentThread->proc->name);
		a.Panic();		
	}
}
示例#12
0
文件: Events.C 项目: FeCastle/arum
void
Events::walkArchList(const Arch & a)
{
  a.printNodes();
}