!563 支持shmm解析

Merge pull request !563 from yuyanqing/master
This commit is contained in:
openharmony_ci 2024-08-22 13:36:21 +00:00 committed by Gitee
commit 77748119e8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 19 additions and 3 deletions

View File

@ -334,6 +334,7 @@ private:
bool CheckTargetPids(); bool CheckTargetPids();
bool CheckReportOption(); bool CheckReportOption();
void WriteCommEventBeforeSampling(); void WriteCommEventBeforeSampling();
void RemoveVdsoTmpFile();
VirtualRuntime virtualRuntime_; VirtualRuntime virtualRuntime_;
#if USE_COLLECT_SYMBOLIC #if USE_COLLECT_SYMBOLIC

View File

@ -1247,6 +1247,7 @@ bool SubCommandRecord::OnSubCommand(std::vector<std::string> &args)
RecoverSavedCmdlinesSize(); RecoverSavedCmdlinesSize();
OnlineReportData(); OnlineReportData();
CloseClientThread(); CloseClientThread();
RemoveVdsoTmpFile();
return true; return true;
} }
@ -1268,6 +1269,20 @@ void SubCommandRecord::CloseClientThread()
} }
} }
void SubCommandRecord::RemoveVdsoTmpFile()
{
std::vector<std::string> fileName = {"/data/local/tmp/shmm", "/data/local/tmp/[vdso]"};
for (auto name : fileName) {
if (access(name.c_str(), F_OK) == 0) {
if (remove(name.c_str()) != 0) {
char errInfo[ERRINFOLEN] = { 0 };
strerror_r(errno, errInfo, ERRINFOLEN);
HLOGE("remove file %s failed,errno:%d,errinfo:%s", name.c_str(), errno, errInfo);
}
}
}
}
bool SubCommandRecord::ProcessRecord(std::unique_ptr<PerfEventRecord> record) bool SubCommandRecord::ProcessRecord(std::unique_ptr<PerfEventRecord> record)
{ {
CHECK_TRUE(record == nullptr, false, 1, "record is null"); CHECK_TRUE(record == nullptr, false, 1, "record is null");

View File

@ -1220,17 +1220,17 @@ void VirtualRuntime::LoadVdso()
VirtualThread myThread(getpid(), symbolsFiles_); VirtualThread myThread(getpid(), symbolsFiles_);
myThread.ParseMap(); myThread.ParseMap();
for (const auto &map : myThread.GetMaps()) { for (const auto &map : myThread.GetMaps()) {
if (map->name == MMAP_VDSO_NAME) { if (map->IsVdsoMap()) {
std::string memory(map->end - map->begin, '\0'); std::string memory(map->end - map->begin, '\0');
std::copy(reinterpret_cast<char *>((map->begin)), reinterpret_cast<char *>((map->end)), std::copy(reinterpret_cast<char *>((map->begin)), reinterpret_cast<char *>((map->end)),
&memory[0]); &memory[0]);
std::string tempPath("/data/local/tmp/"); std::string tempPath("/data/local/tmp/");
std::string tempFileName = tempPath + MMAP_VDSO_NAME; std::string tempFileName = tempPath + map->name;
if (!WriteStringToFile(tempFileName, memory)) { if (!WriteStringToFile(tempFileName, memory)) {
printf("vdso temp file create fail at %s\n", tempFileName.c_str()); printf("vdso temp file create fail at %s\n", tempFileName.c_str());
} else { } else {
HLOGD("vdso temp file create at %s:%zu", tempFileName.c_str(), memory.size()); HLOGD("vdso temp file create at %s:%zu", tempFileName.c_str(), memory.size());
auto symbolsFile = SymbolsFile::CreateSymbolsFile(MMAP_VDSO_NAME); auto symbolsFile = SymbolsFile::CreateSymbolsFile(map->name);
symbolsFile->setSymbolsFilePath(tempPath); // also load from search path symbolsFile->setSymbolsFilePath(tempPath); // also load from search path
symbolsFiles_.emplace_back(std::move(symbolsFile)); symbolsFiles_.emplace_back(std::move(symbolsFile));
return; return;