support shmm

Signed-off-by: yuyanqinghw <yuyanqing539@huawei.com>
This commit is contained in:
yuyanqinghw 2024-08-22 19:30:49 +08:00
parent 69b08acf5c
commit e80ed49ce6
3 changed files with 19 additions and 3 deletions

View File

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

View File

@ -1247,6 +1247,7 @@ bool SubCommandRecord::OnSubCommand(std::vector<std::string> &args)
RecoverSavedCmdlinesSize();
OnlineReportData();
CloseClientThread();
RemoveVdsoTmpFile();
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)
{
CHECK_TRUE(record == nullptr, false, 1, "record is null");

View File

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