Beispiel #1
0
bool CppFileContents::write(OovStringRef const fn)
    {
    SimpleFile file;
    eOpenStatus openStat = file.open(fn, M_WriteExclusiveTrunc, OE_Binary);
    OovStatus status(openStat == OS_Opened, SC_File);
    if(status.ok())
        {
        OovString includeCov = "#include \"OovCoverage.h\"";
        appendLineEnding(includeCov);
        updateMemory();
        status = file.write(includeCov.c_str(), includeCov.length());
        }
    if(status.ok())
        {
        status = file.write(mFileContents.data(), mFileContents.size());
        }
    if(!status.ok())
        {
        OovString str = "Unable to write %s ";
        str += fn;
        str += "\n";
        status.report(ET_Error, str.getStr());
        }
    return status.ok();
    }
Beispiel #2
0
void MainWindow::updateDisplay()
{
    ui->screen->clear();
    quint16 start = 0x2000;
    for (quint8 i = 0; i < 100; i++) {
        QString line;
        //printf("%04x\n",start);fflush(stdout);
        char* p = (char*)ram + start;
        char* maxp = p + 132;
        while (*p != 0x7f && p != maxp) {
            unsigned char c = *(p++);
            if (c != 0) {
                //printf("%c (%d)\n",c,c);fflush(stdout);
                line.append(QChar(c));
            }
        }
        if (p == maxp) break;
        // at terminator
        p++;
        unsigned char a1 = *(p++);
        unsigned char a2 = *(p++);
        //printf("Next: %02x %02x\n",a1,a2);fflush(stdout);
        quint16 next = (((a1&0x10)!=0)?0x2000:0x4000) | ((a1&0x0f)<<8) | a2;
        ui->screen->append(line);
        if (start == next) break;
        start = next;
    }
    ui->screen->update();
    updateMemory();
}
Beispiel #3
0
void MainWindow::connectSim(SimThread *sim)
{
    QObject::connect(ui->startButton,SIGNAL(clicked()),sim,SLOT(simRun()));
    QObject::connect(ui->stopButton,SIGNAL(clicked()),sim,SLOT(simStop()));
    QObject::connect(ui->stepButton,SIGNAL(clicked()),sim,SLOT(simStep()));
    QObject::connect(ui->stepButton,SIGNAL(clicked()),this,SLOT(updateMemory()));
    QObject::connect(ui->setupButton,SIGNAL(clicked()),this,SLOT(doSetup()));
    QObject::connect(this,SIGNAL(kbdKeypress(quint8)),sim,SLOT(keypress(quint8)));
}
Beispiel #4
0
void initMemory(struct SensorModul *sm)
{
    /**
      Make sure that /proc/meminfo exists and is readable. If not we do
      not register any monitors for memory.
     */
    if(updateMemory() < 0)
        return;

    registerMonitor("mem/physical/free", "integer", printMFree, printMFreeInfo, sm);
    registerMonitor("mem/physical/used", "integer", printUsed, printUsedInfo, sm);
    registerMonitor("mem/physical/application", "integer", printAppl, printApplInfo, sm);
    registerMonitor("mem/physical/buf", "integer", printBuffers, printBuffersInfo, sm);
    registerMonitor("mem/physical/cached", "integer", printCached, printCachedInfo, sm);
    registerMonitor("mem/swap/used", "integer", printSwapUsed, printSwapUsedInfo, sm);
    registerMonitor("mem/swap/free", "integer", printSwapFree, printSwapFreeInfo, sm);
}
Beispiel #5
0
ReturnFlag LinkageDE_::run_() {
	ReturnFlag rf = Return_Normal;

#ifdef OFEC_CONSOLE
	if (Global::msp_global->m_runId == 0) {
		mSingleObj::getSingleObj()->setProgrOutputFlag(true);
		if (mMultiModal::getPopInfor())
			mMultiModal::getPopInfor()->setOutProgFlag(true);
	}
#endif // OFEC_CONSOLE

	initilizeMemory();
	initilizeCurPop();

	while (!ifTerminating()) {
		/*g_mutexStream.lock();
		cout<<Global::msp_global->m_runId<<" "<<Global::msp_global->mp_problem->getEvaluations()<<" "<<m_best[0]->obj(0)<<endl;
		g_mutexStream.unlock();*/
		rf = this->evolve();
#ifdef OFEC_DEMON
		vector<Algorithm*> vp;
		vp.push_back(this);
		msp_buffer->updateBuffer_(&vp);
#endif
		if (rf != Return_Normal) handleReturnFlag(rf);

		updateMemory();

#ifdef OFEC_CONSOLE
		if (mMultiModal::getPopInfor()) {
			int peaksf;
			peaksf = CAST_PROBLEM_CONT->getGOpt().getNumGOptFound();
			mMultiModal::getPopInfor()->input(Global::msp_global.get(), Global::msp_global->mp_problem->getEvaluations(), \
				Global::msp_global->m_totalNumIndis, 1, peaksf, \
				CAST_PROBLEM_CONT->getGOpt().getNumOpt(), 0, 0, 0, 0, \
				0, 0, CAST_PROBLEM_CONT->getGOpt().isAllFound());
		}
#endif

		if (rf == Return_Terminate) break;
	}

	return rf;
}
static int update(void* userData, PDUI* uiFuncs, PDReader* inEvents, PDWriter* outEvents)
{
    uint32_t event;

    (void)outEvents;

    HexMemoryData* data = (HexMemoryData*)userData;

    /*
       PDVec2 windowSize = uiFuncs->getWindowSize();
       const float fontHeight = uiFuncs->getFontHeight();
       const float fontWidth = uiFuncs->getFontWidth();

       int drawableLineCount = (int)(windowSize.y / fontHeight);
       int drawableChars = (int)(windowSize.x / fontWidth);
     */

    // Loop over all the in events

    while ((event = PDRead_getEvent(inEvents)) != 0)
    {
        switch (event)
        {
            case PDEventType_setMemory:
            {
                updateMemory(data, inEvents);
                break;
            }
        }
    }

    drawUI(data, uiFuncs);

    /*
       PDWrite_eventBegin(outEvents, PDEventType_getMemory);
       PDWrite_u16(outEvents, "address", 0x6000);
       PDWrite_u16(outEvents, "size", (uint16_t)(drawableLineCount * drawableChars));
       PDWrite_eventEnd(outEvents);
     */

    return 0;
}
Beispiel #7
0
void initMemory( struct SensorModul* sm ) {

	long i = sysconf( _SC_PAGESIZE );

	pageshift = 0;
	while( (i >>= 1) > 0 )
		pageshift++;

	/* calculate an amount to shift to K values */
	/* remember that log base 2 of 1024 is 10 (i.e.: 2^10 = 1024) */
	pageshift -= 10;

	/* now determine which pageshift function is appropriate for the 
	result (have to because x << y is undefined for y < 0) */
	if( pageshift > 0 ) {
		/* this is the most likely */
		p_pagetok = pagetok_left;
	} else if( pageshift == 0 ) {
		p_pagetok = pagetok_none;
	} else {
		p_pagetok = pagetok_right;
		pageshift = -pageshift;
	}

#ifdef HAVE_KSTAT
	registerMonitor( "mem/physical/free", "integer",
					printMemFree, printMemFreeInfo, sm );
	registerMonitor( "mem/physical/used", "integer",
					printMemUsed, printMemUsedInfo, sm );
	registerMonitor( "mem/physical/application", "integer",
					printMemUsed, printMemUsedInfo, sm );
#endif
	registerMonitor( "mem/swap/free", "integer",
					printSwapFree, printSwapFreeInfo, sm );
	registerMonitor( "mem/swap/used", "integer",
					printSwapUsed, printSwapUsedInfo, sm );

	gettimeofday(&lastSampling, 0);
	updateMemory();
	updateSwap(0);
}
/* begin code for insert_into_table ------------------------------------------------------------------------------------------------------------
 The insert_into_table function adds a given word to the tables that should contain it. It does this by allocating tables up to Total_Tables and adding the word to the completions list to them if there is space available. If there is no space available, the function updates TotalWords. There is no return value.
 */
