void CController::CDebugger::StepOver( ProcID nID ) const
{
	CProcessor* pProcessor = m_pController->GetProcessor( nID );
	SIS_CHECKPTR( pProcessor );
	CProcEvent* pEvent = new CStepOverEvent;
	pProcessor->AddEvent( pEvent );
}
Esempio n. 2
0
void QConsoleView::printConsolePrompt()
{
    CProcessor* pProc = g_pBoard->GetCPU();
    TCHAR buffer[14];
    _sntprintf(buffer, 14, _T("%06o> "), pProc->GetPC());
    this->print(buffer);
}
Esempio n. 3
0
U64 LLFastTimer::countsPerSecond()
{
	if (!sCPUClockFrequency)
	{
		CProcessor proc;
		sCPUClockFrequency = proc.GetCPUFrequency(50);
	}
	return U64(sCPUClockFrequency);
}
Esempio n. 4
0
void DisasmView_SetCurrentProc(BOOL okCPU)
{
    m_okDisasmProcessor = okCPU;
    CProcessor* pDisasmPU = (m_okDisasmProcessor) ? g_pBoard->GetCPU() : g_pBoard->GetPPU();
    ASSERT(pDisasmPU != NULL);
    m_wDisasmBaseAddr = pDisasmPU->GetPC();
    InvalidateRect(m_hwndDisasmViewer, NULL, TRUE);
    DisasmView_UpdateWindowText();
}
Esempio n. 5
0
void PrintConsolePrompt()
{
    CProcessor* pProc = ConsoleView_GetCurrentProcessor();
    TCHAR bufferAddr[7];
    PrintOctalValue(bufferAddr, pProc->GetPC());
    TCHAR buffer[14];
    wsprintf(buffer, _T("%s> "), bufferAddr);
    ::SetWindowText(m_hwndConsolePrompt, buffer);
}
Esempio n. 6
0
void DebugView_UpdateWindowText()
{
    CProcessor* pDebugPU = (m_okDebugProcessor) ? g_pBoard->GetCPU() : g_pBoard->GetPPU();
    ASSERT(pDebugPU != NULL);
    LPCTSTR sProcName = pDebugPU->GetName();

    TCHAR buffer[64];
    _stprintf_s(buffer, 64, _T("Debug - %s"), sProcName);
    ::SetWindowText(g_hwndDebug, buffer);
}
void CController::CDebugger::Stop( ProcID nID ) const
{
	if ( -1 == nID )
		StopAll();

	CProcessor* pProcessor = m_pController->GetProcessor( nID );
	SIS_CHECKPTR( pProcessor );
	CProcEvent* pEvent = new CBreakEvent;
	pProcessor->AddEvent( pEvent );
}
Esempio n. 8
0
int QConsoleView::printDisassemble(WORD address, BOOL okOneInstr, BOOL okShort)
{
    CProcessor* pProc = g_pBoard->GetCPU();
    BOOL okHaltMode = pProc->IsHaltMode();

    const int nWindowSize = 30;
    WORD memory[nWindowSize + 2];
    int addrtype;
    for (int i = 0; i < nWindowSize + 2; i++)
        memory[i] = g_pBoard->GetWordView(address + i*2, okHaltMode, TRUE, &addrtype);

    TCHAR bufaddr[7];
    TCHAR bufvalue[7];
    TCHAR buffer[64];

    int lastLength = 0;
    int length = 0;
    for (int index = 0; index < nWindowSize; index++) {  // –исуем строки
        PrintOctalValue(bufaddr, address);
        WORD value = memory[index];
        PrintOctalValue(bufvalue, value);

        if (length > 0)
        {
            if (!okShort)
            {
                _sntprintf(buffer, 64, _T("  %s  %s\r\n"), bufaddr, bufvalue);
                this->print(buffer);
            }
        }
        else
        {
            if (okOneInstr && index > 0)
                break;
            TCHAR instr[8];
            TCHAR args[32];
            length = DisassembleInstruction(memory + index, address, instr, args);
            lastLength = length;
            if (index + length > nWindowSize)
                break;
            if (okShort)
                _sntprintf(buffer, 64, _T("  %s  %-7s %s\r\n"), bufaddr, instr, args);
            else
                _sntprintf(buffer, 64, _T("  %s  %s  %-7s %s\r\n"), bufaddr, bufvalue, instr, args);
            this->print(buffer);
        }
        length--;
        address += 2;
    }

    return lastLength;
}
Esempio n. 9
0
//-----------------------------------------------------------------------------//
// 실행되고 있는 프로세서의 자식으로 프로세서가 동작한다.
// 즉 자식 프로세서가 종료되면 부모 프로세서로 권한이 바뀌게 된다는 의미이다.
// pStack: 부모 프로세서가 저장된 스택
// pFileName : 실행될 스크립트 파일명
// callback : 콜백함수
// pArgument : 실행인자 
//-----------------------------------------------------------------------------//
BOOL CMachine::ExecuteScriptChild( ProcStack *pStack, char *pFileName, 
								  void callback (int,ns_script::CProcessor*), char *pArgument )
{
	CProcessor *proc = new CProcessor;
	if( !proc->ExecuteScript(this, pFileName, callback, pArgument) )
	{
		delete proc;
		return FALSE;
	}

	pStack->push( proc );
	return TRUE;
}
Esempio n. 10
0
void DisasmView_UpdateWindowText()
{
    CProcessor* pDisasmPU = (m_okDisasmProcessor) ? g_pBoard->GetCPU() : g_pBoard->GetPPU();
    ASSERT(pDisasmPU != NULL);
    LPCTSTR sProcName = pDisasmPU->GetName();

    TCHAR buffer[64];
    if (m_okDisasmSubtitles)
        _stprintf_s(buffer, 64, _T("Disassemble - %s - Subtitles"), sProcName);
    else
        _stprintf_s(buffer, 64, _T("Disassemble - %s"), sProcName);
    ::SetWindowText(g_hwndDisasm, buffer);
}
Esempio n. 11
0
void QDebugView::updateData()
{
    CProcessor* pCPU = g_pBoard->GetCPU();
    ASSERT(pCPU != NULL);

    // Get new register values and set change flags
    for (int r = 0; r < 8; r++) {
        WORD value = pCPU->GetReg(r);
        m_okDebugCpuRChanged[r] = (m_wDebugCpuR[r] != value);
        m_wDebugCpuR[r] = value;
    }
    WORD pswCPU = pCPU->GetPSW();
    m_okDebugCpuRChanged[8] = (m_wDebugCpuR[8] != pswCPU);
    m_wDebugCpuR[8] = pswCPU;
}
Esempio n. 12
0
none_ COptUnregister::work(const TMessageUnit *tmu) {
    v_ *category = _category->value(tmu);
    v_ *key      = _key->value(tmu);

    if (!category || !key) {
        assert(0);
        // TODO do something to tell outside
        return;
    }

    if (STR != category->getType() || STR != key->getType()) {
        assert(0);
        // TODO do something to tell outside
        return;
    }

    v_ *object = CRegister::instance()->searchItem((const ch_1 *) *category,
            (const ch_1 *) *key);

    if (null_v != object) {
        if (OBJ == object->getType()) {
            obj_       obj        = (obj_) (*object);
            CProcessor *processor = (CProcessor *) obj;

            if (!processor) {
                assert(0);
                // TODO do something to tell outside
                return;
            }

            if (0 != processor->unregisterItem((const ch_1 *) *category,
                    (const ch_1 *) *key)) {
                assert(0);
                // TODO do something to tell outside
            }
        } else {
            if (0 !=
                    CRegister::instance()->unregisterItem(
                            (const ch_1 *) *category, (const ch_1 *) *key)) {
                assert(0);
                // TODO do something to tell outside
            }
        }
    } else {
        assert(0);
        // TODO do something to tell outside
    }
}
Esempio n. 13
0
void QConsoleView::printMemoryDump(WORD address, int lines)
{
    CProcessor* pProc = g_pBoard->GetCPU();

    address &= ~1;  // Line up to even address

    BOOL okHaltMode = pProc->IsHaltMode();

    for (int line = 0; line < lines; line++)
    {
        WORD dump[8];
        for (int i = 0; i < 8; i++)
            dump[i] = g_pBoard->GetWord(address + i*2, okHaltMode);

        TCHAR buffer[2+6+2 + 7*8 + 1 + 16 + 1 + 2];
        TCHAR* pBuf = buffer;
        *pBuf = _T(' ');  pBuf++;
        *pBuf = _T(' ');  pBuf++;
        PrintOctalValue(pBuf, address);  pBuf += 6;
        *pBuf = _T(' ');  pBuf++;
        *pBuf = _T(' ');  pBuf++;
        for (int i = 0; i < 8; i++) {
            PrintOctalValue(pBuf, dump[i]);  pBuf += 6;
            *pBuf = _T(' ');  pBuf++;
        }
        *pBuf = _T(' ');  pBuf++;
//        for (int i = 0; i < 8; i++) {
//            WORD word = dump[i];
//            BYTE ch1 = LOBYTE(word);
//            TCHAR wch1 = Translate_BK_Unicode(ch1);
//            if (ch1 < 32) wch1 = _T('Ј');
//            *pBuf = wch1;  pBuf++;
//            BYTE ch2 = HIBYTE(word);
//            TCHAR wch2 = Translate_BK_Unicode(ch2);
//            if (ch2 < 32) wch2 = _T('Ј');
//            *pBuf = wch2;  pBuf++;
//        }
        *pBuf++ = _T('\r');
        *pBuf++ = _T('\n');
        *pBuf = 0;

        this->print(buffer);

        address += 16;
    }
}
Esempio n. 14
0
// Update after Run or Step
void DebugView_OnUpdate()
{
    CProcessor* pCPU = g_pBoard->GetCPU();
    ASSERT(pCPU != NULL);

    // Get new register values and set change flags
    for (int r = 0; r < 8; r++)
    {
        WORD value = pCPU->GetReg(r);
        m_okDebugCpuRChanged[r] = (m_wDebugCpuR[r] != value);
        m_wDebugCpuR[r] = value;
    }
    WORD pswCPU = pCPU->GetPSW();
    m_okDebugCpuRChanged[8] = (m_wDebugCpuR[8] != pswCPU);
    m_wDebugCpuR[8] = pswCPU;
    WORD cpcCPU = pCPU->GetCPC();
    m_okDebugCpuRChanged[9] = (m_wDebugCpuR[9] != cpcCPU);
    m_wDebugCpuR[9] = cpcCPU;
    WORD cpswCPU = pCPU->GetCPSW();
    m_okDebugCpuRChanged[10] = (m_wDebugCpuR[10] != cpswCPU);
    m_wDebugCpuR[10] = cpswCPU;

    CProcessor* pPPU = g_pBoard->GetPPU();
    ASSERT(pPPU != NULL);

    // Get new register values and set change flags
    for (int r = 0; r < 8; r++)
    {
        WORD value = pPPU->GetReg(r);
        m_okDebugPpuRChanged[r] = (m_wDebugPpuR[r] != value);
        m_wDebugPpuR[r] = value;
    }
    WORD pswPPU = pPPU->GetPSW();
    m_okDebugPpuRChanged[8] = (m_wDebugPpuR[8] != pswPPU);
    m_wDebugPpuR[8] = pswPPU;
    WORD cpcPPU = pPPU->GetCPC();
    m_okDebugPpuRChanged[9] = (m_wDebugPpuR[9] != cpcPPU);
    m_wDebugPpuR[9] = cpcPPU;
    WORD cpswPPU = pPPU->GetCPSW();
    m_okDebugPpuRChanged[10] = (m_wDebugPpuR[10] != cpswPPU);
    m_wDebugPpuR[10] = cpswPPU;
}
Esempio n. 15
0
void LLCPUInfo::stream(std::ostream& s) const
{
#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS
	// gather machine information.
	char proc_buf[CPUINFO_BUFFER_SIZE];		/* Flawfinder: ignore */
	CProcessor proc;
	if(proc.CPUInfoToText(proc_buf, CPUINFO_BUFFER_SIZE))
	{
		s << proc_buf;
	}
	else
	{
		s << "Unable to collect processor information" << std::endl;
	}
#else
	// *NOTE: This works on linux. What will it do on other systems?
	LLFILE* cpuinfo = LLFile::fopen(CPUINFO_FILE, "rb");
	if(cpuinfo)
	{
		char line[MAX_STRING];
		memset(line, 0, MAX_STRING);
		while(fgets(line, MAX_STRING, cpuinfo))
		{
			line[strlen(line)-1] = ' ';
			s << line;
		}
		fclose(cpuinfo);
		s << std::endl;
	}
	else
	{
		s << "Unable to collect processor information" << std::endl;
	}
#endif
	// These are interesting as they reflect our internal view of the
	// CPU's attributes regardless of platform
	s << "->mHasSSE:     " << (U32)mHasSSE << std::endl;
	s << "->mHasSSE2:    " << (U32)mHasSSE2 << std::endl;
	s << "->mHasAltivec: " << (U32)mHasAltivec << std::endl;
	s << "->mCPUMhz:     " << mCPUMhz << std::endl;
	s << "->mCPUString:  " << mCPUString << std::endl;
}
Esempio n. 16
0
void CDecoder::Close()
{
    CSingleLock lock(m_section);
    SAFE_RELEASE(m_decoder);
    SAFE_RELEASE(m_service);
    SAFE_RELEASE(m_processor);
    for(unsigned i = 0; i < m_buffer_count; i++)
        m_buffer[i].Clear();
    m_buffer_count = 0;
    memset(&m_format, 0, sizeof(m_format));
    CProcessor* proc = m_processor;
    m_processor = NULL;
    lock.Leave();

    if(proc)
    {
        CSingleExit leave(m_section);
        proc->Release();
    }
}
Esempio n. 17
0
void DebugView_DoDraw(HDC hdc)
{
    ASSERT(g_pBoard != NULL);

    // Create and select font
    HFONT hFont = CreateMonospacedFont();
    HGDIOBJ hOldFont = SelectObject(hdc, hFont);
    int cxChar, cyLine;  GetFontWidthAndHeight(hdc, &cxChar, &cyLine);
    COLORREF colorOld = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
    COLORREF colorBkOld = SetBkColor(hdc, GetSysColor(COLOR_WINDOW));

    CProcessor* pDebugPU = (m_okDebugProcessor) ? g_pBoard->GetCPU() : g_pBoard->GetPPU();
    ASSERT(pDebugPU != NULL);
    WORD* arrR = (m_okDebugProcessor) ? m_wDebugCpuR : m_wDebugPpuR;
    BOOL* arrRChanged = (m_okDebugProcessor) ? m_okDebugCpuRChanged : m_okDebugPpuRChanged;

    //LPCTSTR sProcName = pDebugPU->GetName();
    //TextOut(hdc, cxChar * 1, 2 + 1 * cyLine, sProcName, 3);

    DebugView_DrawProcessor(hdc, pDebugPU, 30 + cxChar * 2, 2 + 1 * cyLine, arrR, arrRChanged);

    // Draw stack for the current processor
    DebugView_DrawMemoryForRegister(hdc, 6, pDebugPU, 30 + 35 * cxChar, 2 + 0 * cyLine);

    CMemoryController* pDebugMemCtl = pDebugPU->GetMemoryController();
    DebugView_DrawPorts(hdc, m_okDebugProcessor, pDebugMemCtl, g_pBoard, 30 + 57 * cxChar, 2 + 0 * cyLine);

    //DebugView_DrawChannels(hdc, 75 * cxChar, 2 + 0 * cyLine);

    SetTextColor(hdc, colorOld);
    SetBkColor(hdc, colorBkOld);
    SelectObject(hdc, hOldFont);
    DeleteObject(hFont);

    if (::GetFocus() == m_hwndDebugViewer)
    {
        RECT rcClient;
        GetClientRect(m_hwndDebugViewer, &rcClient);
        DrawFocusRect(hdc, &rcClient);
    }
}
Esempio n. 18
0
//-----------------------------------------------------------------------------//
// Processor 실행
// return value : -2 = NotRun
//				  -1 = Success
//				   0 = Halt 0	Normal End
//				   1 = Halt 1	ScriptEnd
//				   2 = Halt 2	ScriptExit
//				   3 = New Execute Script
//-----------------------------------------------------------------------------//
int CMachine::Run()
{
	if( m_ProcList.empty() ) return -2;

	ProcList::iterator it = m_ProcList.begin();
	while( m_ProcList.end() != it )
	{
		ProcStack *st = *it;
		//int result = st->top()->Run();

		CProcessor *p = st->top();
		int result = p->Run();

		if( 0 <= result )
		{
			// ScriptEnd, Normal End
			if( 0 == result || 1 == result )
			{
				CProcessor *p = st->top(); st->pop();
				delete p;
				if( st->empty() ) delete st;
				it = m_ProcList.erase( it );				
			}
			// ScriptExit
			else if( 2 == result )
			{
				Clear();
			}
			// New ExecuteScript
			else if( 3 == result )
			{
				CProcessor *proc = st->top();
				ExecuteScriptChild( st, proc->GetArgumentStr(0), proc->m_pCallFunc, NULL );
			}
		}
		++it;
	}

	return -1;
}
Esempio n. 19
0
void DoConsoleCommand()
{
    // Get command text
    TCHAR command[32];
    GetWindowText(m_hwndConsoleEdit, command, 32);
    SendMessage(m_hwndConsoleEdit, WM_SETTEXT, 0, (LPARAM) _T(""));  // Clear command

    if (command[0] == 0) return;  // Nothing to do

    // Echo command to the log
    TCHAR buffer[36];
    ::GetWindowText(m_hwndConsolePrompt, buffer, 14);
    ConsoleView_Print(buffer);
    wsprintf(buffer, _T(" %s\r\n"), command);
    ConsoleView_Print(buffer);

    BOOL okUpdateAllViews = FALSE;  // Flag - need to update all debug views
    CProcessor* pProc = ConsoleView_GetCurrentProcessor();

    // Execute the command
    switch (command[0])
    {
    case _T('h'):
        ConsoleView_ShowHelp();
        break;
    case _T('c'):  // Clear log
        ClearConsole();
        break;
    case _T('r'):  // Register operations
        if (command[1] == 0)  // Print all registers
        {
            for (int r = 0; r < 8; r++)
            {
                LPCTSTR name = REGISTER_NAME[r];
                WORD value = pProc->GetReg(r);
                PrintRegister(name, value);
            }
            PrintRegister(_T("PS"), pProc->GetPSW());
        }
        else if (command[1] >= _T('0') && command[1] <= _T('7'))  // "r0".."r7"
        {
            int r = command[1] - _T('0');
            LPCTSTR name = REGISTER_NAME[r];
            if (command[2] == 0)  // "rN" - show register N
            {
                WORD value = pProc->GetReg(r);
                PrintRegister(name, value);
            }
            else if (command[2] == _T('=') || command[2] == _T(' '))  // "rN=XXXXXX" - set register N to value XXXXXX
            {
                WORD value;
                if (! ParseOctalValue(command + 3, &value))
                    ConsoleView_Print(MESSAGE_WRONG_VALUE);
                else
                {
                    pProc->SetReg(r, value);
                    PrintRegister(name, value);
                    okUpdateAllViews = TRUE;
                }
            }
            else
                ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND);
        }
        else if (command[1] == _T('p') && command[2] == _T('s'))  // "rps"
        {
            if (command[3] == 0)  // "rps" - show PSW
            {
                WORD value = pProc->GetPSW();
                PrintRegister(_T("PS"), value);
            }
            else if (command[3] == _T('=') || command[3] == _T(' '))  // "rps=XXXXXX" - set PSW to value XXXXXX
            {
                WORD value;
                if (! ParseOctalValue(command + 4, &value))
                    ConsoleView_Print(MESSAGE_WRONG_VALUE);
                else
                {
                    pProc->SetPSW(value);
                    PrintRegister(_T("PS"), value);
                    okUpdateAllViews = TRUE;
                }
            }
            else
                ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND);
        }
        else
            ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND);
        break;
    case _T('s'):  // Step
        if (command[1] == 0)  // "s" - Step Into, execute one instruction
        {
            PrintDisassemble(pProc, pProc->GetPC(), TRUE, FALSE);
            //pProc->Execute();

            g_pBoard->DebugTicks();

            okUpdateAllViews = TRUE;
        }
        else if (command[1] == _T('o'))  // "so" - Step Over
        {
            int instrLength = PrintDisassemble(pProc, pProc->GetPC(), TRUE, FALSE);
            WORD bpaddress = (WORD)(pProc->GetPC() + instrLength * 2);

            Emulator_SetCPUBreakpoint(bpaddress);
            Emulator_Start();
        }
        break;
    case _T('d'):  // Disassemble
    case _T('D'):  // Disassemble, short format
        {
            BOOL okShort = (command[0] == _T('D'));
            if (command[1] == 0)  // "d" - disassemble at current address
                PrintDisassemble(pProc, pProc->GetPC(), FALSE, okShort);
            else if (command[1] >= _T('0') && command[1] <= _T('7'))  // "dXXXXXX" - disassemble at address XXXXXX
            {
                WORD value;
                if (! ParseOctalValue(command + 1, &value))
                    ConsoleView_Print(MESSAGE_WRONG_VALUE);
                else
                {
                    PrintDisassemble(pProc, value, FALSE, okShort);
                }
            }
            else
                ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND);
        }
        break;
    case _T('u'):
        SaveMemoryDump(pProc);
        break;
    case _T('m'):
        if (command[1] == 0)  // "m" - dump memory at current address
        {
            PrintMemoryDump(pProc, pProc->GetPC(), 8);
        }
        else if (command[1] >= _T('0') && command[1] <= _T('7'))  // "mXXXXXX" - dump memory at address XXXXXX
        {
            WORD value;
            if (! ParseOctalValue(command + 1, &value))
                ConsoleView_Print(MESSAGE_WRONG_VALUE);
            else
            {
                PrintMemoryDump(pProc, value, 8);
            }
        }
        else if (command[1] == _T('r') &&
                command[2] >= _T('0') && command[2] <= _T('7'))  // "mrN" - dump memory at address from register N
        {
            int r = command[2] - _T('0');
            WORD address = pProc->GetReg(r);
            PrintMemoryDump(pProc, address, 8);
        }
        else if (command[1] == _T('o'))
        {
            ConsoleView_GotoMonitor();
        }
        else
            ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND);
        break;
        //TODO: "mXXXXXX YYYYYY" - set memory cell at XXXXXX to value YYYYYY
        //TODO: "mrN YYYYYY" - set memory cell at address from rN to value YYYYYY
    case _T('g'):
        if (command[1] == 0)
        {
            Emulator_Start();
        }
        else
        {
            WORD value;
            if (! ParseOctalValue(command + 1, &value))
                ConsoleView_Print(MESSAGE_WRONG_VALUE);
            else
            {
                Emulator_SetCPUBreakpoint(value);
                Emulator_Start();
            }
        }
        break;
