!1260 fix: 修复arkts数据无法解析的问题

Merge pull request !1260 from 集川/master
This commit is contained in:
openharmony_ci 2023-12-22 02:15:19 +00:00 committed by Gitee
commit a5bedc0a26
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 31 additions and 13 deletions

View File

@ -73,7 +73,22 @@ long BufferWriter::Write(const void* data, size_t size)
if (shareMemoryBlock_ == nullptr || data == nullptr || size == 0) {
return false;
}
return shareMemoryBlock_->PutRawTimeout(reinterpret_cast<const int8_t*>(data), size);
ProfilerPluginData pluginData;
pluginData.set_name(pluginName_);
pluginData.set_version(pluginVersion_);
pluginData.set_status(0);
pluginData.set_data(data, size);
struct timespec ts = { 0, 0 };
clock_gettime(clockId_, &ts);
pluginData.set_clock_id(static_cast<ProfilerPluginData_ClockId>(clockId_));
pluginData.set_tv_sec(ts.tv_sec);
pluginData.set_tv_nsec(ts.tv_nsec);
DoStats(pluginData.ByteSizeLong());
return shareMemoryBlock_->PutMessage(pluginData, pluginName_);
}
RandomWriteCtx* BufferWriter::StartReport()

View File

@ -823,19 +823,22 @@ void StackPreprocess::Flush(const uint8_t* src, size_t size)
HILOG_ERROR(LOG_CORE, "Flush src is nullptr");
return;
}
ProfilerPluginData pluginData;
pluginData.set_name("nativehook");
pluginData.set_version("1.02");
pluginData.set_status(0);
pluginData.set_data(src, size);
struct timespec ts;
clock_gettime(pluginDataClockId_, &ts);
pluginData.set_clock_id(static_cast<ProfilerPluginData_ClockId>(pluginDataClockId_));
pluginData.set_tv_sec(ts.tv_sec);
pluginData.set_tv_nsec(ts.tv_nsec);
pluginData.SerializeToArray(buffer_.get(), pluginData.ByteSizeLong());
if (isSaService_) {
ProfilerPluginData pluginData;
pluginData.set_name("nativehook");
pluginData.set_version("1.02");
pluginData.set_status(0);
pluginData.set_data(src, size);
struct timespec ts;
clock_gettime(pluginDataClockId_, &ts);
pluginData.set_clock_id(static_cast<ProfilerPluginData_ClockId>(pluginDataClockId_));
pluginData.set_tv_sec(ts.tv_sec);
pluginData.set_tv_nsec(ts.tv_nsec);
pluginData.SerializeToArray(buffer_.get(), pluginData.ByteSizeLong());
size = pluginData.ByteSizeLong();
}
writer_->Write(buffer_.get(), pluginData.ByteSizeLong());
writer_->Write(buffer_.get(), size);
writer_->Flush();
}