OffsetLinenumMap JavaJncReader::GetOffsetLines(std::wstring funcName) { int line = -1; std::string file; if (! m_lineMap.isEmpty()) { return m_lineMap; } //fprintf(debugFP, "============================\n"); //DumpJncPcStackInfoMap(debugFP); //if (gJncReaderVerbose) //{ //fprintf (stderr, "CJNCReader::GetOffsetLines (size:%lu) n", // m_jncPcStackInfoMap.size()); //} JncPcStackInfoMap::iterator it, itEnd; for (it = m_jncPcStackInfoMap.begin(), itEnd = m_jncPcStackInfoMap.end(); it != itEnd; ++it) { gtUInt64 pc = it->first; if (nullptr != debugFP) { fprintf(debugFP, "loadaddr: 0x%llx, pc = 0x%llx, stack size = %u\n", m_LoadAddr, pc, it->second->numstackframes); } int i = 0; for (i = 0 ; i < it->second->numstackframes; i++) { if (m_jncMethodMap[it->second->methods[i]].name.empty()) { if (debugFP != nullptr) { fprintf(debugFP, "Empty methods name..\n"); } continue; } std::wstring tmpStr(m_jncMethodMap[it->second->methods[i]].name.begin(), m_jncMethodMap[it->second->methods[i]].name.end()); // parse method signature char parsedMethodSig[OS_MAX_PATH] = { 0 }; parseMethodSignature(nullptr, m_jncMethodMap[it->second->methods[i]].signature.data(), parsedMethodSig); // append parsed signature to tmpStr tmpStr.append(parsedMethodSig, parsedMethodSig + strlen(parsedMethodSig)); if ((!funcName.empty()) && wcscmp(funcName.c_str(), tmpStr.c_str())) { continue; } bool rv = _getSrcInfoFromBcAndMethodID(it->second->bcis[i], it->second->methods[i], line, file); if (false == rv) { continue; } // Add it to offset line table unsigned int codeOffset = (unsigned int)(pc - m_LoadAddr); m_lineMap[codeOffset] = line; // if (gJncReaderVerbose) if (nullptr != debugFP) { fprintf(debugFP, " Frame:%2u, bcis:%4d, method:(%lld) %s (%d,%s)\n", i, it->second->bcis[i], it->second->methods[i], m_jncMethodMap[it->second->methods[i]].name.c_str(), line, file.c_str()); } } } return m_lineMap; } // GetOffsetLines(wstring funcName)
// GetOffsetLines(wstring funcName) // OffsetLinenumMap JavaJncReader::GetOffsetLines(wstring funcName) { int line = -1; string file; if (! m_lineMap.isEmpty()) { return m_lineMap; } if (gJncReaderVerbose) { fprintf(stderr, "CJNCReader::GetOffsetLines (size:%lu) n", m_jncPcStackInfoMap.size()); } JncPcStackInfoMap::iterator it = m_jncPcStackInfoMap.begin(); JncPcStackInfoMap::iterator itEnd = m_jncPcStackInfoMap.end(); for (; it != itEnd; it++) { uint64_t pc = it->first; if (gJncReaderVerbose) { fprintf(stderr, "loadaddr: 0x%lx, size:%ld, pc = 0x%lx, stack size = %u\n", m_loadAddr, m_textSize, it->first, it->second->numstackframes); } int i = 0; for (i = 0 ; i < it->second->numstackframes; i++) { wstring tmpStr(m_jncMethodMap[it->second->methods[i]].name.begin(), m_jncMethodMap[it->second->methods[i]].name.end()); // parse method signature char parsedMethodSig[OS_MAX_PATH] = { 0 }; parseMethodSignature(nullptr, m_jncMethodMap[it->second->methods[i]].signature.data(), parsedMethodSig); // append parsed signature to tmpStr tmpStr.append(parsedMethodSig, parsedMethodSig + strlen(parsedMethodSig)); if ((!funcName.empty()) && wcscmp(funcName.c_str(), tmpStr.c_str())) { continue; } _getSrcInfoFromBcAndMethodID(it->second->bcis[i], it->second->methods[i], line, file); // Add it to offset line table unsigned int codeOffset = pc - m_loadAddr; m_lineMap[codeOffset] = line; if (gJncReaderVerbose) { fprintf(stderr, " Frame:%2u, bcis:%4d, method:(%lx) %s (%d,%s)\n", i, it->second->bcis[i], (uint64_t)it->second->methods[i], m_jncMethodMap[it->second->methods[i]].name.c_str(), line, file.c_str()); } } } return m_lineMap; } // GetOffsetLines(wstring funcName)