void CDebugger::FindEeFunctions() { if(m_virtualMachine.m_ee->m_os->GetELF() == nullptr) return; auto executableRange = m_virtualMachine.m_ee->m_os->GetExecutableRange(); uint32 minAddr = executableRange.first; uint32 maxAddr = executableRange.second & ~0x03; { Framework::CStdStream patternStream("ee_functions.xml", "rb"); boost::scoped_ptr<Framework::Xml::CNode> document(Framework::Xml::CParser::ParseDocument(patternStream)); CMipsFunctionPatternDb patternDb(document.get()); for(auto patternIterator(std::begin(patternDb.GetPatterns())); patternIterator != std::end(patternDb.GetPatterns()); ++patternIterator) { auto pattern = *patternIterator; for(uint32 address = minAddr; address <= maxAddr; address += 4) { uint32* text = reinterpret_cast<uint32*>(m_virtualMachine.m_ee->m_ram + address); uint32 textSize = (maxAddr - address); if(pattern.Matches(text, textSize)) { m_virtualMachine.m_ee->m_EE.m_Functions.InsertTag(address, pattern.name.c_str()); break; } } } m_virtualMachine.m_ee->m_EE.m_Functions.OnTagListChange(); } }
void CDebugger::FindEeFunctions() { if(m_virtualMachine.m_ee->m_os->GetELF() == nullptr) return; auto executableRange = m_virtualMachine.m_ee->m_os->GetExecutableRange(); uint32 minAddr = executableRange.first; uint32 maxAddr = executableRange.second & ~0x03; { Framework::CStdStream patternStream("ee_functions.xml", "rb"); boost::scoped_ptr<Framework::Xml::CNode> document(Framework::Xml::CParser::ParseDocument(patternStream)); CMipsFunctionPatternDb patternDb(document.get()); for(auto patternIterator(std::begin(patternDb.GetPatterns())); patternIterator != std::end(patternDb.GetPatterns()); ++patternIterator) { auto pattern = *patternIterator; for(uint32 address = minAddr; address <= maxAddr; address += 4) { uint32* text = reinterpret_cast<uint32*>(m_virtualMachine.m_ee->m_ram + address); uint32 textSize = (maxAddr - address); if(pattern.Matches(text, textSize)) { m_virtualMachine.m_ee->m_EE.m_Functions.InsertTag(address, pattern.name.c_str()); break; } } } } { //Identify functions that reference special string literals (TODO: Move that inside a file) static const std::map<std::string, std::string> stringFuncs = { { "SceSifrpcBind", "SifBindRpc" }, { "SceSifrpcCall", "SifCallRpc" }, { "call cdread cmd\n", "CdRead" }, { "sceGsPutDrawEnv: DMA Ch.2 does not terminate\r\n", "GsPutDrawEnv" }, { "sceGsSyncPath: DMA Ch.1 does not terminate\r\n", "GsSyncPath" }, { "sceDbcReceiveData: rpc error\n", "DbcReceiveData" } }; { auto& eeFunctions = m_virtualMachine.m_ee->m_EE.m_Functions; const auto& eeComments = m_virtualMachine.m_ee->m_EE.m_Comments; const auto& eeAnalysis = m_virtualMachine.m_ee->m_EE.m_analysis; for(auto tagIterator = eeComments.GetTagsBegin(); tagIterator != eeComments.GetTagsEnd(); tagIterator++) { const auto& tag = *tagIterator; auto subroutine = eeAnalysis->FindSubroutine(tag.first); if(subroutine == nullptr) continue; auto stringFunc = stringFuncs.find(tag.second); if(stringFunc == std::end(stringFuncs)) continue; eeFunctions.InsertTag(subroutine->start, stringFunc->second.c_str()); } } } m_virtualMachine.m_ee->m_EE.m_Functions.OnTagListChange(); }