Esempio n. 1
0
void CTLB::RecordDifference( CLog &LogFile, const CTLB& rTLB)
{
	for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++)
	{
		if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) 
		{
			LogFile.LogF("TLB[%d] Defined: %s %s\r\n",i,m_tlb[i].EntryDefined ? "Yes" : "No",rTLB.m_tlb[i].EntryDefined ? "Yes" : "No");
			continue;
		}
		if (!m_tlb[i].EntryDefined)
		{
			continue;
		}
		if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value)
		{
			LogFile.LogF("TLB[%d] PageMask: %X %X\r\n",i,m_tlb[i].PageMask.Value,rTLB.m_tlb[i].PageMask.Value);
		}
		if (m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value)
		{
			LogFile.LogF("TLB[%d] EntryHi: %X %X\r\n",i,m_tlb[i].EntryHi.Value,rTLB.m_tlb[i].EntryHi.Value);
		}
		if (m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value)
		{
			LogFile.LogF("TLB[%d] EntryLo0: %X %X\r\n",i,m_tlb[i].EntryLo0.Value,rTLB.m_tlb[i].EntryLo0.Value);
		}
		if (m_tlb[i].EntryLo1.Value != rTLB.m_tlb[i].EntryLo1.Value)
		{
			LogFile.LogF("TLB[%d] EntryLo1: %X %X\r\n",i,m_tlb[i].EntryLo1.Value,rTLB.m_tlb[i].EntryLo1.Value);
		}
	}
}
Esempio n. 2
0
bool CDumpMemory::DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/)
{
    switch (Format)
    {
    case DisassemblyWithPC:
    {
        CLog LogFile;
        if (!LogFile.Open(FileName))
        {
            g_Notify->DisplayError(stdstr_f("Failed to open\n%s", FileName).c_str());
            return false;
        }
        LogFile.SetFlush(false);
        LogFile.SetTruncateFile(false);
        g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
        char Command[200];
        for (COpcode OpCode(StartPC);  OpCode.PC() < EndPC; OpCode.Next())
        {
            const char * szOpName = OpCode.OpcodeName();
            OpCode.OpcodeParam(Command);
            LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command);
        }
#endif
        m_StartAddress.SetValue(StartPC, true, true);
        m_EndAddress.SetValue(EndPC, true, true);
        return true;
    }
    break;
    }
    return false;
}
Esempio n. 3
0
void CSystemTimer::RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTimer)
{
    if (m_LastUpdate != rSystemTimer.m_LastUpdate)
    {
        LogFile.LogF("Timer-LastUpdate: %X %X\r\n", m_LastUpdate, rSystemTimer.m_LastUpdate);
    }
    if (m_NextTimer != rSystemTimer.m_NextTimer)
    {
        LogFile.LogF("Timer-NextTimer: %X %X\r\n", m_NextTimer, rSystemTimer.m_NextTimer);
    }
    if (m_Current != rSystemTimer.m_Current)
    {
        LogFile.LogF("Timer-Current %X %X\r\n", m_Current, rSystemTimer.m_Current);
    }
    if (m_inFixTimer != rSystemTimer.m_inFixTimer)
    {
        LogFile.LogF("Timer-inFixTimer %X %X\r\n", (int)m_inFixTimer, (int)rSystemTimer.m_inFixTimer);
    }

    for (int i = 0; i < MaxTimer; i++)
    {
        if (m_TimerDetatils[i].Active != rSystemTimer.m_TimerDetatils[i].Active)
        {
            LogFile.LogF("Timer-m_TimerDetatils[%d] %X %X\r\n", i, (int)m_TimerDetatils[i].Active, (int)rSystemTimer.m_TimerDetatils[i].Active);
        }
        if (m_TimerDetatils[i].CyclesToTimer != rSystemTimer.m_TimerDetatils[i].CyclesToTimer)
        {
            LogFile.LogF("Timer-m_TimerDetatils[%d] 0x%08X, 0x%08X\r\n", i, (uint32_t)m_TimerDetatils[i].CyclesToTimer, (uint32_t)rSystemTimer.m_TimerDetatils[i].CyclesToTimer);
        }
    }
}
Esempio n. 4
0
void CProfiling::GenerateLog()
{
    stdstr LogFileName;
    {
        CLog Log;
        Log.Open("Profiling.txt");
        LogFileName = Log.FileName();

        //Get the total time
        int64_t TotalTime = 0;
        for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++)
        {
            TotalTime += itemTime->second;
        }

        //Create a sortable list of items
        std::vector<PROFILE_VALUE *> ItemList;
        for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++)
        {
            ItemList.push_back(&(*Entry));
        }

        //sort the list with a basic bubble sort
        for (size_t OuterPass = 0; OuterPass < (ItemList.size() - 1); OuterPass++)
        {
            for (size_t InnerPass = 0; InnerPass < (ItemList.size() - 1); InnerPass++)
            {
                if (ItemList[InnerPass]->second < ItemList[InnerPass + 1]->second)
                {
                    PROFILE_VALUE * TempPtr = ItemList[InnerPass];
                    ItemList[InnerPass] = ItemList[InnerPass + 1];
                    ItemList[InnerPass + 1] = TempPtr;
                }
            }
        }

        TIMER_NAME TimerNames[] =
        {
            { Timer_R4300, "R4300" },
            { Timer_RSP_Dlist, "RSP: Dlist" },
            { Timer_RSP_Alist, "RSP: Alist" },
            { Timer_RSP_Unknown, "RSP: Unknown" },
            { Timer_RefreshScreen, "Refresh Screen" },
            { Timer_UpdateScreen, "Update Screen" },
            { Timer_UpdateFPS, "Update FPS" },
            { Timer_FuncLookup, "Function Lookup" },
            { Timer_Done, "Timer_Done" },
            { Timer_GetBlockInfo, "Timer_GetBlockInfo" },
            { Timer_AnalyseBlock, "Timer_AnalyseBlock" },
            { Timer_CompileBlock, "Timer_CompileBlock" },
            { Timer_CompileDone, "Timer_CompileDone" },
        };

        for (size_t count = 0; count < ItemList.size(); count++)
        {
            char Buffer[255];
            double CpuUsage = ((double)ItemList[count]->second / (double)TotalTime) * 100;
            if (CpuUsage <= 0.2) { continue; }
            sprintf(Buffer, "Func 0x%08X", ItemList[count]->first);
            for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++)
            {
                if (ItemList[count]->first == TimerNames[NameID].Timer)
                {
                    strcpy(Buffer, TimerNames[NameID].Name);
                    break;
                }
            }
            Log.LogF("%s\t%2.2f", Buffer, CpuUsage);
        }
    }

    ResetCounters();
}
Esempio n. 5
0
	//Generate a log file with the current results, this will also reset the counters
	void GenerateLog   ( void )
	{
		stdstr LogFileName;
		{
			CLog Log;
			Log.Open("RSP Profiling.txt");
			LogFileName = Log.FileName();

			//Get the total time
			__int64 TotalTime = 0;
			for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++ )
			{
				TotalTime += itemTime->second;
			}

			//Create a sortable list of items
			std::vector<PROFILE_VALUE *> ItemList;
			for (PROFILE_ENRTY Entry = m_Entries.begin(); Entry != m_Entries.end(); Entry++ )
			{
				ItemList.push_back(&(*Entry));
			}

			//sort the list with a basic bubble sort
			if (ItemList.size() > 0)
			{
				for (size_t OuterPass = 0; OuterPass < (ItemList.size() - 1); OuterPass++ )
				{
					for (size_t InnerPass = 0; InnerPass < (ItemList.size() - 1); InnerPass++ )
					{
						if (ItemList[InnerPass]->second < ItemList[InnerPass + 1]->second)
						{
							PROFILE_VALUE * TempPtr = ItemList[InnerPass];
							ItemList[InnerPass] = ItemList[InnerPass + 1];
							ItemList[InnerPass + 1] = TempPtr;
						}
					}
				}
			}

			TIMER_NAME TimerNames[] = {
				{Timer_Compiling,     "RSP: Compiling"},
				{Timer_RSP_Running,   "RSP: Running"},
				{Timer_R4300_Running, "R4300: Running"},
				{Timer_RDP_Running,   "RDP: Running"},
			};

			for (size_t count = 0; count < ItemList.size(); count++ )
			{
				char Buffer[255];
				float CpuUsage = (float)(((double)ItemList[count]->second / (double)TotalTime) * 100);

				if (CpuUsage <= 0.2) { continue; }
				sprintf(Buffer, "Func 0x%08X", ItemList[count]->first);
				for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++)
				{
					if (ItemList[count]->first == (DWORD)TimerNames[NameID].Timer)
					{
						strcpy(Buffer,TimerNames[NameID].Name);
						break;
					}
				}
				Log.LogF("%s\t%2.2f",Buffer,  CpuUsage);
			}
		}

		ShellExecute(NULL,"open",LogFileName.c_str(),NULL,NULL,SW_SHOW);
		ResetCounters();
	}