void insert_into_table(const char *word){
    size_t stringLength = strlen(word);//calculate the length of the string using strlen
    int i;//number of the iteration
    Table *pointer = &Root; // pointer to the root of the table
    int index;//the index position that the character will take
    
    for (i = 0; i<Total_Tables && i<stringLength; i++){//the first iteration (i = 0) will point to the root table.
        index = getCharIndex(word[i]);//get the index that the character should go into in the table
        if (index < 0) {//the function getCharIndex will return -1 if the character doesn't fit any index.
#if DEBUG
            printf("Encountered a character, (%c), that cannot be indexed.\n", (char)word[i]);
#endif
            //index = 'z';
            continue;//don't handle the character if it cannot be indexed
        }
        
        if (pointer->nextLevel[index] == NULL){//check to make sure there is not a next level table
            pointer->nextLevel[index] = (struct table*) malloc(sizeof(struct table));//allocate space for the new table
            updateMemory(sizeof(struct table));//add to the total program overhead because of the addition of this table
            *pointer->nextLevel[index] = (struct table){{NULL},{NULL},0};//set the whole table to null values that will be filled in later
        }
Beispiel #9
0
void printSwapUsed( const char *cmd ) {
	if( Dirty )
		updateMemory();
	fprintf(CurrentClient, "%ld\n", totalswap - freeswap );
}
Beispiel #10
0
void printSwapUsedInfo( const char *cmd ) {
	if( Dirty )
		updateMemory();
	fprintf(CurrentClient, "Used Swap\t0\t%ld\tKB\n", totalswap );
}
Beispiel #11
0
void printSwapFree( const char *cmd ) {
	if( Dirty )
		updateMemory();
	fprintf(CurrentClient, "%ld\n", freeswap );
}
Beispiel #12
0
void printMemUsed( const char *cmd ) {
	if( Dirty )
		updateMemory();
	fprintf(CurrentClient, "%ld\n", totalmem - freemem );
}
Beispiel #13
0
void printMemUsedInfo( const char *cmd ) {
	if( Dirty )
		updateMemory();
	fprintf(CurrentClient, "Used Memory\t0\t%ld\tKB\n", totalmem );
}
Beispiel #14
0
void printMemFree( const char *cmd ) {
	if( Dirty )
		updateMemory();
	fprintf(CurrentClient, "%ld\n", freemem );
}
Beispiel #15
0
void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
{
    if(dbgStopped) //there can be no more messages if the debugger stopped = BUG
        __debugbreak();
    switch(type)
    {
    case GUI_DISASSEMBLE_AT:
        emit disassembleAt((int_t)param1, (int_t)param2);
        break;

    case GUI_SET_DEBUG_STATE:
        emit dbgStateChanged((DBGSTATE)(int_t)param1);
        break;

    case GUI_ADD_MSG_TO_LOG:
        emit addMsgToLog(QString((const char*)param1));
        break;

    case GUI_CLEAR_LOG:
        emit clearLog();
        break;

    case GUI_UPDATE_REGISTER_VIEW:
        emit updateRegisters();
        break;

    case GUI_UPDATE_DISASSEMBLY_VIEW:
        emit repaintGui();
        break;

    case GUI_UPDATE_BREAKPOINTS_VIEW:
        emit updateBreakpoints();
        break;

    case GUI_UPDATE_WINDOW_TITLE:
        emit updateWindowTitle(QString((const char*)param1));
        break;

    case GUI_GET_WINDOW_HANDLE:
        return winId;

    case GUI_DUMP_AT:
        emit dumpAt((int_t)param1);
        break;

    case GUI_SCRIPT_ADD:
    {
        BridgeResult result;
        emit scriptAdd((int)param1, (const char**)param2);
        result.Wait();
    }
    break;

    case GUI_SCRIPT_CLEAR:
        emit scriptClear();
        break;

    case GUI_SCRIPT_SETIP:
        emit scriptSetIp((int)param1);
        break;

    case GUI_SCRIPT_ERROR:
    {
        BridgeResult result;
        emit scriptError((int)param1, QString((const char*)param2));
        result.Wait();
    }
    break;

    case GUI_SCRIPT_SETTITLE:
        emit scriptSetTitle(QString((const char*)param1));
        break;

    case GUI_SCRIPT_SETINFOLINE:
        emit scriptSetInfoLine((int)param1, QString((const char*)param2));
        break;

    case GUI_SCRIPT_MESSAGE:
    {
        BridgeResult result;
        emit scriptMessage(QString((const char*)param1));
        result.Wait();
    }
    break;

    case GUI_SCRIPT_MSGYN:
    {
        BridgeResult result;
        emit scriptQuestion(QString((const char*)param1));
        return (void*)result.Wait();
    }
    break;

    case GUI_SCRIPT_ENABLEHIGHLIGHTING:
        emit scriptEnableHighlighting((bool)param1);
        break;

    case GUI_SYMBOL_UPDATE_MODULE_LIST:
        emit updateSymbolList((int)param1, (SYMBOLMODULEINFO*)param2);
        break;

    case GUI_SYMBOL_LOG_ADD:
        emit addMsgToSymbolLog(QString((const char*)param1));
        break;

    case GUI_SYMBOL_LOG_CLEAR:
        emit clearSymbolLog();
        break;

    case GUI_SYMBOL_SET_PROGRESS:
        emit setSymbolProgress((int)param1);
        break;

    case GUI_REF_ADDCOLUMN:
        emit referenceAddColumnAt((int)param1, QString((const char*)param2));
        break;

    case GUI_REF_SETROWCOUNT:
        emit referenceSetRowCount((int_t)param1);
        break;

    case GUI_REF_GETROWCOUNT:
        return (void*)referenceManager->currentReferenceView()->mList->getRowCount();

    case GUI_REF_DELETEALLCOLUMNS:
        GuiReferenceInitialize("References");
        break;

    case GUI_REF_SETCELLCONTENT:
    {
        CELLINFO* info = (CELLINFO*)param1;
        emit referenceSetCellContent(info->row, info->col, QString(info->str));
    }
    break;

    case GUI_REF_GETCELLCONTENT:
        return (void*)referenceManager->currentReferenceView()->mList->getCellContent((int)param1, (int)param2).toUtf8().constData();

    case GUI_REF_RELOADDATA:
        emit referenceReloadData();
        break;

    case GUI_REF_SETSINGLESELECTION:
        emit referenceSetSingleSelection((int)param1, (bool)param2);
        break;

    case GUI_REF_SETPROGRESS:
        emit referenceSetProgress((int)param1);
        break;

    case GUI_REF_SETSEARCHSTARTCOL:
        emit referenceSetSearchStartCol((int)param1);
        break;

    case GUI_REF_INITIALIZE:
    {
        BridgeResult result;
        emit referenceInitialize(QString((const char*)param1));
        result.Wait();
    }
    break;

    case GUI_STACK_DUMP_AT:
        emit stackDumpAt((uint_t)param1, (uint_t)param2);
        break;

    case GUI_UPDATE_DUMP_VIEW:
        emit updateDump();
        break;

    case GUI_UPDATE_THREAD_VIEW:
        emit updateThreads();
        break;

    case GUI_UPDATE_MEMORY_VIEW:
        emit updateMemory();
        break;

    case GUI_ADD_RECENT_FILE:
        emit addRecentFile(QString((const char*)param1));
        break;

    case GUI_SET_LAST_EXCEPTION:
        emit setLastException((unsigned int)param1);
        break;

    case GUI_GET_DISASSEMBLY:
    {
        uint_t parVA = (uint_t)param1;
        char* text = (char*)param2;
        if(!text || !parVA || !DbgIsDebugging())
            return 0;
        byte_t wBuffer[16];
        if(!DbgMemRead(parVA, wBuffer, 16))
            return 0;
        QBeaEngine disasm(-1);
        Instruction_t instr = disasm.DisassembleAt(wBuffer, 16, 0, 0, parVA);
        BeaTokenizer::TokenizeInstruction(&instr.tokens, &instr.disasm, -1);
        QList<RichTextPainter::CustomRichText_t> richText;
        BeaTokenizer::TokenToRichText(&instr.tokens, &richText, 0);
        QString finalInstruction = "";
        for(int i = 0; i < richText.size(); i++)
            finalInstruction += richText.at(i).text;
        strcpy_s(text, GUI_MAX_DISASSEMBLY_SIZE, finalInstruction.toUtf8().constData());
        return (void*)1;
    }
    break;

    case GUI_MENU_ADD:
    {
        BridgeResult result;
        emit menuAddMenu((int)param1, QString((const char*)param2));
        return (void*)result.Wait();
    }
    break;

    case GUI_MENU_ADD_ENTRY:
    {
        BridgeResult result;
        emit menuAddMenuEntry((int)param1, QString((const char*)param2));
        return (void*)result.Wait();
    }
    break;

    case GUI_MENU_ADD_SEPARATOR:
    {
        BridgeResult result;
        emit menuAddSeparator((int)param1);
        result.Wait();
    }
    break;

    case GUI_MENU_CLEAR:
    {
        BridgeResult result;
        emit menuClearMenu((int)param1);
        result.Wait();
    }
    break;

    case GUI_SELECTION_GET:
    {
        int hWindow = (int)param1;
        SELECTIONDATA* selection = (SELECTIONDATA*)param2;
        if(!DbgIsDebugging())
            return (void*)false;
        BridgeResult result;
        switch(hWindow)
        {
        case GUI_DISASSEMBLY:
            emit selectionDisasmGet(selection);
            break;
        case GUI_DUMP:
            emit selectionDumpGet(selection);
            break;
        case GUI_STACK:
            emit selectionStackGet(selection);
            break;
        default:
            return (void*)false;
        }
        result.Wait();
        if(selection->start > selection->end) //swap start and end
        {
            int_t temp = selection->end;
            selection->end = selection->start;
            selection->start = temp;
        }
        return (void*)true;
    }
    break;

    case GUI_SELECTION_SET:
    {
        int hWindow = (int)param1;
        const SELECTIONDATA* selection = (const SELECTIONDATA*)param2;
        if(!DbgIsDebugging())
            return (void*)false;
        BridgeResult result;
        switch(hWindow)
        {
        case GUI_DISASSEMBLY:
            emit selectionDisasmSet(selection);
            break;
        case GUI_DUMP:
            emit selectionDumpSet(selection);
            break;
        case GUI_STACK:
            emit selectionStackSet(selection);
            break;
        default:
            return (void*)false;
        }
        return (void*)result.Wait();
    }
    break;

    case GUI_GETLINE_WINDOW:
    {
        QString text = "";
        BridgeResult result;
        emit getStrWindow(QString((const char*)param1), &text);
        if(result.Wait())
        {
            strcpy_s((char*)param2, GUI_MAX_LINE_SIZE, text.toUtf8().constData());
            return (void*)true;
        }
        return (void*)false; //cancel/escape
    }
    break;

    case GUI_AUTOCOMPLETE_ADDCMD:
        emit autoCompleteAddCmd(QString((const char*)param1));
        break;

    case GUI_AUTOCOMPLETE_DELCMD:
        emit autoCompleteDelCmd(QString((const char*)param1));
        break;

    case GUI_AUTOCOMPLETE_CLEARALL:
        emit autoCompleteClearAll();
        break;

    case GUI_ADD_MSG_TO_STATUSBAR:
        emit addMsgToStatusBar(QString((const char*)param1));
        break;

    case GUI_UPDATE_SIDEBAR:
        emit updateSideBar();
        break;

    case GUI_REPAINT_TABLE_VIEW:
        emit repaintTableView();
        break;

    case GUI_UPDATE_PATCHES:
        emit updatePatches();
        break;

    case GUI_UPDATE_CALLSTACK:
        emit updateCallStack();
        break;

    case GUI_SYMBOL_REFRESH_CURRENT:
        emit symbolRefreshCurrent();
        break;

    case GUI_LOAD_SOURCE_FILE:
        emitLoadSourceFile(QString((const char*)param1), (int)param2);
        break;

    case GUI_MENU_SET_ICON:
    {
        int hMenu = (int)param1;
        const ICONDATA* icon = (const ICONDATA*)param2;
        BridgeResult result;
        if(!icon)
            emit setIconMenu(hMenu, QIcon());
        else
        {
            QImage img;
            img.loadFromData((uchar*)icon->data, icon->size);
            QIcon qIcon(QPixmap::fromImage(img));
            emit setIconMenu(hMenu, qIcon);
        }
        result.Wait();
    }
    break;

    case GUI_MENU_SET_ENTRY_ICON:
    {
        int hEntry = (int)param1;
        const ICONDATA* icon = (const ICONDATA*)param2;
        BridgeResult result;
        if(!icon)
            emit setIconMenuEntry(hEntry, QIcon());
        else
        {
            QImage img;
            img.loadFromData((uchar*)icon->data, icon->size);
            QIcon qIcon(QPixmap::fromImage(img));
            emit setIconMenuEntry(hEntry, qIcon);
        }
        result.Wait();
    }
    break;

    case GUI_SHOW_CPU:
        emit showCpu();
        break;

    case GUI_ADD_QWIDGET_TAB:
        emit addQWidgetTab((QWidget*)param1);
        break;

    case GUI_SHOW_QWIDGET_TAB:
        emit showQWidgetTab((QWidget*)param1);
        break;

    case GUI_CLOSE_QWIDGET_TAB:
        emit closeQWidgetTab((QWidget*)param1);
        break;

    case GUI_EXECUTE_ON_GUI_THREAD:
        GuiAddLogMessage(QString().sprintf("thread id (bridge) %X\n", GetCurrentThreadId()).toUtf8().constData());
        emit executeOnGuiThread(param1);
        break;

    case GUI_UPDATE_TIME_WASTED_COUNTER:
        emit updateTimeWastedCounter();
        break;
    }
    return nullptr;
}
Beispiel #16
0
void printMemFree( const char *cmd ) {
	updateMemory();
	fprintf(CurrentClient, "%lu\n", freemem );
}