#if !defined(PRODUCT)
    case _T('t'):
        {
            BOOL okTrace = !g_pBoard->GetTrace();
            g_pBoard->SetTrace(okTrace);
            if (okTrace)
                ConsoleView_Print(_T("  Trace is ON.\r\n"));
            else
            {
                ConsoleView_Print(_T("  Trace is OFF.\r\n"));
                DebugLogCloseFile();
            }
        }
        break;
#endif
    default:
        ConsoleView_Print(MESSAGE_UNKNOWN_COMMAND);
        break;
    }

    PrintConsolePrompt();

    if (okUpdateAllViews)
    {
        MainWindow_UpdateAllViews();
    }
}
Esempio n. 20
0
void QMemoryView::paintEvent(QPaintEvent * /*event*/)
{
    if (g_pBoard == NULL) return;

    QPainter painter(this);
    painter.fillRect(0,0, this->width(), this->height(), Qt::white);

    QFont font = Common_GetMonospacedFont();
    painter.setFont(font);
    QFontMetrics fontmetrics(font);
    int cxChar = fontmetrics.averageCharWidth();
    int cyLine = fontmetrics.height();

    CProcessor* pDebugPU = g_pBoard->GetCPU();
    ASSERT(pDebugPU != NULL);

    QColor colorText = painter.pen().color();

    m_cyLineMemory = cyLine;

    TCHAR buffer[7];
    const TCHAR* ADDRESS_LINE = _T(" address  0      2      4      6      10     12     14     16");
    painter.drawText(0, cyLine, ADDRESS_LINE);

    // Calculate m_nPageSize
    m_nPageSize = this->height() / cyLine - 1;

    quint16 address = m_wBaseAddress;
    int y = 2 * cyLine;
    for (;;) {  // Draw lines
        DrawOctalValue(painter, 2 * cxChar, y, address);

        int x = 10 * cxChar;
        ushort wchars[16];

        for (int j = 0; j < 8; j++) {  // Draw words as octal value
            // Get word from memory
            quint16 word = 0;
            int addrtype;
            bool okHalt = false;
            quint16 wChanged = 0;

            okHalt = pDebugPU->IsHaltMode();
            word = g_pBoard->GetWordView(address, okHalt, false, &addrtype);
            wChanged = Emulator_GetChangeRamStatus(address);

            if ((addrtype & (ADDRTYPE_IO | ADDRTYPE_DENY)) == 0)
            {
                painter.setPen(wChanged != 0 ? Qt::red : colorText);
                if (m_ByteMode)
                {
                    PrintOctalValue(buffer, (word & 0xff));
                    painter.drawText(x, y, buffer + 3);
                    PrintOctalValue(buffer, (word >> 8));
                    painter.drawText(x + 3 * cxChar + cxChar / 2, y, buffer + 3);
                }
                else
                    DrawOctalValue(painter, x, y, word);
            }

            // Prepare characters to draw at right
            quint8 ch1 = (quint8)(word & 0xff); // LOBYTE
            ushort wch1 = Translate_BK_Unicode(ch1);
            if (ch1 < 32) wch1 = 0x00b7;
            wchars[j * 2] = wch1;
            quint8 ch2 = (quint8)((word >> 8) & 0xff); // HIBYTE
            ushort wch2 = Translate_BK_Unicode(ch2);
            if (ch2 < 32) wch2 = 0x00b7;
            wchars[j * 2 + 1] = wch2;

            address += 2;
            x += 7 * cxChar;
        }
Esempio n. 21
0
// Update after Run or Step
void DisasmView_OnUpdate()
{
    CProcessor* pDisasmPU = (m_okDisasmProcessor) ? g_pBoard->GetCPU() : g_pBoard->GetPPU();
    ASSERT(pDisasmPU != NULL);
    m_wDisasmBaseAddr = pDisasmPU->GetPC();
}
Esempio n. 22
0
LLCPUInfo::LLCPUInfo()
{
	std::ostringstream out;
	CProcessor proc;
	const ProcessorInfo* info = proc.GetCPUInfo();
	// proc.WriteInfoTextFile("procInfo.txt");
	mHasSSE = info->_Ext.SSE_StreamingSIMD_Extensions;
	mHasSSE2 = info->_Ext.SSE2_StreamingSIMD2_Extensions;
	mHasAltivec = info->_Ext.Altivec_Extensions;
	mCPUMhz = (S32)(proc.GetCPUFrequency(50)/1000000.0);
	mFamily.assign( info->strFamily );
	mCPUString = "Unknown";

#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS
	out << proc.strCPUName;
	if (200 < mCPUMhz && mCPUMhz < 10000)           // *NOTE: cpu speed is often way wrong, do a sanity check
	{
		out << " (" << mCPUMhz << " MHz)";
	}
	mCPUString = out.str();
	
#elif LL_LINUX
	std::map< std::string, std::string > cpuinfo;
	LLFILE* cpuinfo_fp = LLFile::fopen(CPUINFO_FILE, "rb");
	if(cpuinfo_fp)
	{
		char line[MAX_STRING];
		memset(line, 0, MAX_STRING);
		while(fgets(line, MAX_STRING, cpuinfo_fp))
		{
			// /proc/cpuinfo on Linux looks like:
			// name\t*: value\n
			char* tabspot = strchr( line, '\t' );
			if (tabspot == NULL)
				continue;
			char* colspot = strchr( tabspot, ':' );
			if (colspot == NULL)
				continue;
			char* spacespot = strchr( colspot, ' ' );
			if (spacespot == NULL)
				continue;
			char* nlspot = strchr( line, '\n' );
			if (nlspot == NULL)
				nlspot = line + strlen( line ); // Fallback to terminating NUL
			std::string linename( line, tabspot );
			std::string llinename(linename);
			LLStringUtil::toLower(llinename);
			std::string lineval( spacespot + 1, nlspot );
			cpuinfo[ llinename ] = lineval;
		}
		fclose(cpuinfo_fp);
	}
# if LL_X86
	std::string flags = " " + cpuinfo["flags"] + " ";
	LLStringUtil::toLower(flags);
	mHasSSE = ( flags.find( " sse " ) != std::string::npos );
	mHasSSE2 = ( flags.find( " sse2 " ) != std::string::npos );
	
	F64 mhz;
	if (LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhz)
	    && 200.0 < mhz && mhz < 10000.0)
	{
		mCPUMhz = (S32)llrint(mhz);
	}
	if (!cpuinfo["model name"].empty())
		mCPUString = cpuinfo["model name"];
# endif // LL_X86
#endif // LL_LINUX
}
Esempio n. 23
0
void QConsoleView::execConsoleCommand(const QString &command)
{
    if (command.isNull() || command.isEmpty()) return;  // Nothing to do
    if (g_okEmulatorRunning) return;

    // Echo command to the log
    this->printLine(command);

    BOOL okUpdateAllViews = FALSE;  // Flag - need to update all debug views
    BOOL okUpdateMenu = FALSE;  // Flag - need to update main menu
    CProcessor* pProc = g_pBoard->GetCPU();

    // Execute the command
    if (command == _T("h"))
    {
        this->printHelp();
    }
    else if (command == _T("c"))  // Clear log
    {
        this->clear();
    }
    else if (command.startsWith(_T("r")))  // Register operations
    {
        if (command.length() == 1)  // Print all registers
        {
            for (int r = 0; r < 8; r++)
            {
                LPCTSTR name = REGISTER_NAME[r];
                WORD value = pProc->GetReg(r);
                this->printRegister(name, value);
            }
        }
        else if (command[1].toAscii() >= '0' && command[1].toAscii() <= '7')  // "r0".."r7"
        {
            int r = command[1].toAscii() - '0';
            LPCTSTR name = REGISTER_NAME[r];
            if (command.length() == 2)  // "rN" - show register N
            {
                WORD value = pProc->GetReg(r);
                this->printRegister(name, value);
            }
            else if (command[2].toAscii() == '=' || command[2].toAscii() == ' ')  // "rN=XXXXXX" - set register N to value XXXXXX
            {
                WORD value;
                if (! ParseOctalValue(command.mid(3), &value))
                    this->print(MESSAGE_WRONG_VALUE);
                else
                {
                    pProc->SetReg(r, value);
                    this->printRegister(name, value);
                    okUpdateAllViews = TRUE;
                }
            }
            else
                this->print(MESSAGE_UNKNOWN_COMMAND);
        }
        else if (command.length() >= 2 && command[1].toAscii() == 'p' && command[2].toAscii() == 's')  // "rps"
        {
            if (command.length() == 2)  // "rps" - show PSW
            {
                WORD value = pProc->GetPSW();
                this->printRegister(_T("PS"), value);
            }
            else if (command[3].toAscii() == '=' || command[3].toAscii() == ' ')  // "rps=XXXXXX" - set PSW to value XXXXXX
            {
                WORD value;
                if (! ParseOctalValue(command.mid(4), &value))
                    this->print(MESSAGE_WRONG_VALUE);
                else
                {
                    pProc->SetPSW(value);
                    this->printRegister(_T("PS"), value);
                    okUpdateAllViews = TRUE;
                }
            }
            else
                this->print(MESSAGE_UNKNOWN_COMMAND);
        }
        else
            this->print(MESSAGE_UNKNOWN_COMMAND);
    }
    else if (command == _T("s"))  // "s" - Step Into, execute one instruction
    {
        this->printDisassemble(pProc->GetPC(), TRUE, FALSE);

        //pProc->Execute();
        g_pBoard->DebugTicks();

        okUpdateAllViews = TRUE;
    }
    else if (command == _T("so"))  // "so" - Step Over
    {
        int instrLength = this->printDisassemble(pProc->GetPC(), TRUE, FALSE);
        WORD bpaddress = pProc->GetPC() + instrLength * 2;

        Emulator_SetCPUBreakpoint(bpaddress);
        Emulator_Start();

        okUpdateMenu = TRUE;
    }
    else if (command.startsWith(_T("d")) ||  // Disassemble
             command.startsWith(_T("D")))    // Disassemble, short format
    {
        BOOL okShort = (command[0] == _T('D'));
        if (command.length() == 1)  // "d" - disassemble at current address
            this->printDisassemble(pProc->GetPC(), FALSE, okShort);
        else if (command[1].toAscii() >= '0' && command[1].toAscii() <= '7')  // "dXXXXXX" - disassemble at address XXXXXX
        {
            WORD value;
            if (! ParseOctalValue(command.mid(1), &value))
                this->print(MESSAGE_WRONG_VALUE);
            else
                this->printDisassemble(value, FALSE, okShort);
        }
        else
            this->print(MESSAGE_UNKNOWN_COMMAND);
    }
    else if (command.startsWith(_T("m")))
    {
        if (command.length() == 1)  // "m" - dump memory at current address
        {
            this->printMemoryDump(pProc->GetPC(), 8);
        }
        else if (command[1].toAscii() >= '0' && command[1].toAscii() <= '7')  // "mXXXXXX" - dump memory at address XXXXXX
        {
            WORD value;
            if (! ParseOctalValue(command.mid(1), &value))
                this->print(MESSAGE_WRONG_VALUE);
            else
                this->printMemoryDump(value, 8);
        }
        else if (command[1].toAscii() == 'r' && command.length() >= 3 &&
                command[2].toAscii() >= '0' && command[2].toAscii() <= '7')  // "mrN" - dump memory at address from register N
        {
            int r = command[2].toAscii() - '0';
            WORD address = pProc->GetReg(r);
            this->printMemoryDump(address, 8);
        }
        else
            this->print(MESSAGE_UNKNOWN_COMMAND);
        //TODO: "mXXXXXX YYYYYY" - set memory cell at XXXXXX to value YYYYYY
        //TODO: "mrN YYYYYY" - set memory cell at address from rN to value YYYYYY
    }
    else if (command == _T("g"))  // Go
    {
        Emulator_Start();
        okUpdateAllViews = TRUE;
    }
    else if (command.startsWith(_T("g")))  // Go
    {
        WORD value;
        if (! ParseOctalValue(command.mid(1), &value))
            this->print(MESSAGE_WRONG_VALUE);
        else
        {
            Emulator_SetCPUBreakpoint(value);
            Emulator_Start();

            okUpdateMenu = TRUE;
        }
    }
    else
    {
        this->print(MESSAGE_UNKNOWN_COMMAND);
    }

    this->printConsolePrompt();

    if (okUpdateAllViews)
        Global_UpdateAllViews();
    else if (okUpdateMenu)
        Global_UpdateMenu();

}