mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-22 22:40:48 +00:00
Merge branch 'master' of gitee.com:openharmony/developtools_profiler into master
Signed-off-by: harrysunv9x <harrysunv9x@outlook.com>
This commit is contained in:
commit
8a464f5e72
@ -38,6 +38,7 @@
|
||||
"hichecker",
|
||||
"hidumper",
|
||||
"hilog",
|
||||
"hisysevent",
|
||||
"hitrace",
|
||||
"hiview",
|
||||
"ipc",
|
||||
|
@ -54,5 +54,18 @@ bool IsBetaVersion();
|
||||
std::pair<bool, std::string> CheckNotExistsFilePath(const std::string& filePath);
|
||||
bool CheckWhiteList(const std::string& cmdPath);
|
||||
bool CheckCmdLineArgValid(const std::string& cmdLine);
|
||||
int PluginWriteToHisysevent (std::string pluginName, std::string caller, std::string args, int errorCode,
|
||||
std::string errorMessage);
|
||||
std::string GetProcessNameByPid(int32_t pid);
|
||||
|
||||
enum ErrorType {
|
||||
RET_NO_PERMISSION,
|
||||
RET_NOT_SUPPORT,
|
||||
RET_IVALID_PATH,
|
||||
RET_IVALID_PID,
|
||||
RET_MSG_EMPTY,
|
||||
RET_FAIL = -1,
|
||||
RET_SUCC = 0,
|
||||
};
|
||||
} // COMMON
|
||||
#endif // COMMON_H
|
@ -33,6 +33,7 @@
|
||||
#include "application_info.h"
|
||||
#include "bundle_mgr_proxy.h"
|
||||
#include "file_ex.h"
|
||||
#include "hisysevent.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "logging.h"
|
||||
#include "system_ability_definition.h"
|
||||
@ -773,4 +774,41 @@ bool CheckCmdLineArgValid(const std::string& cmdLine)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int PluginWriteToHisysevent(std::string pluginName, std::string caller, std::string args, int errorCode,
|
||||
std::string errorMessage)
|
||||
{
|
||||
return HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::PROFILER, "HIPROFILER_USAGE",
|
||||
OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC,
|
||||
"PLUGIN_NAME", pluginName,
|
||||
"CALLER", caller,
|
||||
"ARGS", args,
|
||||
"ERROR_CODE", errorCode,
|
||||
"ERROR_MESSAGE", errorMessage);
|
||||
}
|
||||
|
||||
std::string GetProcessNameByPid(int32_t pid)
|
||||
{
|
||||
std::string path = "/proc/" + std::to_string(pid) + "/cmdline";
|
||||
std::ifstream cmdlineFile(path);
|
||||
if (!cmdlineFile) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string processName;
|
||||
std::getline(cmdlineFile, processName, '\0');
|
||||
|
||||
static constexpr size_t headSize = 2;
|
||||
if (processName.substr(0, headSize) == "./") {
|
||||
processName = processName.substr(headSize);
|
||||
}
|
||||
size_t found = processName.rfind("/");
|
||||
std::string procName;
|
||||
if (found != std::string::npos) {
|
||||
procName = processName.substr(found + 1);
|
||||
} else {
|
||||
procName = processName;
|
||||
}
|
||||
return procName;
|
||||
}
|
||||
} // namespace COMMON
|
||||
|
@ -37,6 +37,7 @@ ohos_source_set("cpudataplugin_source") {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
@ -46,7 +47,10 @@ ohos_source_set("cpudataplugin_source") {
|
||||
ohos_shared_library("cpudataplugin") {
|
||||
output_name = "cpudataplugin"
|
||||
version_script = "libcpu_plugin.map"
|
||||
deps = [ ":cpudataplugin_source" ]
|
||||
deps = [
|
||||
":cpudataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
]
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
|
@ -99,6 +99,7 @@ private:
|
||||
DIR* OpenDestDir(std::string& dirPath);
|
||||
int32_t GetValidTid(DIR* dirp);
|
||||
ThreadState GetThreadState(const char threadState);
|
||||
std::string GetCmdArgs(CpuConfig protoConfig);
|
||||
|
||||
template <typename T> void WriteThread(T& threadInfo, const char* pFile, uint32_t fileLen, int32_t tid);
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
#include "common.h"
|
||||
#include "cpu_plugin_result.pbencoder.h"
|
||||
#include "buffer_splitter.h"
|
||||
|
||||
@ -68,6 +70,14 @@ CpuDataPlugin::~CpuDataPlugin()
|
||||
minFrequencyVec_.clear();
|
||||
}
|
||||
|
||||
std::string CpuDataPlugin::GetCmdArgs(CpuConfig protoConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
args << "pid: " << COMMON::GetProcessNameByPid(protoConfig.pid());
|
||||
args << " report_process_info: " << (protoConfig.report_process_info() ? "true" : "false");
|
||||
return args.str();
|
||||
}
|
||||
|
||||
int CpuDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
{
|
||||
buffer_ = malloc(READ_BUFFER_SIZE);
|
||||
@ -77,15 +87,19 @@ int CpuDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
}
|
||||
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, RET_FAIL,
|
||||
"%s:parseFromArray failed!", __func__);
|
||||
auto args = GetCmdArgs(protoConfig_);
|
||||
if (protoConfig_.pid() > 0) {
|
||||
pid_ = protoConfig_.pid();
|
||||
} else if (protoConfig_.report_process_info()) {
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:need report process info", __func__);
|
||||
} else {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "%s:invalid pid", __func__);
|
||||
int ret = COMMON::PluginWriteToHisysevent("CPU_PLUGIN", "sh", args, RET_FAIL, "failed");
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "%s:invalid pid, record hisysevent result. %d", __func__, ret);
|
||||
return RET_FAIL;
|
||||
}
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:start success!", __func__);
|
||||
|
||||
int ret = COMMON::PluginWriteToHisysevent("cpu_plugin", "sh", args, RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:start success! hisysevent report cpu_plugin result: %d", __func__, ret);
|
||||
return RET_SUCC;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ ohos_unittest("cpudataplugin_ut") {
|
||||
module_out_path = module_output_path
|
||||
sources = [ "unittest/cpu_data_plugin_unittest.cpp" ]
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugintest",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/cpu_data:cpu_data_cpp",
|
||||
|
@ -27,6 +27,7 @@ ohos_fuzztest("CpuStartPluginFuzzTest") {
|
||||
]
|
||||
sources = [ "cpustartplugin_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/cpu_data:cpu_data_cpp",
|
||||
]
|
||||
|
@ -38,6 +38,7 @@ ohos_source_set("diskiodataplugin_source") {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
@ -47,7 +48,10 @@ ohos_source_set("diskiodataplugin_source") {
|
||||
ohos_shared_library("diskiodataplugin") {
|
||||
output_name = "diskiodataplugin"
|
||||
version_script = "libdiskio_plugin.map"
|
||||
deps = [ ":diskiodataplugin_source" ]
|
||||
deps = [
|
||||
":diskiodataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
]
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [
|
||||
|
@ -56,6 +56,8 @@ private:
|
||||
|
||||
template <typename T> void WriteDiskioData(T& diskioData);
|
||||
|
||||
std::string GetCmdArgs(DiskioConfig protoConfig);
|
||||
|
||||
// for UT
|
||||
void SetPath(std::string path)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <ctime>
|
||||
|
||||
#include "buffer_splitter.h"
|
||||
#include "common.h"
|
||||
#include "diskio_plugin_result.pbencoder.h"
|
||||
|
||||
namespace {
|
||||
@ -46,6 +47,13 @@ DiskioDataPlugin::~DiskioDataPlugin()
|
||||
}
|
||||
}
|
||||
|
||||
std::string DiskioDataPlugin::GetCmdArgs(DiskioConfig protoConfig)
|
||||
{
|
||||
std::string args;
|
||||
args += "report_io_stats: " + std::to_string(protoConfig.report_io_stats());
|
||||
return args;
|
||||
}
|
||||
|
||||
int DiskioDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
{
|
||||
buffer_ = malloc(READ_BUFFER_SIZE);
|
||||
@ -53,11 +61,12 @@ int DiskioDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
|
||||
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, RET_FAIL,
|
||||
"%s:parseFromArray failed!", __func__);
|
||||
|
||||
if (protoConfig_.report_io_stats()) {
|
||||
ioEntry_ = std::make_shared<IoStats>(protoConfig_.report_io_stats());
|
||||
}
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:start success!", __func__);
|
||||
|
||||
int ret = COMMON::PluginWriteToHisysevent("diskio_plugin", "sh", GetCmdArgs(protoConfig_), RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:start success! hisysevent report diskio_plugin result: %d", __func__, ret);
|
||||
return RET_SUCC;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ ohos_unittest("diskiodataplugin_ut") {
|
||||
module_out_path = module_output_path
|
||||
sources = [ "unittest/diskio_data_plugin_unittest.cpp" ]
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/diskio_plugin:diskiodataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/diskio_plugin:diskiodataplugintest",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/diskio_data:diskio_data_cpp",
|
||||
|
@ -27,6 +27,7 @@ ohos_fuzztest("DiskioStartPluginFuzzTest") {
|
||||
]
|
||||
sources = [ "diskiostartplugin_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/diskio_plugin:diskiodataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/diskio_data:diskio_data_cpp",
|
||||
]
|
||||
|
@ -52,6 +52,7 @@ ohos_source_set("ftrace_plugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"hiview:libucollection_client",
|
||||
"init:libbegetutil",
|
||||
"protobuf:protobuf_lite",
|
||||
|
@ -76,6 +76,7 @@ private:
|
||||
void EnableTraceEvents(void);
|
||||
void DisableTraceEvents(void);
|
||||
void DisableAllCategories(void);
|
||||
std::string GetCmdArgs(TracePluginConfig traceConfig);
|
||||
|
||||
template <typename T> bool ReportClockTimes(T& tracePluginResult);
|
||||
|
||||
|
@ -19,11 +19,13 @@
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <regex>
|
||||
|
||||
#include "common.h"
|
||||
#include "file_utils.h"
|
||||
#include "ftrace_field_parser.h"
|
||||
#include "ftrace_fs_ops.h"
|
||||
@ -746,6 +748,33 @@ bool FlowController::AddPlatformEventsToParser(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string FlowController::GetCmdArgs(TracePluginConfig traceConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
for (const auto& event : traceConfig.ftrace_events()) {
|
||||
args << "ftrace_events: " << event << ", ";
|
||||
}
|
||||
for (const auto& category : traceConfig.hitrace_categories()) {
|
||||
args << "hitrace_categories: " << category << ", ";
|
||||
}
|
||||
for (const auto& app : traceConfig.hitrace_apps()) {
|
||||
args << "hitrace_apps: " << app << ", ";
|
||||
}
|
||||
args << "buffer_size_kb: " << std::to_string(traceConfig.buffer_size_kb()) << ", ";
|
||||
args << "flush_interval_ms: " << std::to_string(traceConfig.flush_interval_ms()) << ", ";
|
||||
args << "flush_threshold_kb: " << std::to_string(traceConfig.flush_threshold_kb()) << ", ";
|
||||
args << "trace_period_ms: " << std::to_string(traceConfig.trace_period_ms()) << ", ";
|
||||
args << "trace_duration_ms: " << std::to_string(traceConfig.trace_duration_ms()) << ", ";
|
||||
args << "hitrace_time: " << std::to_string(traceConfig.hitrace_time()) << ", ";
|
||||
args << "parse_ksyms: " << (traceConfig.parse_ksyms() ? "true" : "false") << ", ";
|
||||
args << "clock: " << traceConfig.clock() << ", ";
|
||||
args << "raw_data_prefix: " << traceConfig.raw_data_prefix() << ", ";
|
||||
args << "debug_on: " << (traceConfig.debug_on() ? "true" : "false") << ", ";
|
||||
args << "discard_cache_data: " << (traceConfig.discard_cache_data() ? "true" : "false") << ", ";
|
||||
args << "parse_mode: " << std::to_string(traceConfig.parse_mode());
|
||||
return args.str();
|
||||
}
|
||||
|
||||
int FlowController::LoadConfig(const uint8_t configData[], uint32_t size)
|
||||
{
|
||||
CHECK_TRUE(size > 0, -1, "config data size is zero!");
|
||||
@ -790,6 +819,10 @@ int FlowController::LoadConfig(const uint8_t configData[], uint32_t size)
|
||||
SetupTraceReadPeriod(traceConfig.trace_period_ms());
|
||||
flushCacheData_ = traceConfig.discard_cache_data();
|
||||
hitraceTime_ = traceConfig.hitrace_time();
|
||||
|
||||
int ret = COMMON::PluginWriteToHisysevent("ftrace_plugin", "sh", GetCmdArgs(traceConfig),
|
||||
COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "hisysevent report ftrace_plugin result: %d", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ ohos_source_set("gpudataplugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
@ -47,7 +48,10 @@ ohos_source_set("gpudataplugin_source") {
|
||||
ohos_shared_library("gpudataplugin") {
|
||||
output_name = "gpudataplugin"
|
||||
version_script = "libgpu_plugin.map"
|
||||
deps = [ ":gpudataplugin_source" ]
|
||||
deps = [
|
||||
":gpudataplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
]
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [ "hilog:libhilog_base" ]
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
|
||||
private:
|
||||
int ReadFile();
|
||||
std::string GetCmdArgs(GpuConfig traceConfig);
|
||||
template <typename T> void WriteGpuDataInfo(T& gpuData);
|
||||
|
||||
private:
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "gpu_data_plugin.h"
|
||||
#include <ctime>
|
||||
#include "common.h"
|
||||
#include "gpu_plugin_result.pbencoder.h"
|
||||
|
||||
namespace {
|
||||
@ -32,14 +33,27 @@ int GpuDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
}
|
||||
|
||||
file_.open(GPU_PATH);
|
||||
auto args = GetCmdArgs(protoConfig_);
|
||||
if (!file_.is_open()) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "%s:failed to open(%s)", __func__, GPU_PATH.c_str());
|
||||
int ret = COMMON::PluginWriteToHisysevent("gpu_plugin", "sh", args, RET_FAIL, "failed");
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "%s:failed to open(%s), hisysevent report gpu_plugin ret: %d",
|
||||
__func__, GPU_PATH.c_str(), ret);
|
||||
return RET_FAIL;
|
||||
}
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:start success!", __func__);
|
||||
|
||||
int ret = COMMON::PluginWriteToHisysevent("gpu_plugin", "sh", args, RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:start success! hisysevent report gpu_plugin result: %d", __func__, ret);
|
||||
return RET_SUCC;
|
||||
}
|
||||
|
||||
std::string GpuDataPlugin::GetCmdArgs(GpuConfig traceConfig)
|
||||
{
|
||||
std::string args;
|
||||
args += "pid: " + std::to_string(traceConfig.pid()) + ", report_gpu_info: ";
|
||||
args += (traceConfig.report_gpu_info() ? "true" : "false");
|
||||
return args;
|
||||
}
|
||||
|
||||
int GpuDataPlugin::ReportOptimize(RandomWriteCtx* randomWrite)
|
||||
{
|
||||
ProtoEncoder::GpuData dataProto(randomWrite);
|
||||
|
@ -36,6 +36,7 @@ ohos_source_set("hidumpplugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
// for ut
|
||||
void SetConfig(HidumpConfig& config);
|
||||
int SetTestCmd(const char *test_cmd);
|
||||
std::string GetCmdArgs(HidumpConfig protoConfig);
|
||||
const char *GetTestCmd();
|
||||
char *testCmd_ = nullptr;
|
||||
private:
|
||||
|
@ -24,9 +24,10 @@
|
||||
#include <sstream>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "hidump_plugin_result.pbencoder.h"
|
||||
#include "securec.h"
|
||||
#include "common.h"
|
||||
#include "hidump_plugin_result.pbencoder.h"
|
||||
#include "hisysevent.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace {
|
||||
using namespace OHOS::Developtools::Profiler;
|
||||
@ -58,6 +59,14 @@ HidumpPlugin::~HidumpPlugin()
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s: success!", __func__);
|
||||
}
|
||||
|
||||
std::string HidumpPlugin::GetCmdArgs(HidumpConfig protoConfig)
|
||||
{
|
||||
std::string args;
|
||||
args += "sections: " + std::to_string(protoConfig.sections()) + ", report_fps: ";
|
||||
args += (protoConfig.report_fps() ? "true" : "false");
|
||||
return args;
|
||||
}
|
||||
|
||||
int HidumpPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
{
|
||||
PROFILER_LOG_INFO(LOG_CORE, "HidumpPlugin:Start ----> !");
|
||||
@ -73,10 +82,12 @@ int HidumpPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
COMMON::CustomPopen(fullCmd, "r", pipeFds_, childPid_, true), [this](FILE* fp) -> int {
|
||||
return COMMON::CustomPclose(fp, pipeFds_, childPid_, true);
|
||||
});
|
||||
auto args = GetCmdArgs(protoConfig_);
|
||||
if (fp_.get() == nullptr) {
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = {0};
|
||||
strerror_r(errno, buf, bufSize);
|
||||
COMMON::PluginWriteToHisysevent("hidump_plugin", "sh", args, COMMON::ErrorType::RET_FAIL, "failed");
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "HidumpPlugin: CustomPopen(%s) Failed, errno(%d:%s)", FPS_FORMAT, errno, buf);
|
||||
return -1;
|
||||
}
|
||||
@ -86,7 +97,8 @@ int HidumpPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
std::unique_lock<std::mutex> locker(mutex_);
|
||||
running_ = true;
|
||||
writeThread_ = std::thread([this] { this->Loop(); });
|
||||
PROFILER_LOG_INFO(LOG_CORE, "HidumpPlugin: ---> Start success!");
|
||||
int ret = COMMON::PluginWriteToHisysevent("hidump_plugin", "sh", args, COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "HidumpPlugin--> Start success! hisysevent report hidump_plugin result:%d", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ ohos_source_set("hilogplugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ private:
|
||||
bool FindFirstNum(char** p);
|
||||
bool RemoveSpaces(char** p);
|
||||
bool FindFirstSpace(char** p);
|
||||
std::string GetCmdArgs(HilogConfig protoConfig);
|
||||
|
||||
bool StringToL(const char* word, long& value);
|
||||
// for ut
|
||||
|
@ -68,6 +68,16 @@ HilogPlugin::~HilogPlugin()
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s: success!", __func__);
|
||||
}
|
||||
|
||||
std::string HilogPlugin::GetCmdArgs(HilogConfig protoConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
args << "log_level: " << std::to_string(protoConfig.log_level()) << ", ";
|
||||
args << "pid: " << COMMON::GetProcessNameByPid(protoConfig.pid()) << ", ";
|
||||
args << "need_record: " << (protoConfig.need_record() ? "true" : "false") << ", ";
|
||||
args << "need_clear: " << (protoConfig.need_clear() ? "true" : "false");
|
||||
return args.str();
|
||||
}
|
||||
|
||||
int HilogPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
{
|
||||
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, -1, "HilogPlugin: ParseFromArray failed");
|
||||
@ -83,7 +93,6 @@ int HilogPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
CHECK_NOTNULL(fp, -1, "%s:clear hilog error", __func__);
|
||||
COMMON::CustomPclose(fp, pipeFds, childPid);
|
||||
}
|
||||
|
||||
InitHilogCmd();
|
||||
fp_ = std::unique_ptr<FILE, std::function<int (FILE*)>>(
|
||||
COMMON::CustomPopen(fullCmd_, "r", pipeFds_, childPid_, true), [this](FILE* fp) -> int {
|
||||
@ -106,8 +115,11 @@ int HilogPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
fcntl(fileno(fp_.get()), F_SETPIPE_SZ, oldPipeSize * PIPE_SIZE_RATIO);
|
||||
int pipeSize = fcntl(fileno(fp_.get()), F_GETPIPE_SZ);
|
||||
PROFILER_LOG_INFO(LOG_CORE, "{fp = %d, pipeSize=%d, oldPipeSize=%d}", fileno(fp_.get()), pipeSize, oldPipeSize);
|
||||
|
||||
workThread_ = std::thread([this] { this->Run(); });
|
||||
|
||||
int ret = COMMON::PluginWriteToHisysevent("hilog_plugin", "sh", GetCmdArgs(protoConfig_),
|
||||
COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "hisysevent report hilog_plugin result:%d", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ ohos_source_set("hiperfplugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"openssl:libcrypto_shared",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -22,10 +22,11 @@
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#include "common.h"
|
||||
#include "hiperf_plugin_config.pb.h"
|
||||
#include "hisysevent.h"
|
||||
#include "logging.h"
|
||||
#include "securec.h"
|
||||
#include "common.h"
|
||||
#include "trace_file_writer.h"
|
||||
|
||||
namespace {
|
||||
@ -111,6 +112,16 @@ bool RunCommand(const std::string& cmd)
|
||||
CHECK_TRUE(res, false, "HiperfPlugin::RunCommand: execute command FAILED!");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string GetCmdArgs(HiperfPluginConfig protoConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
args << "is_root: " << (protoConfig.is_root() ? "true" : "false") << ", ";
|
||||
args << "record_args: " << protoConfig.record_args() << ", ";
|
||||
args << "split_outfile_name: " << protoConfig.split_outfile_name() << ", ";
|
||||
args << "log_level: " << std::to_string(protoConfig.log_level());
|
||||
return args.str();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int HiperfPluginSessionStart(const uint8_t* configData, const uint32_t configSize)
|
||||
@ -141,6 +152,9 @@ int HiperfPluginSessionStart(const uint8_t* configData, const uint32_t configSiz
|
||||
CHECK_TRUE(res, -1, "HiperfPluginSessionStart, RunCommand(%s) FAILED!", cmd.c_str());
|
||||
}
|
||||
|
||||
int ret = COMMON::PluginWriteToHisysevent("hiperf_plugin", "sh", GetCmdArgs(g_config),
|
||||
COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "hisysevent report hiperf_plugin result:%d", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("HiperfStartPluginFuzzTest") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"openssl:libcrypto_shared",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -38,6 +38,7 @@ ohos_source_set("hisyseventplugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
private:
|
||||
std::string GetFullCmd();
|
||||
bool InitHisyseventCmd();
|
||||
std::string GetCmdArgs(HisyseventConfig protoConfig);
|
||||
|
||||
template <typename T> bool ParseSyseventLineInfo(const char* data, size_t len, T hisyseventInfoProto);
|
||||
|
||||
|
@ -76,10 +76,21 @@ int HisyseventPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
running_ = true;
|
||||
workThread_ = std::thread([this] { this->Run(); });
|
||||
|
||||
PROFILER_LOG_INFO(LOG_CORE, "END %s: success!", __func__);
|
||||
int ret = COMMON::PluginWriteToHisysevent("hisysevent_plugin", "sh", GetCmdArgs(protoConfig_),
|
||||
COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "END %s: success! hisysevent report hisysevent_plugin result:%d", __func__, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string HisyseventPlugin::GetCmdArgs(HisyseventConfig protoConfig)
|
||||
{
|
||||
std::string args;
|
||||
args += "msg: " + protoConfig.msg() + ", ";
|
||||
args += "subscribe_domain: " + protoConfig.subscribe_domain() + ", ";
|
||||
args += "subscribe_event: " + protoConfig.subscribe_event();
|
||||
return args;
|
||||
}
|
||||
|
||||
int HisyseventPlugin::Stop()
|
||||
{
|
||||
PROFILER_LOG_INFO(LOG_CORE, "BEGN %s: ready!", __func__);
|
||||
|
@ -43,6 +43,7 @@ ohos_source_set("memdataplugin_source") {
|
||||
"drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
|
||||
"hidumper:lib_dump_usage",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"hiview:libucollection_graphic",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -349,7 +349,7 @@ public:
|
||||
};
|
||||
|
||||
template <typename T> void WriteProcesseList(T& memoryData);
|
||||
|
||||
std::string GetCmdArgs(MemoryConfig protoConfig);
|
||||
template <typename T> void WriteProcinfoByPidfds(T& processMemoryInfo, int32_t pid);
|
||||
|
||||
DIR* OpenDestDir(const char* dirPath);
|
||||
|
@ -17,10 +17,10 @@
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
|
||||
#include "common.h"
|
||||
#include "memory_plugin_result.pbencoder.h"
|
||||
#include "securec.h"
|
||||
#include "smaps_stats.h"
|
||||
#include "common.h"
|
||||
|
||||
namespace {
|
||||
using namespace OHOS::HDI::Memorytracker::V1_0;
|
||||
@ -199,10 +199,44 @@ int MemoryDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
}
|
||||
}
|
||||
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:start success!", __func__);
|
||||
int ret = COMMON::PluginWriteToHisysevent("memory_plugin", "sh", GetCmdArgs(protoConfig_),
|
||||
COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s: success! hisysevent report memory_plugin result:%d", __func__, ret);
|
||||
return RET_SUCC;
|
||||
}
|
||||
|
||||
|
||||
std::string MemoryDataPlugin::GetCmdArgs(MemoryConfig protoConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
args << "report_process_tree: " << (protoConfig.report_process_tree() ? "true" : "false") << ", ";
|
||||
args << "report_sysmem_mem_info: " << (protoConfig.report_sysmem_mem_info() ? "true" : "false") << ", ";
|
||||
args << "report_sysmem_vmem_info: " << (protoConfig.report_sysmem_vmem_info() ? "true" : "false") << ", ";
|
||||
args << "report_process_mem_info: " << (protoConfig.report_process_mem_info() ? "true" : "false") << ", ";
|
||||
args << "report_app_mem_info: " << (protoConfig.report_app_mem_info() ? "true" : "false") << ", ";
|
||||
args << "report_app_mem_by_memory_service: " << (protoConfig.report_app_mem_by_memory_service() ?
|
||||
"true" : "false") << ", ";
|
||||
args << "report_smaps_mem_info: " << (protoConfig.report_smaps_mem_info() ? "true" : "false") << ", ";
|
||||
args << "report_purgeable_ashmem_info: " << (protoConfig.report_purgeable_ashmem_info() ?
|
||||
"true" : "false") << ", ";
|
||||
args << "report_dma_mem_info: " << (protoConfig.report_dma_mem_info() ? "true" : "false") << ", ";
|
||||
args << "report_gpu_mem_info: " << (protoConfig.report_gpu_mem_info() ? "true" : "false") << ", ";
|
||||
args << "report_gpu_dump_info: " << (protoConfig.report_gpu_dump_info() ? "true" : "false") << ", ";
|
||||
args << "report_fake_data: " << (protoConfig.report_fake_data() ? "true" : "false") << ", ";
|
||||
|
||||
for (const auto& count : protoConfig.sys_meminfo_counters()) {
|
||||
args << "sys_meminfo_counters: " << std::to_string(count) << ", ";
|
||||
}
|
||||
for (const auto& count : protoConfig.sys_vmeminfo_counters()) {
|
||||
args << "sys_vmeminfo_counters: " << std::to_string(count) << ", ";
|
||||
}
|
||||
for (const auto& p : protoConfig.pid()) {
|
||||
args << "pid: " << COMMON::GetProcessNameByPid(p) << ", ";
|
||||
}
|
||||
return args.str();
|
||||
}
|
||||
|
||||
|
||||
template <typename T> void MemoryDataPlugin::WriteMeminfo(T& memoryData)
|
||||
{
|
||||
int readsize = ReadFile(meminfoFd_);
|
||||
|
@ -126,6 +126,7 @@ ohos_executable("native_daemon") {
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokensetproc_shared",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hisysevent:libhisysevent",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"openssl:libcrypto_shared",
|
||||
@ -202,6 +203,7 @@ ohos_shared_library("libnative_daemon_client") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hisysevent:libhisysevent",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"os_account:os_account_innerkits",
|
||||
|
@ -104,6 +104,7 @@ public:
|
||||
int32_t CreatePluginSession();
|
||||
void RegisterWriter(const std::shared_ptr<Writer> writer);
|
||||
void WriteHookConfig();
|
||||
std::string GetCmdArgs(NativeHookConfig traceConfig);
|
||||
std::pair<int, int> GetFds(int32_t pid, const std::string& name);
|
||||
inline void SetSaServiceConfig(bool saFlag, bool isProtobufSerialize)
|
||||
{
|
||||
|
@ -46,6 +46,7 @@ private:
|
||||
void FillTaskConfigContext(int32_t pid, const std::string& name);
|
||||
bool ProtocolProc(SocketContext &context, uint32_t pnum, const int8_t *buf, const uint32_t size) override;
|
||||
void DelayedShutdown(bool cancel);
|
||||
std::string GetCmdArgs(std::shared_ptr<NativeMemoryProfilerSaConfig>& config);
|
||||
|
||||
private:
|
||||
struct TaskConfig {
|
||||
|
@ -166,9 +166,45 @@ void NativeMemoryProfilerSaService::StopHook(uint32_t pid, std::string name, boo
|
||||
}
|
||||
}
|
||||
|
||||
std::string NativeMemoryProfilerSaService::GetCmdArgs(std::shared_ptr<NativeMemoryProfilerSaConfig>& config)
|
||||
{
|
||||
std::stringstream args;
|
||||
args << "pid: " << COMMON::GetProcessNameByPid(config->pid_) << ", ";
|
||||
args << "filter_size: " << config->filterSize_ << ", ";
|
||||
args << "max_stack_depth: " << std::to_string(config->maxStackDepth_) << ", ";
|
||||
args << "process_name: " << config->processName_ << ", ";
|
||||
args << "malloc_disable: " << (config->mallocDisable_ ? "true" : "false") << ", ";
|
||||
args << "mmap_disable: " << (config->mmapDisable_ ? "true" : "false") << ", ";
|
||||
args << "free_stack_report: " << (config->freeStackData_ ? "true" : "false") << ", ";
|
||||
args << "munmap_stack_report: " << (config->munmapStackData_ ? "true" : "false") << ", ";
|
||||
args << "malloc_free_matching_interval: " << std::to_string(config->mallocFreeMatchingInterval_) << ", ";
|
||||
args << "malloc_free_matching_cnt: " << std::to_string(config->mallocFreeMatchingCnt_) << ", ";
|
||||
args << "string_compressed: " << (config->stringCompressed_ ? "true" : "false") << ", ";
|
||||
args << "fp_unwind: " << (config->fpUnwind_ ? "true" : "false") << ", ";
|
||||
args << "blocked: " << (config->blocked_ ? "true" : "false") << ", ";
|
||||
args << "record_accurately: " << (config->recordAccurately_ ? "true" : "false") << ", ";
|
||||
args << "startup_mode: " << (config->startupMode_ ? "true" : "false") << ", ";
|
||||
args << "memtrace_enable: " << (config->memtraceEnable_ ? "true" : "false") << ", ";
|
||||
args << "offline_symbolization: " << (config->offlineSymbolization_ ? "true" : "false") << ", ";
|
||||
args << "callframe_compress: " << (config->callframeCompress_ ? "true" : "false") << ", ";
|
||||
args << "statistics_interval: " << std::to_string(config->statisticsInterval_) << ", ";
|
||||
args << "clock: " << std::to_string(config->clockId_) << ", ";
|
||||
args << "sample_interval: " << std::to_string(config->sampleInterval_) << ", ";
|
||||
args << "response_library_mode: " << (config->responseLibraryMode_ ? "true" : "false") << ", ";
|
||||
args << "js_stack_report: " << std::to_string(config->jsStackReport_) << ", ";
|
||||
args << "max_js_stack_depth: " << std::to_string(config->maxJsStackDepth_) << ", ";
|
||||
args << "filter_napi_name: " << config->filterNapiName_ << ", ";
|
||||
args << "nmd_pid: " << std::to_string(config->nmdPid_) << ", ";
|
||||
args << "nmd_type: " << std::to_string(config->nmdType_) << ", ";
|
||||
return args.str();
|
||||
}
|
||||
|
||||
int32_t NativeMemoryProfilerSaService::StartHook(std::shared_ptr<NativeMemoryProfilerSaConfig>& config, uint32_t fd)
|
||||
{
|
||||
auto args = GetCmdArgs(config);
|
||||
if (!HasProfilingPermission()) {
|
||||
COMMON::PluginWriteToHisysevent("native_hook_plugin", "hiview", args, COMMON::ErrorType::RET_NO_PERMISSION,
|
||||
"no profiling permission");
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "StartHook failed, no profiling permission!");
|
||||
return RET_ERR;
|
||||
}
|
||||
@ -183,6 +219,8 @@ int32_t NativeMemoryProfilerSaService::StartHook(std::shared_ptr<NativeMemoryPro
|
||||
PROFILER_LOG_INFO(LOG_CORE, "file path: %s", config->filePath_.c_str());
|
||||
|
||||
if (!CheckConfig(config, fd)) {
|
||||
COMMON::PluginWriteToHisysevent("native_hook_plugin", "hiview", args, COMMON::ErrorType::RET_MSG_EMPTY,
|
||||
"check config failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
@ -190,6 +228,8 @@ int32_t NativeMemoryProfilerSaService::StartHook(std::shared_ptr<NativeMemoryPro
|
||||
auto retFile = COMMON::CheckNotExistsFilePath(config->filePath_);
|
||||
if (!retFile.first) {
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:check file path %s fail", __func__, config->filePath_.c_str());
|
||||
COMMON::PluginWriteToHisysevent("native_hook_plugin", "hiview", args, COMMON::ErrorType::RET_IVALID_PATH,
|
||||
"check file path failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
int fdTemp = open(retFile.second.c_str(), O_RDWR | O_CREAT, FILE_MODE);
|
||||
@ -214,6 +254,8 @@ int32_t NativeMemoryProfilerSaService::StartHook(std::shared_ptr<NativeMemoryPro
|
||||
}
|
||||
}
|
||||
if (hook->CreatePluginSession() != RET_OK) {
|
||||
COMMON::PluginWriteToHisysevent("native_hook_plugin", "hiview", args, COMMON::ErrorType::RET_FAIL,
|
||||
"create pluginsession failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
hook->WriteHookConfig();
|
||||
@ -225,6 +267,8 @@ int32_t NativeMemoryProfilerSaService::StartHook(std::shared_ptr<NativeMemoryPro
|
||||
true);
|
||||
if (timerFd == -1) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "NativeMemoryProfilerSaService Start Schedule Task failed");
|
||||
COMMON::PluginWriteToHisysevent("native_hook_plugin", "hiview", args, COMMON::ErrorType::RET_FAIL,
|
||||
"start schedule task failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
|
||||
@ -248,6 +292,7 @@ int32_t NativeMemoryProfilerSaService::StartHook(std::shared_ptr<NativeMemoryPro
|
||||
}
|
||||
++taskNum_;
|
||||
DelayedShutdown(true);
|
||||
COMMON::PluginWriteToHisysevent("native_hook_plugin", "hiview", args, COMMON::ErrorType::RET_SUCC, "success");
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,7 @@ ohos_unittest("native_memory_profiler_sa_ut") {
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"c_utils:utils",
|
||||
"googletest:gtest",
|
||||
"hisysevent:libhisysevent",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"openssl:libcrypto_shared",
|
||||
|
@ -763,6 +763,45 @@ void HookManager::StartPluginSession()
|
||||
PROFILER_LOG_INFO(LOG_CORE, "StartPluginSession: pid(%d) is less or equal zero.", item->pid);
|
||||
}
|
||||
}
|
||||
int ret = COMMON::PluginWriteToHisysevent("native_hook_plugin", "sh", GetCmdArgs(hookConfig_),
|
||||
COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "hisysevent report native_hook_plugin result:%d", ret);
|
||||
}
|
||||
|
||||
std::string HookManager::GetCmdArgs(NativeHookConfig traceConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
args << "pid: " << COMMON::GetProcessNameByPid(traceConfig.pid()) << ", ";
|
||||
args << "save_file: " << (traceConfig.save_file() ? "true" : "false") << ", ";
|
||||
args << "filter_size: " << std::to_string(traceConfig.filter_size()) << ", ";
|
||||
args << "smb_pages: " << std::to_string(traceConfig.smb_pages()) << ", ";
|
||||
args << "max_stack_depth: " << std::to_string(traceConfig.max_stack_depth()) << ", ";
|
||||
args << "process_name: " << traceConfig.process_name() << ", ";
|
||||
args << "malloc_disable: " << (traceConfig.malloc_disable() ? "true" : "false") << ", ";
|
||||
args << "mmap_disable: " << (traceConfig.mmap_disable() ? "true" : "false") << ", ";
|
||||
args << "free_stack_report: " << (traceConfig.free_stack_report() ? "true" : "false") << ", ";
|
||||
args << "munmap_stack_report: " << (traceConfig.munmap_stack_report() ? "true" : "false") << ", ";
|
||||
args << "malloc_free_matching_interval: " << std::to_string(traceConfig.malloc_free_matching_interval()) << ", ";
|
||||
args << "malloc_free_matching_cnt: " << std::to_string(traceConfig.malloc_free_matching_cnt()) << ", ";
|
||||
args << "string_compressed: " << (traceConfig.string_compressed() ? "true" : "false") << ", ";
|
||||
args << "fp_unwind: " << (traceConfig.fp_unwind() ? "true" : "false") << ", ";
|
||||
args << "blocked: " << (traceConfig.blocked() ? "true" : "false") << ", ";
|
||||
args << "record_accurately: " << (traceConfig.record_accurately() ? "true" : "false") << ", ";
|
||||
args << "startup_mode: " << (traceConfig.startup_mode() ? "true" : "false") << ", ";
|
||||
args << "memtrace_enable: " << (traceConfig.memtrace_enable() ? "true" : "false") << ", ";
|
||||
args << "offline_symbolization: " << (traceConfig.offline_symbolization() ? "true" : "false") << ", ";
|
||||
args << "callframe_compress: " << (traceConfig.callframe_compress() ? "true" : "false") << ", ";
|
||||
args << "statistics_interval: " << std::to_string(traceConfig.statistics_interval()) << ", ";
|
||||
args << "clock: " << traceConfig.clock() << ", ";
|
||||
args << "sample_interval: " << std::to_string(traceConfig.sample_interval()) << ", ";
|
||||
args << "response_library_mode: " << (traceConfig.response_library_mode() ? "true" : "false") << ", ";
|
||||
args << "js_stack_report: " << std::to_string(traceConfig.js_stack_report()) << ", ";
|
||||
args << "max_js_stack_depth: " << std::to_string(traceConfig.max_js_stack_depth()) << ", ";
|
||||
args << "filter_napi_name: " << traceConfig.filter_napi_name() << ", ";
|
||||
for (const auto& pid : traceConfig.expand_pids()) {
|
||||
args << "expand_pids: " << std::to_string(pid) << ", ";
|
||||
}
|
||||
return args.str();
|
||||
}
|
||||
|
||||
void HookManager::WriteHookConfig()
|
||||
|
@ -740,7 +740,8 @@ public:
|
||||
HLOGD("map is exec not abc file , the symbol file is:%s", map_->name.c_str());
|
||||
return false;
|
||||
}
|
||||
if (StringEndsWith(filePath_, ".hap") || StringEndsWith(filePath_, ".hsp")) {
|
||||
if (StringEndsWith(filePath_, ".hap") || StringEndsWith(filePath_, ".hsp")
|
||||
|| StringEndsWith(filePath_, ".hqf")) {
|
||||
dfxExtractor_ = std::make_unique<DfxExtractor>(filePath_);
|
||||
if (dfxExtractor_ == nullptr) {
|
||||
HLOGD("DfxExtractor create failed.");
|
||||
|
@ -526,7 +526,8 @@ int32_t GetProcessPid(const std::string& processName)
|
||||
bool IsArkJsFile(const std::string& filepath)
|
||||
{
|
||||
return (StringEndsWith(filepath, ".hap") || StringEndsWith(filepath, ".hsp") ||
|
||||
StringStartsWith(filepath, "[anon:ArkTS Code") || StringEndsWith(filepath, ".abc"));
|
||||
StringStartsWith(filepath, "[anon:ArkTS Code") || StringEndsWith(filepath, ".abc")
|
||||
|| StringEndsWith(filepath, ".hqf"));
|
||||
}
|
||||
} // namespace NativeDaemon
|
||||
} // namespace Developtools
|
||||
|
@ -126,6 +126,7 @@ ohos_unittest("native_daemon_ut") {
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"faultloggerd:libunwinder",
|
||||
"googletest:gtest",
|
||||
"hisysevent:libhisysevent",
|
||||
"init:libbegetutil",
|
||||
"openssl:libcrypto_shared",
|
||||
"protobuf:protobuf_lite",
|
||||
|
@ -39,6 +39,7 @@ ohos_source_set("networkplugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
@ -47,7 +48,10 @@ ohos_source_set("networkplugin_source") {
|
||||
ohos_shared_library("networkplugin") {
|
||||
output_name = "networkplugin"
|
||||
version_script = "libnetwork_plugin.map"
|
||||
deps = [ ":networkplugin_source" ]
|
||||
deps = [
|
||||
":networkplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
]
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [ "hilog:libhilog_base" ]
|
||||
|
@ -93,6 +93,7 @@ protected:
|
||||
bool ReadSystemTxRxBytes(NetSystemData &systemData);
|
||||
void AddNetDetails(NetworkCell& cell, NetDetails& data);
|
||||
void AddNetSystemDetails(NetSystemData& systemData, NetSystemDetails& data);
|
||||
std::string GetCmdArgs(NetworkConfig traceConfig);
|
||||
// for UT
|
||||
void setPathForTest(std::string path)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "buffer_splitter.h"
|
||||
#include "common.h"
|
||||
#include "network_plugin_result.pbencoder.h"
|
||||
#include "securec.h"
|
||||
|
||||
@ -47,11 +48,22 @@ int NetworkPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
pidUid_.emplace(pid, GetUid(pid));
|
||||
}
|
||||
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:NetworkPlugin, start success!", __func__);
|
||||
|
||||
int ret = COMMON::PluginWriteToHisysevent("network_plugin", "sh", GetCmdArgs(protoConfig_),
|
||||
COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s: NetworkPlugin success! hisysevent report result:%d", __func__, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string NetworkPlugin::GetCmdArgs(NetworkConfig traceConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
for (const auto& p : traceConfig.pid()) {
|
||||
args << "pid: " << COMMON::GetProcessNameByPid(p) << ", ";
|
||||
}
|
||||
args << "test_file: " << traceConfig.test_file();
|
||||
return args.str();
|
||||
}
|
||||
|
||||
template <typename T> bool NetworkPlugin::WriteNetWorkData(T& networkDatasProto)
|
||||
{
|
||||
std::string file = GetRateNodePath();
|
||||
|
@ -26,6 +26,7 @@ ohos_unittest("networkplugin_ut") {
|
||||
module_out_path = module_output_path
|
||||
sources = [ "unittest/network_plugin_test.cpp" ]
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/network_plugin:networkplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/network_data:network_data_cpp",
|
||||
]
|
||||
|
@ -28,6 +28,7 @@ ohos_fuzztest("NetworkStartPluginFuzzTest") {
|
||||
]
|
||||
sources = [ "networkstartplugin_fuzzer.cpp" ]
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/network_plugin:networkplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/network_data:network_data_cpp",
|
||||
]
|
||||
|
@ -49,6 +49,7 @@ ohos_source_set("network_profiler_service") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hisysevent:libhisysevent",
|
||||
"init:libbegetutil",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -71,9 +71,13 @@ public:
|
||||
bool ResetWriter(uint32_t pluginId) override;
|
||||
void SetCommandPoller(const std::shared_ptr<CommandPoller>& p) override;
|
||||
bool RegisterAgentPlugin(const std::string& pluginPath);
|
||||
std::string GetCmdArgs(NetworkProfilerConfig traceConfig);
|
||||
|
||||
private:
|
||||
bool CheckConfig();
|
||||
bool CheckConfigPid(std::set<int32_t>& pidCache);
|
||||
bool CheckStartupProcessName();
|
||||
bool CheckRestartProcessName(std::set<int32_t>& pidCache);
|
||||
bool HandleNetworkProfilerContext(const std::shared_ptr<NetworkProfilerCtx>& ctx);
|
||||
clockid_t GetClockId(NetworkProfilerConfig::ClockId clockType);
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "network_profiler_manager.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
@ -57,9 +58,8 @@ void NetworkProfilerManager::Init()
|
||||
RegisterAgentPlugin("network-profiler");
|
||||
}
|
||||
|
||||
bool NetworkProfilerManager::CheckConfig()
|
||||
bool NetworkProfilerManager::CheckConfigPid(std::set<int32_t>& pidCache)
|
||||
{
|
||||
std::set<int32_t> pidCache;
|
||||
for (const auto& pid : config_.pid()) {
|
||||
if (pid > 0) {
|
||||
if (COMMON::IsUserMode() && (!COMMON::CheckApplicationPermission(pid, ""))) {
|
||||
@ -70,17 +70,19 @@ bool NetworkProfilerManager::CheckConfig()
|
||||
if (stat(pidPath.c_str(), &statBuf) != 0) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "%s: hook process does not exist", __func__);
|
||||
return false;
|
||||
} else {
|
||||
auto [iter, ret] = pidCache.emplace(pid);
|
||||
if (ret) {
|
||||
networkCtx_.emplace_back(std::make_shared<NetworkProfilerCtx>(pid));
|
||||
paramValue_ += std::to_string(pid) + ",";
|
||||
}
|
||||
continue;
|
||||
}
|
||||
auto [iter, ret] = pidCache.emplace(pid);
|
||||
if (ret) {
|
||||
networkCtx_.emplace_back(std::make_shared<NetworkProfilerCtx>(pid));
|
||||
paramValue_ += std::to_string(pid) + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NetworkProfilerManager::CheckStartupProcessName()
|
||||
{
|
||||
for (const auto& name : config_.startup_process_name()) {
|
||||
if (name.empty()) {
|
||||
continue;
|
||||
@ -98,7 +100,11 @@ bool NetworkProfilerManager::CheckConfig()
|
||||
networkCtx_.emplace_back(std::make_shared<NetworkProfilerCtx>(name));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NetworkProfilerManager::CheckRestartProcessName(std::set<int32_t>& pidCache)
|
||||
{
|
||||
for (const auto& name : config_.restart_process_name()) {
|
||||
if (name.empty()) {
|
||||
continue;
|
||||
@ -123,6 +129,21 @@ bool NetworkProfilerManager::CheckConfig()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NetworkProfilerManager::CheckConfig()
|
||||
{
|
||||
std::set<int32_t> pidCache;
|
||||
if (!CheckConfigPid(pidCache)) {
|
||||
return false;
|
||||
}
|
||||
if (!CheckStartupProcessName()) {
|
||||
return false;
|
||||
}
|
||||
if (!CheckRestartProcessName(pidCache)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config_.flush_interval() == 0) {
|
||||
config_.set_flush_interval(1);
|
||||
@ -170,15 +191,41 @@ bool NetworkProfilerManager::StartNetworkProfiler()
|
||||
|
||||
int ret = SystemSetParameter(PARAM_KAY.c_str(), paramValue_.c_str());
|
||||
PROFILER_LOG_INFO(LOG_CORE, "StartNetworkProfiler parameter: %s", paramValue_.c_str());
|
||||
|
||||
auto args = GetCmdArgs(config_);
|
||||
if (ret < 0) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "StartNetworkProfiler set parameter failed");
|
||||
COMMON::PluginWriteToHisysevent("network_profiler_plugin", "sh", args, COMMON::ErrorType::RET_FAIL,
|
||||
"set param failed");
|
||||
return false;
|
||||
} else {
|
||||
PROFILER_LOG_INFO(LOG_CORE, "StartNetworkProfiler set parameter success");
|
||||
}
|
||||
|
||||
int res = COMMON::PluginWriteToHisysevent("memory_plugin", "sh", args, COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "hisysevent report network_profiler_plugin ret: %d.", res);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string NetworkProfilerManager::GetCmdArgs(NetworkProfilerConfig traceConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
for (const auto& p : traceConfig.pid()) {
|
||||
args << "pid: " << COMMON::GetProcessNameByPid(p) << ", ";
|
||||
}
|
||||
for (const auto& name : traceConfig.startup_process_name()) {
|
||||
args << "startup_process_name: " << name << ", ";
|
||||
}
|
||||
for (const auto& name : traceConfig.restart_process_name()) {
|
||||
args << "restart_process_name: " << name << ", ";
|
||||
}
|
||||
args << "clock_id: " << std::to_string(traceConfig.clock_id()) << ", ";
|
||||
args << "smb_pages: " << std::to_string(traceConfig.smb_pages()) << ", ";
|
||||
args << "flush_interval: " << std::to_string(traceConfig.flush_interval()) << ", ";
|
||||
args << "block: " << (traceConfig.block() ? "true" : "false");
|
||||
return args.str();
|
||||
}
|
||||
|
||||
void NetworkProfilerManager::StopNetworkProfiler()
|
||||
{
|
||||
int ret = SystemSetParameter(PARAM_KAY.c_str(), "");
|
||||
|
@ -37,6 +37,7 @@ ohos_source_set("processplugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
@ -48,7 +49,10 @@ ohos_source_set("processplugin_source") {
|
||||
ohos_shared_library("processplugin") {
|
||||
output_name = "processplugin"
|
||||
version_script = "libprocess_plugin.map"
|
||||
deps = [ ":processplugin_source" ]
|
||||
deps = [
|
||||
":processplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
]
|
||||
if (current_toolchain != host_toolchain) {
|
||||
defines = [ "HAVE_HILOG" ]
|
||||
external_deps = [ "hilog:libhilog_base" ]
|
||||
|
@ -95,6 +95,8 @@ private:
|
||||
|
||||
template <typename T> bool WritePssData(int pid, T& processinfo);
|
||||
|
||||
std::string GetCmdArgs(ProcessConfig traceConfig);
|
||||
|
||||
ProcessConfig protoConfig_;
|
||||
std::unique_ptr<uint8_t[]> buffer_;
|
||||
std::vector<int32_t> pids_;
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "buffer_splitter.h"
|
||||
#include "common.h"
|
||||
#include "hisysevent.h"
|
||||
#include "process_plugin_result.pbencoder.h"
|
||||
#include "securec.h"
|
||||
|
||||
@ -56,10 +58,22 @@ int ProcessDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, RET_FAIL,
|
||||
"%s:parseFromArray failed!", __func__);
|
||||
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:start success!", __func__);
|
||||
int ret = COMMON::PluginWriteToHisysevent("process_plugin", "sh", GetCmdArgs(protoConfig_),
|
||||
COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s: success! hisysevent report process_plugin result:%d", __func__, ret);
|
||||
return RET_SUCC;
|
||||
}
|
||||
|
||||
std::string ProcessDataPlugin::GetCmdArgs(ProcessConfig traceConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
args << "report_process_tree: " << (traceConfig.report_process_tree() ? "true" : "false") << ", ";
|
||||
args << "report_cpu: " << (traceConfig.report_cpu() ? "true" : "false") << ", ";
|
||||
args << "report_diskio: " << (traceConfig.report_diskio() ? "true" : "false") << ", ";
|
||||
args << "report_pss: " << (traceConfig.report_pss() ? "true" : "false");
|
||||
return args.str();
|
||||
}
|
||||
|
||||
int ProcessDataPlugin::ReportOptimize(RandomWriteCtx* randomWrite)
|
||||
{
|
||||
ProtoEncoder::ProcessData dataProto(randomWrite);
|
||||
|
@ -26,6 +26,7 @@ ohos_unittest("processplugin_ut") {
|
||||
module_out_path = module_output_path
|
||||
sources = [ "unittest/process_plugin_unittest.cpp" ]
|
||||
deps = [
|
||||
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||
"${OHOS_PROFILER_DIR}/device/plugins/process_plugin:processplugin_source",
|
||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/process_data:process_data_cpp",
|
||||
]
|
||||
|
@ -36,6 +36,7 @@ ohos_shared_library("xpowerplugin") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
void OptimizeCallback(const std::uint32_t messageType, const uint8_t* protoData, size_t protoSize);
|
||||
void SetWriter(WriterStruct* writer);
|
||||
bool StartPowerManager(std::uint32_t messageType, std::string& bundleName);
|
||||
std::string GetCmdArgs(XpowerConfig traceConfig);
|
||||
private:
|
||||
void* powerClientHandle_ = nullptr;
|
||||
XpowerConfig protoConfig_;
|
||||
|
@ -48,6 +48,17 @@ XpowerPlugin::~XpowerPlugin()
|
||||
}
|
||||
}
|
||||
|
||||
std::string XpowerPlugin::GetCmdArgs(XpowerConfig traceConfig)
|
||||
{
|
||||
std::stringstream args;
|
||||
args << "bundle_name: " << traceConfig.bundle_name() << ", ";
|
||||
|
||||
for (const auto& type : traceConfig.message_type()) {
|
||||
args << "type: " << std::to_string(type) << ", ";
|
||||
}
|
||||
return args.str();
|
||||
}
|
||||
|
||||
int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
||||
{
|
||||
PROFILER_LOG_INFO(LOG_CORE, "%s:config data -->configSize=%d", __func__, configSize);
|
||||
@ -63,8 +74,11 @@ int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
||||
messageType |= mesType;
|
||||
}
|
||||
}
|
||||
auto args = GetCmdArgs(protoConfig_);
|
||||
if (messageType == 0) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "XpowerPlugin error : messageType is empty!");
|
||||
COMMON::PluginWriteToHisysevent("xpower_plugin", "sh", args, COMMON::ErrorType::RET_MSG_EMPTY,
|
||||
"messageType is empty");
|
||||
return -1;
|
||||
}
|
||||
PROFILER_LOG_INFO(LOG_CORE, "bundleName is %s,messagetype is %d", bundleName.c_str(), messageType);
|
||||
@ -73,12 +87,16 @@ int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
||||
(messageType & OptimizeMessageType::MESSAGE_ABNORMAL_EVENTS) != 0) {
|
||||
if (bundleName.empty()) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "XpowerPlugin error : bundle name is empty!");
|
||||
COMMON::PluginWriteToHisysevent("xpower_plugin", "sh", args, COMMON::ErrorType::RET_MSG_EMPTY,
|
||||
"bundle name is empty");
|
||||
return -1;
|
||||
}
|
||||
// check bundleName
|
||||
int32_t uid = COMMON::GetPackageUid(bundleName);
|
||||
if (uid < AID_HAP_START || uid > AID_HAP_END) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "the bundle name %s is not supported", bundleName.c_str());
|
||||
COMMON::PluginWriteToHisysevent("xpower_plugin", "sh", args, COMMON::ErrorType::RET_NOT_SUPPORT,
|
||||
"bundle name is not supported");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -87,6 +105,8 @@ int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
||||
bool isExsit = COMMON::IsProcessExist(bundleName, processId);
|
||||
if (!isExsit) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "%s:the process %s does not exist.", __func__, bundleName.c_str());
|
||||
COMMON::PluginWriteToHisysevent("xpower_plugin", "sh", args, COMMON::ErrorType::RET_IVALID_PID,
|
||||
"the process does not exist");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -94,9 +114,13 @@ int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
||||
// 加载对应so 库文件
|
||||
if (!StartPowerManager(messageType, bundleName)) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "start power manager failed!");
|
||||
COMMON::PluginWriteToHisysevent("xpower_plugin", "sh", args, COMMON::ErrorType::RET_FAIL,
|
||||
"start power manager failed");
|
||||
return -1;
|
||||
}
|
||||
PROFILER_LOG_INFO(LOG_CORE, "finish register the callback function:%s", __func__);
|
||||
int ret = COMMON::PluginWriteToHisysevent("xpower_plugin", "sh", args, COMMON::ErrorType::RET_SUCC, "success");
|
||||
PROFILER_LOG_INFO(LOG_CORE, "finish register the callback function:%s, hisysevent report xpower_plugin ret: %d.",
|
||||
__func__, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,8 @@ void ByTrace::SetTraceConfig(int mSum, int mInterval, long long mThreshold, int
|
||||
threshold = mThreshold;
|
||||
lowfps = mLowfps;
|
||||
curNum = mCurNum;
|
||||
LOGI("ByTrace::SetTraceConfig mSum(%d) mInterval(%d) mThreshold(%lld) mLowfps(%d) mCurNum(%d)", mSum, mInterval,
|
||||
mThreshold, mLowfps, mCurNum);
|
||||
LOGD("ByTrace::SetTraceConfig mSum(%d) mInterval(%d) mThreshold(%lld) mLowfps(%d) mCurNum(%d)",
|
||||
mSum, mInterval, mThreshold, mLowfps, mCurNum);
|
||||
}
|
||||
void ByTrace::ThreadGetTrace() const
|
||||
{
|
||||
@ -45,7 +45,7 @@ void ByTrace::ThreadGetTrace() const
|
||||
std::string traceFile = "/data/local/tmp/sptrace_" + time + ".ftrace";
|
||||
std::string traceCmdExe = cmdString + traceFile;
|
||||
SPUtils::LoadCmd(traceCmdExe, result);
|
||||
LOGI("TRACE threadGetTrace CMD(%s)", traceCmdExe.c_str());
|
||||
LOGD("TRACE threadGetTrace CMD(%s)", traceCmdExe.c_str());
|
||||
}
|
||||
TraceStatus ByTrace::CheckFpsJitters(std::vector<long long> jitters, int cfps) const
|
||||
{
|
||||
|
@ -81,14 +81,14 @@ std::map<std::string, std::string> CPU::ItemData()
|
||||
}
|
||||
}
|
||||
|
||||
LOGI("CPU::ItemData map size(%u)", result.size());
|
||||
LOGD("CPU::ItemData map size(%u)", result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
void CPU::SetPackageName(const std::string &pName)
|
||||
{
|
||||
packageName = pName;
|
||||
LOGI("CPU SetPackageName name(%s)", pName.c_str());
|
||||
LOGD("CPU SetPackageName name(%s)", pName.c_str());
|
||||
}
|
||||
|
||||
void CPU::SetProcessId(const std::string &pid)
|
||||
@ -107,8 +107,8 @@ std::vector<CpuFreqs> CPU::GetCpuFreq()
|
||||
cpuFreqs.cpuId = cpufreq[i].cpuId;
|
||||
cpuFreqs.curFreq = cpufreq[i].curFreq;
|
||||
cpuFrequency.push_back(cpuFreqs);
|
||||
LOGI("cpuFreqs.cpuId: %s", std::to_string(cpufreq[i].cpuId).c_str());
|
||||
LOGI("cpuFreqs.curFreq: %s", std::to_string(cpufreq[i].curFreq).c_str());
|
||||
LOGD("cpuFreqs.cpuId: %s, cpuFreqs.curFreq: %s",
|
||||
std::to_string(cpufreq[i].cpuId).c_str(), std::to_string(cpufreq[i].curFreq).c_str());
|
||||
}
|
||||
return cpuFrequency;
|
||||
}
|
||||
@ -133,14 +133,12 @@ std::vector<CpuUsageInfos> CPU::GetCpuUsage()
|
||||
cpuUsageInfos.irqUsage = cpuInfo.irqUsage;
|
||||
cpuUsageInfos.softIrqUsage = cpuInfo.softIrqUsage;
|
||||
workload.push_back(cpuUsageInfos);
|
||||
LOGI("UsageCpuId: %s", cpuInfo.cpuId.c_str());
|
||||
LOGI("userUsage: %s", std::to_string(cpuInfo.userUsage).c_str());
|
||||
LOGI("niceUsage: %s", std::to_string(cpuInfo.niceUsage).c_str());
|
||||
LOGI("systemUsage: %s", std::to_string(cpuInfo.systemUsage).c_str());
|
||||
LOGI("idleUsage: %s", std::to_string(cpuInfo.idleUsage).c_str());
|
||||
LOGI("ioWaitUsage: %s", std::to_string(cpuInfo.ioWaitUsage).c_str());
|
||||
LOGI("irqUsage: %s", std::to_string(cpuInfo.irqUsage).c_str());
|
||||
LOGI("softIrqUsage: %s", std::to_string(cpuInfo.softIrqUsage).c_str());
|
||||
LOGD("UsageCpuId: %s, userUsage: %s, niceUsage: %s, systemUsage: %s",
|
||||
"idleUsage: %s, ioWaitUsage: %s, irqUsage: %s, softIrqUsage: %s",
|
||||
cpuInfo.cpuId.c_str(), std::to_string(cpuInfo.userUsage).c_str(),
|
||||
std::to_string(cpuInfo.niceUsage).c_str(), std::to_string(cpuInfo.systemUsage).c_str(),
|
||||
std::to_string(cpuInfo.idleUsage).c_str(), std::to_string(cpuInfo.ioWaitUsage).c_str(),
|
||||
std::to_string(cpuInfo.irqUsage).c_str(), std::to_string(cpuInfo.softIrqUsage).c_str());
|
||||
}
|
||||
return workload;
|
||||
}
|
||||
@ -161,12 +159,10 @@ std::map<std::string, std::string> CPU::GetSysProcessCpuLoad() const
|
||||
processCpuInfo["ProcCpuUsage"] = std::to_string(data.cpuUsage * oneHundred);
|
||||
processCpuInfo["ProcUCpuUsage"] = std::to_string(data.uCpuUsage * oneHundred);
|
||||
processCpuInfo["ProcSCpuUsage"] = std::to_string(data.sCpuUsage * oneHundred);
|
||||
LOGI("ProcId: %s", std::to_string(data.pid).c_str());
|
||||
LOGI("ProcAppName: %s", data.procName.c_str());
|
||||
LOGI("ProcCpuLoad: %s", std::to_string(data.cpuLoad).c_str());
|
||||
LOGI("ProcCpuUsage: %s", std::to_string(data.cpuUsage).c_str());
|
||||
LOGI("ProcUCpuUsage: %s", std::to_string(data.uCpuUsage).c_str());
|
||||
LOGI("ProcSCpuUsage: %s", std::to_string(data.sCpuUsage).c_str());
|
||||
LOGD("ProcId: %s, ProcAppName: %s, ProcCpuLoad: %s, ProcCpuUsage: %s, ProcUCpuUsage: %s, ProcSCpuUsage: %s",
|
||||
std::to_string(data.pid).c_str(), data.procName.c_str(), std::to_string(data.cpuLoad).c_str(),
|
||||
std::to_string(data.cpuUsage).c_str(), std::to_string(data.uCpuUsage).c_str(),
|
||||
std::to_string(data.sCpuUsage).c_str());
|
||||
} else {
|
||||
processCpuInfo["ProcId"] = "NA";
|
||||
processCpuInfo["ProcAppName"] = packageName;
|
||||
|
@ -55,7 +55,7 @@ std::map<std::string, std::string> Capture::ItemData()
|
||||
}
|
||||
result["capture"] = path;
|
||||
|
||||
LOGI("Capture::ItemData map size(%u)", result.size());
|
||||
LOGD("Capture::ItemData map size(%u)", result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -76,16 +76,16 @@ void Capture::ThreadGetCatch()
|
||||
if (!SPUtils::FileAccess(captureDir)) {
|
||||
std::string capturePath = CMD_COMMAND_MAP.at(CmdCommand::CREAT_DIR) + captureDir;
|
||||
if (!SPUtils::LoadCmd(capturePath, cmdResult)) {
|
||||
LOGI("%s capture not be created!", captureDir.c_str());
|
||||
LOGE("%s capture not be created!", captureDir.c_str());
|
||||
return;
|
||||
} else {
|
||||
LOGI("%s created successfully!", captureDir.c_str());
|
||||
LOGD("%s created successfully!", captureDir.c_str());
|
||||
}
|
||||
};
|
||||
std::ostringstream errorRecv;
|
||||
auto fd = open(savePath.c_str(), O_RDWR | O_CREAT, 0666);
|
||||
if (fd == -1) {
|
||||
LOGI("Failed to open file: %s", savePath.c_str());
|
||||
LOGE("Failed to open file: %s", savePath.c_str());
|
||||
}
|
||||
if (!TakeScreenCap(savePath)) {
|
||||
LOGE("Screen Capture Failed!");
|
||||
@ -102,10 +102,10 @@ void Capture::ThreadGetCatchSocket(const std::string &captureTime) const
|
||||
if (!SPUtils::FileAccess(captureDir)) {
|
||||
std::string capturePath = CMD_COMMAND_MAP.at(CmdCommand::CREAT_DIR) + captureDir;
|
||||
if (!SPUtils::LoadCmd(capturePath, cmdResult)) {
|
||||
LOGI("%s capture not be created!", captureDir.c_str());
|
||||
LOGE("%s capture not be created!", captureDir.c_str());
|
||||
return;
|
||||
} else {
|
||||
LOGI("%s created successfully!", captureDir.c_str());
|
||||
LOGD("%s created successfully!", captureDir.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@ -114,13 +114,13 @@ void Capture::ThreadGetCatchSocket(const std::string &captureTime) const
|
||||
std::cout << "" << std::endl;
|
||||
}
|
||||
|
||||
auto fd = open(realPath, O_RDWR | O_CREAT, 0644);
|
||||
auto fd = open(savePath.c_str(), O_RDWR | O_CREAT, 0644);
|
||||
if (fd == -1) {
|
||||
LOGI("Failed to open file: %s", savePath.c_str());
|
||||
LOGE("Failed to open file: %s", savePath.c_str());
|
||||
}
|
||||
std::string snapshot = CMD_COMMAND_MAP.at(CmdCommand::SNAPSHOT);
|
||||
if (!SPUtils::LoadCmd(snapshot + savePath, cmdResult)) {
|
||||
LOGI("snapshot_display command failed!");
|
||||
LOGE("snapshot_display command failed!");
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ std::map<std::string, std::string> DDR::ItemData()
|
||||
if (result.find("ddrFrequency") != result.end() && result["ddrFrequency"].empty()) {
|
||||
result["ddrFrequency"] = "NA";
|
||||
}
|
||||
LOGI("DDR::ItemData map size(%u)", result.size());
|
||||
LOGD("DDR::ItemData map size(%u)", result.size());
|
||||
return result;
|
||||
}
|
||||
long long DDR::GetDdrFreq()
|
||||
|
@ -25,14 +25,12 @@ void Dubai::DumpDubaiBegin()
|
||||
std::string result;
|
||||
std::string dumpBubaiB = HIDUMPER_CMD_MAP.at(HidumperCmd::DUMPER_DUBAI_B);
|
||||
SPUtils::LoadCmd(dumpBubaiB, result);
|
||||
LOGI("Dubai::DumpDubaiBegin");
|
||||
}
|
||||
void Dubai::DumpDubaiFinish()
|
||||
{
|
||||
std::string result;
|
||||
std::string dumpBubaiF = HIDUMPER_CMD_MAP.at(HidumperCmd::DUMPER_DUBAI_F);
|
||||
SPUtils::LoadCmd(dumpBubaiF, result);
|
||||
LOGI("Dubai::DumpDubaiFinish");
|
||||
}
|
||||
|
||||
void Dubai::MoveDubaiDb()
|
||||
@ -44,8 +42,8 @@ void Dubai::MoveDubaiDb()
|
||||
const std::string PkgEntry = "/entry/rdb";
|
||||
const std::string cpDubai = "cp -r " + dubaiXpower + XpowerDb + " " + Database + dubaiPkgName + PkgEntry;
|
||||
const std::string dubaiPathChmod = "chmod 777 " + Database + dubaiPkgName + PkgEntry + XpowerDb;
|
||||
LOGI("cpDubai: (%s)", cpDubai.c_str());
|
||||
LOGI("dubaiPathChmod: (%s)", dubaiPathChmod.c_str());
|
||||
LOGD("cpDubai: (%s), dubaiPathChmod: (%s)",
|
||||
cpDubai.c_str(), dubaiPathChmod.c_str());
|
||||
SPUtils::LoadCmd(cpDubai, result);
|
||||
SPUtils::LoadCmd(dubaiPathChmod, result);
|
||||
}
|
||||
@ -54,7 +52,6 @@ void Dubai::CallBeginAndFinish()
|
||||
{
|
||||
DumpDubaiBegin();
|
||||
DumpDubaiFinish();
|
||||
LOGI("Dubai::CallBeginAndFinish");
|
||||
}
|
||||
|
||||
std::string Dubai::CallMoveDubaiDbFinished()
|
||||
@ -62,7 +59,6 @@ std::string Dubai::CallMoveDubaiDbFinished()
|
||||
std::string dubaiMoveFinish;
|
||||
if (isDumpDubaiFinish) {
|
||||
MoveDubaiDb();
|
||||
LOGI("Dubai::MoveDubaiDbFinished");
|
||||
}
|
||||
dubaiMoveFinish = "get_dubai_db";
|
||||
return dubaiMoveFinish;
|
||||
|
@ -50,14 +50,12 @@ std::map<std::string, std::string> FPS::ItemData()
|
||||
result["fps"] = "NA";
|
||||
result["fpsJitters"] = "NA";
|
||||
} else {
|
||||
int fullFrame = 120;
|
||||
int maxFullFrame = 123;
|
||||
const int fullFrame = 120;
|
||||
const int maxFullFrame = 123;
|
||||
if (fpsInfoResult.fps > fullFrame && fpsInfoResult.fps < maxFullFrame) {
|
||||
fpsInfoResult.fps = fullFrame;
|
||||
}
|
||||
result["fps"] = std::to_string(fpsInfoResult.fps);
|
||||
LOGI("result.fps: %s", std::to_string(fpsInfoResult.fps).c_str());
|
||||
LOGI("result.curTime: %s", std::to_string(fpsInfoResult.curTime).c_str());
|
||||
std::string jitterStr = "";
|
||||
std::string split = "";
|
||||
for (size_t i = 0; i < fpsInfoResult.jitters.size(); i++) {
|
||||
@ -67,7 +65,10 @@ std::map<std::string, std::string> FPS::ItemData()
|
||||
jitterStr += split + std::to_string(fpsInfoResult.jitters[i]);
|
||||
}
|
||||
result["fpsJitters"] = jitterStr;
|
||||
LOGI("result.jitters: %s", jitterStr.c_str());
|
||||
LOGD("result.fps: %s, result.curTime: %s, result.jitters: %s",
|
||||
std::to_string(fpsInfoResult.fps).c_str(),
|
||||
std::to_string(fpsInfoResult.curTime).c_str(),
|
||||
jitterStr.c_str());
|
||||
SetFpsCurrentFpsTime(fpsInfoResult);
|
||||
}
|
||||
return result;
|
||||
@ -127,7 +128,7 @@ FpsInfo FPS::GetFpsInfo()
|
||||
OHOS::SmartPerf::SPUtils::GetCurrentTime(fifty, prevResultFpsInfo.curTime);
|
||||
fpsInfoMax = GetSurfaceFrame(uniteLayer);
|
||||
} else {
|
||||
LOGI("FPS:app is in the background");
|
||||
LOGE("FPS:app is in the background");
|
||||
if (processId.empty()) {
|
||||
processFlag = true;
|
||||
fpsInfoMax.Clear();
|
||||
@ -184,13 +185,12 @@ void FPS::ReadDataFromPipe(int fd)
|
||||
char tmp[1024];
|
||||
fpsNum = 0;
|
||||
prevScreenTimestamp = -1;
|
||||
LOGI("FPS::dump time: start!");
|
||||
struct timespec time1 = { 0 };
|
||||
clock_gettime(CLOCK_MONOTONIC, &time1);
|
||||
fpsInfo.curTime = static_cast<int>(time1.tv_sec - 1);
|
||||
fpsInfo.currTimeDump = (time1.tv_sec - 1) * mod + time1.tv_nsec;
|
||||
LOGI("FPS:fpsInfo.curTime: %d", fpsInfo.curTime);
|
||||
LOGI("FPS:psInfo.currTimeDump: %lld", fpsInfo.currTimeDump);
|
||||
LOGD("FPS:fpsInfo.curTime: %d, FPS:psInfo.currTimeDump: %lld",
|
||||
fpsInfo.curTime, fpsInfo.currTimeDump);
|
||||
FILE *fp = fdopen(fd, "r");
|
||||
if (!fp) {
|
||||
LOGE("FPS::Failed to open file descriptor");
|
||||
|
@ -43,7 +43,7 @@ std::map<std::string, std::string> GPU::ItemData()
|
||||
result["gpuFrequency"] = "NA";
|
||||
result["gpuLoad"] = "NA";
|
||||
}
|
||||
LOGI("GPU::ItemData map size(%u)", result.size());
|
||||
LOGD("GPU::ItemData map size(%u)", result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ int GPU::GetGpuFreq()
|
||||
{
|
||||
std::shared_ptr<GpuCollector> collector = GpuCollector::Create();
|
||||
CollectResult<GpuFreq> result = collector->CollectGpuFrequency();
|
||||
LOGI("GpuFrequency: %s", std::to_string(result.data.curFeq).c_str());
|
||||
LOGD("GpuFrequency: %s", std::to_string(result.data.curFeq).c_str());
|
||||
return result.data.curFeq;
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ float GPU::GetGpuLoad()
|
||||
{
|
||||
std::shared_ptr<GpuCollector> collector = GpuCollector::Create();
|
||||
CollectResult<SysGpuLoad> result = collector->CollectSysGpuLoad();
|
||||
LOGI("SysGpuLoad: %s", std::to_string(result.data.gpuLoad).c_str());
|
||||
LOGD("SysGpuLoad: %s", std::to_string(result.data.gpuLoad).c_str());
|
||||
return float(result.data.gpuLoad);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace OHOS {
|
||||
|
||||
void* handle = dlopen(soFilePathChar, RTLD_LAZY);
|
||||
if (!handle) {
|
||||
LOGI("open GpuCounterPlugin so file error.");
|
||||
LOGE("open GpuCounterPlugin so file error.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -65,15 +65,12 @@ namespace OHOS {
|
||||
int ret = startGetGpuPerfInfo()->StartGetGpuPerfInfo(duration, std::move(gpuCounterCallback));
|
||||
if (ret == 0) {
|
||||
gcStatus = GC_RUNNING;
|
||||
LOGI("GpuCounter collect start.");
|
||||
} else {
|
||||
LOGE("GpuCounter call gameService error, ret = %d", ret);
|
||||
}
|
||||
} else if (type == GC_RESTART && gcStatus == GC_RUNNING) {
|
||||
int ret = startGetGpuPerfInfo()->StartGetGpuPerfInfo(duration, std::move(gpuCounterCallback));
|
||||
if (ret == 0) {
|
||||
LOGI("GpuCounter recollect start.");
|
||||
} else {
|
||||
if (ret != 0) {
|
||||
LOGE("GpuCounter call gameService error, ret = %d", ret);
|
||||
}
|
||||
} else {
|
||||
@ -86,7 +83,6 @@ namespace OHOS {
|
||||
if (gcStatus != GC_RUNNING || gpuCounterData.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
LOGI("GpuCounter collect stop.");
|
||||
char gpuCounterDataDirChar[PATH_MAX] = {0x00};
|
||||
if (realpath(path.c_str(), gpuCounterDataDirChar) == nullptr) {
|
||||
LOGE("data dir %s is nullptr", path.c_str());
|
||||
@ -177,7 +173,6 @@ namespace OHOS {
|
||||
int ret = startGetGpuPerfInfo()->StopGetGpuPerfInfo();
|
||||
if (ret == 0) {
|
||||
gcStatus = GC_INIT;
|
||||
LOGI("GpuCounter collect finish.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,6 @@ namespace OHOS {
|
||||
}
|
||||
|
||||
if (gpuPerfInfos[0].remainTime <= restartTime) {
|
||||
LOGI("remain time to restart");
|
||||
gpuCounterInstance.StartCollect(GpuCounter::GC_RESTART);
|
||||
}
|
||||
return 0;
|
||||
|
@ -33,7 +33,7 @@ namespace SmartPerf {
|
||||
std::map<std::string, std::string> Network::ItemData()
|
||||
{
|
||||
std::map<std::string, std::string> result = Network::GetNetworkInfo();
|
||||
LOGI("Network ItemData map siez=%u", result.size());
|
||||
LOGD("Network ItemData map siez=%u", result.size());
|
||||
if (result.find("networkUp") != result.end() && result["networkUp"].empty()) {
|
||||
result["networkUp"] = "NA";
|
||||
}
|
||||
|
@ -34,12 +34,10 @@ std::map<std::string, std::string> Power::ItemData()
|
||||
if (result.find("voltageNow") != result.end() && result["voltageNow"].empty()) {
|
||||
result["voltageNow"] = "NA";
|
||||
}
|
||||
LOGI("currentNow: %s", currentNow.c_str());
|
||||
LOGI("voltageNow: %s", voltageNow.c_str());
|
||||
LOGI("Power::ItemData map size(%u)", result.size());
|
||||
LOGD("Power::ItemData map size(%u)", result.size());
|
||||
} else {
|
||||
result["failed"] = "RK does not support power acquisition";
|
||||
LOGI("failed:RK does not support power acquisition");
|
||||
LOGE("failed:RK does not support power acquisition");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ std::map<std::string, std::string> RAM::ItemData()
|
||||
result.insert(*it);
|
||||
}
|
||||
}
|
||||
LOGI("RAM::ItemData map size(%u)", result.size());
|
||||
LOGD("RAM::ItemData map size(%u)", result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ std::map<std::string, std::string> Temperature::ItemData()
|
||||
struct dirent *dirp;
|
||||
std::vector<std::string> dirs;
|
||||
if (dp == nullptr) {
|
||||
std::cout << "Open directory failed!" << std::endl;
|
||||
LOGE("Open directory failed!");
|
||||
}
|
||||
while ((dirp = readdir(dp)) != nullptr) {
|
||||
if (strcmp(dirp->d_name, ".") != 0 && strcmp(dirp->d_name, "..") != 0) {
|
||||
@ -39,9 +39,7 @@ std::map<std::string, std::string> Temperature::ItemData()
|
||||
std::map<std::string, std::string> result;
|
||||
for (auto dir : dirs) {
|
||||
std::string dirType = dir + "/type";
|
||||
LOGI("dirType====: %s", dirType.c_str());
|
||||
std::string dirTemp = dir + "/temp";
|
||||
LOGI("dirTemp====: %s", dirTemp.c_str());
|
||||
|
||||
if (!SPUtils::FileAccess(dirType)) {
|
||||
continue;
|
||||
@ -53,9 +51,7 @@ std::map<std::string, std::string> Temperature::ItemData()
|
||||
SPUtils::LoadFile(dirTemp, temp);
|
||||
for (auto node : collectNodes) {
|
||||
if (type.find(node) != std::string::npos) {
|
||||
LOGI("type====: %s", type.c_str());
|
||||
float t = SPUtilesTye::StringToSometype<float>(temp);
|
||||
LOGI("temp====: %s", temp.c_str());
|
||||
if (node == "gpu") {
|
||||
result[type] = std::to_string(t);
|
||||
} else {
|
||||
@ -65,7 +61,7 @@ std::map<std::string, std::string> Temperature::ItemData()
|
||||
}
|
||||
}
|
||||
|
||||
LOGI("Temperature::ItemData map size(%u)", result.size());
|
||||
LOGD("Temperature::ItemData map size(%u)", result.size());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ int ClientControl::SocketStart(const std::string &args)
|
||||
OHOS::SmartPerf::StartUpDelay sd;
|
||||
sd.GetSpClear();
|
||||
}
|
||||
LOGI("ClientControl::SocketStart() OK");
|
||||
return 0;
|
||||
}
|
||||
int ClientControl::SocketStop()
|
||||
@ -74,7 +73,6 @@ int ClientControl::SocketStop()
|
||||
} else {
|
||||
std::cout << "SP_daemon Collection ended failed" << std::endl;
|
||||
}
|
||||
LOGI("ClientControl::SocketStop() OK");
|
||||
return 0;
|
||||
}
|
||||
int ClientControl::InitSocket()
|
||||
@ -93,7 +91,6 @@ int ClientControl::InitSocket()
|
||||
LOGE("Failed to connect to server");
|
||||
return 1;
|
||||
}
|
||||
LOGI("ClientControl::InitSocket() OK");
|
||||
return 0;
|
||||
}
|
||||
void ClientControl::StartSPDaemon() const
|
||||
@ -102,14 +99,12 @@ void ClientControl::StartSPDaemon() const
|
||||
std::string server = CMD_COMMAND_MAP.at(CmdCommand::SERVER);
|
||||
SPUtils::LoadCmd(server, result);
|
||||
sleep(1);
|
||||
LOGI("ClientControl::StartSPDaemon() OK");
|
||||
}
|
||||
int ClientControl::CloseSocket()
|
||||
{
|
||||
shutdown(clientSocket, SHUT_RD);
|
||||
close(clientSocket);
|
||||
clientSocket = -1;
|
||||
LOGI("ClientControl::CloseSocket() OK");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -52,11 +52,8 @@ void Heartbeat::HeartbeatRule()
|
||||
{
|
||||
while (isrunning) {
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
LOGI("endTime: %lld", std::chrono::time_point_cast<std::chrono::microseconds>(end).time_since_epoch().count());
|
||||
auto duration = std::chrono::duration_cast<std::chrono::seconds>(end - updateStart).count();
|
||||
LOGI("ListeningTimeJitter: %lld", duration);
|
||||
if (duration > timeout) {
|
||||
LOGI("connect timeout have Disconnected successfully!");
|
||||
KillSpId();
|
||||
}
|
||||
sleep(checkMessageTime);
|
||||
@ -67,7 +64,6 @@ void Heartbeat::UpdatestartTime()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
updateStart = std::chrono::steady_clock::now();
|
||||
LOGI("Listening to messages from edtior or device");
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ const std::unordered_map<CmdCommand, std::string> CMD_COMMAND_MAP = {
|
||||
{ CmdCommand::PIDOF_SP, std::string("pidof SP_daemon") },
|
||||
{ CmdCommand::SERVER_GREP, std::string("ps -ef | grep -v grep | grep 'SP_daemon -server'") },
|
||||
{ CmdCommand::EDITOR_SERVER_GREP, std::string("ps -ef | grep -v grep | grep 'SP_daemon -editorServer'") },
|
||||
{ CmdCommand::UINPUT_BACK, std::string("uinput -T -m 600 2760 600 1300 200") },
|
||||
{ CmdCommand::UINPUT_BACK, std::string("uinput -K -d 2076 -d 2020 -u 2076 -u 2020") },
|
||||
{ CmdCommand::TIMESTAMPS, std::string("timestamps") },
|
||||
{ CmdCommand::USER_PERMISSIONS, std::string("whoami") },
|
||||
};
|
||||
|
@ -70,16 +70,13 @@ public:
|
||||
void Process(ProtoType type) const
|
||||
{
|
||||
std::cout << "Socket Process called!" << std::endl;
|
||||
LOGI("Socket Process called!");
|
||||
SpServerSocket spSocket;
|
||||
spSocket.Init(type);
|
||||
if (type == ProtoType::TCP) {
|
||||
std::cout << "Socket TCP Init called!" << std::endl;
|
||||
LOGI("Socket TCP Init called!");
|
||||
TypeTcp(spSocket);
|
||||
}
|
||||
if (type == ProtoType::UDP || type == ProtoType::UDPEX) {
|
||||
LOGI("Socket UDP Init called! type(%d)", static_cast<int>(type));
|
||||
SocketHeartbeat();
|
||||
while (1) {
|
||||
spSocket.Recvfrom();
|
||||
@ -87,7 +84,6 @@ public:
|
||||
}
|
||||
}
|
||||
std::cout << "Socket Process finished!" << std::endl;
|
||||
LOGI("Socket Process finished!");
|
||||
spSocket.Close();
|
||||
}
|
||||
SocketErrorType CheckToken(std::string recvStr, SpServerSocket &spSocket) const
|
||||
@ -154,7 +150,6 @@ public:
|
||||
void StartRecv(SpServerSocket &spSocket) const
|
||||
{
|
||||
if (flagRunning) {
|
||||
LOGI("SP_daemon is running");
|
||||
spSocket.Send("SP_daemon is running");
|
||||
return;
|
||||
}
|
||||
@ -163,7 +158,7 @@ public:
|
||||
};
|
||||
ErrCode code = SPTask::GetInstance().StartTask(lambdaTask);
|
||||
SPTask::GetInstance().StartRecord();
|
||||
LOGI("start:::%s", (code == ErrCode::OK) ? "True" : "False");
|
||||
LOGD("start:::%s", (code == ErrCode::OK) ? "True" : "False");
|
||||
if (code == ErrCode::OK) {
|
||||
spSocket.Send("start::True");
|
||||
flagRunning = true;
|
||||
@ -175,7 +170,7 @@ public:
|
||||
{
|
||||
auto lambdaTask = [&spSocket](const std::string &data) { spSocket.Send(data); };
|
||||
ErrCode code = SPTask::GetInstance().StartTask(lambdaTask);
|
||||
LOGI("start::%s", (code == ErrCode::OK) ? "True" : "False");
|
||||
LOGD("start::%s", (code == ErrCode::OK) ? "True" : "False");
|
||||
if (code == ErrCode::OK) {
|
||||
spSocket.Send("start::True");
|
||||
} else if (code == ErrCode::FAILED) {
|
||||
@ -320,7 +315,7 @@ public:
|
||||
}
|
||||
HandleUDPMsg(spSocket, data, retCode, iterator);
|
||||
}
|
||||
LOGI("sendData key(%d) content(%s)", iterator->first, retCode.c_str());
|
||||
LOGD("sendData key(%d) content(%s)", iterator->first, retCode.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -415,6 +410,8 @@ public:
|
||||
spSocket.Sendto(retCode);
|
||||
} else if (iterator->first == MessageType::BACK_TO_DESKTOP) {
|
||||
BackDesktop();
|
||||
} else if (iterator->first == MessageType::START_DUBAI_DB) {
|
||||
Dubai::CallBeginAndFinish();
|
||||
} else if (iterator->first == MessageType::SET_DUBAI_DB) {
|
||||
Dubai::CallBeginAndFinish();
|
||||
Dubai::isDumpDubaiFinish = true;
|
||||
@ -423,7 +420,7 @@ public:
|
||||
} else {
|
||||
retCode = iterator->second;
|
||||
spSocket.Sendto(retCode);
|
||||
LOGI("UDP sendData: (%s)", retCode.c_str());
|
||||
LOGD("UDP sendData: (%s)", retCode.c_str());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ namespace SmartPerf {
|
||||
std::map<std::string, std::string> Navigation::ItemData()
|
||||
{
|
||||
std::map<std::string, std::string> result = Navigation::GetNavInfo();
|
||||
LOGI("Navigation::ItemData map size(%u)", result.size());
|
||||
LOGD("Navigation::ItemData map size(%u)", result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,6 @@ std::string ParseRadar::ParseRadarAppStrart(const std::string &string) const
|
||||
"ms\n"
|
||||
"CompleteTime:" +
|
||||
streamComplete.str() + "ms\n";
|
||||
LOGI("Radar.result====: %s", result.c_str());
|
||||
return result;
|
||||
}
|
||||
double ParseRadar::ParseRadarResponse(const std::string &string) const
|
||||
@ -149,7 +148,6 @@ std::string ParseRadar::ParseRadarFrame(const std::string &string) const
|
||||
}
|
||||
std::string ParseRadar::ExtractString(const std::string &str, const std::string &target) const
|
||||
{
|
||||
LOGI("Radar.str: %s", str.c_str());
|
||||
size_t pos = str.find(target);
|
||||
if (pos != std::string::npos) {
|
||||
pos += target.length();
|
||||
|
@ -50,21 +50,21 @@ double ParseSlideFpsTrace::CalculateTime()
|
||||
needTime = true;
|
||||
frameNow = 0;
|
||||
touchTime = SPUtilesTye::StringToSometype<double>(ParseSlideFpsTrace::GetLineTime(line));
|
||||
LOGI("ParseSlideFpsTrace::touchTime: (%s)", std::to_string(touchTime).c_str());
|
||||
LOGD("ParseSlideFpsTrace::touchTime: (%s)", std::to_string(touchTime).c_str());
|
||||
swiperFlingFlag = 0;
|
||||
}
|
||||
} else if (line.find("H:RSMainThread::DoComposition") != std::string::npos) {
|
||||
frameNow++;
|
||||
doCompositionTime = SPUtilesTye::StringToSometype<double>(ParseSlideFpsTrace::GetLineTime(line));
|
||||
LOGI("ParseSlideFpsTrace::doCompositionTime: (%s)", std::to_string(doCompositionTime).c_str());
|
||||
LOGD("ParseSlideFpsTrace::doCompositionTime: (%s)", std::to_string(doCompositionTime).c_str());
|
||||
} else if (line.find("H:WEB_LIST_FLING") != std::string::npos ||
|
||||
line.find("H:APP_LIST_FLING,") != std::string::npos) {
|
||||
listFlag++;
|
||||
if (listFlag == two) {
|
||||
completeTime = doCompositionTime;
|
||||
LOGI("ParseSlideFpsTrace::completeTime: (%s)", std::to_string(completeTime).c_str());
|
||||
frameNum = frameNow;
|
||||
LOGI("ParseSlideFpsTrace::frameNum: (%d)", frameNum);
|
||||
LOGD("ParseSlideFpsTrace::completeTime: (%s), ParseSlideFpsTrace::frameNum: (%d)",
|
||||
std::to_string(completeTime).c_str(), frameNum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -94,7 +94,7 @@ void ParseSlideFpsTrace::AppSwiperScroll(std::string line)
|
||||
if (line.find("H:APP_SWIPER_SCROLL,") != std::string::npos) {
|
||||
if (swiperScrollFlag == 0) {
|
||||
touchTime = SPUtilesTye::StringToSometype<double>(ParseSlideFpsTrace::GetLineTime(line));
|
||||
LOGI("AppSwiperScroll.touchTime: (%s)", std::to_string(touchTime).c_str());
|
||||
LOGD("AppSwiperScroll.touchTime: (%s)", std::to_string(touchTime).c_str());
|
||||
needTime = true;
|
||||
swiperScrollFlag = 1;
|
||||
}
|
||||
@ -102,9 +102,9 @@ void ParseSlideFpsTrace::AppSwiperScroll(std::string line)
|
||||
if (line.find("H:APP_SWIPER_FLING,") != std::string::npos) {
|
||||
if (swiperFlingFlag == 1) {
|
||||
completeTime = doCompositionTime;
|
||||
LOGI("AppSwiperScroll.completeTime: (%s)", std::to_string(completeTime).c_str());
|
||||
frameNum = frameNow;
|
||||
LOGI("AppSwiperScroll.frameNum: (%d)", frameNum);
|
||||
LOGD("AppSwiperScroll.completeTime: (%s), AppSwiperScroll.frameNum: (%d)",
|
||||
std::to_string(completeTime).c_str(), frameNum);
|
||||
}
|
||||
swiperFlingFlag++;
|
||||
}
|
||||
@ -112,7 +112,7 @@ void ParseSlideFpsTrace::AppSwiperScroll(std::string line)
|
||||
frameNow = 1;
|
||||
needTime = false;
|
||||
responseTime = doCompositionTime;
|
||||
LOGI("AppSwiperScroll.responseTime: (%s)", std::to_string(responseTime).c_str());
|
||||
LOGD("AppSwiperScroll.responseTime: (%s)", std::to_string(responseTime).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,14 @@ std::map<std::string, std::string> ProfilerFPS::ItemData()
|
||||
result["fps"] = "NA";
|
||||
result["fpsJitters"] = "NA";
|
||||
} else {
|
||||
int fullFrame = 120;
|
||||
int maxFullFrame = 123;
|
||||
const int fullFrame = 120;
|
||||
const int maxFullFrame = 123;
|
||||
if (finalResult.fps > fullFrame && finalResult.fps < maxFullFrame) {
|
||||
finalResult.fps = fullFrame;
|
||||
}
|
||||
result["fps"] = std::to_string(finalResult.fps);
|
||||
LOGI("ProfilerFPS.result.fps: %s", std::to_string(finalResult.fps).c_str());
|
||||
LOGI("ProfilerFPS.result.curTime: %s", std::to_string(finalResult.curTime).c_str());
|
||||
LOGD("ProfilerFPS.result.fps: %s, ProfilerFPS.result.curTime: %s",
|
||||
std::to_string(finalResult.fps).c_str(), std::to_string(finalResult.curTime).c_str());
|
||||
std::string jitterStr = "";
|
||||
std::string split = "";
|
||||
for (size_t i = 0; i < finalResult.jitters.size(); i++) {
|
||||
@ -59,7 +59,7 @@ std::map<std::string, std::string> ProfilerFPS::ItemData()
|
||||
jitterStr += split + std::to_string(finalResult.jitters[i]);
|
||||
}
|
||||
result["fpsJitters"] = jitterStr;
|
||||
LOGI("ProfilerFPS.result.jitters: %s", jitterStr.c_str());
|
||||
LOGD("ProfilerFPS.result.jitters: %s", jitterStr.c_str());
|
||||
if (isCatchTrace > 0) {
|
||||
ByTrace::GetInstance().CheckFpsJitters(finalResult.jitters, finalResult.fps);
|
||||
}
|
||||
@ -110,15 +110,15 @@ void ProfilerFPS::GetResultFPS(int sectionsNum)
|
||||
}
|
||||
time_t now = time(nullptr);
|
||||
if (now == -1) {
|
||||
LOGI("Failed to get current time.");
|
||||
LOGE("Failed to get current time.");
|
||||
return;
|
||||
}
|
||||
char *dt = ctime(&now);
|
||||
LOGI("printf time is: %s", dt);
|
||||
LOGD("printf time is: %s", dt);
|
||||
fflush(stdout);
|
||||
gettimeofday(&end, nullptr);
|
||||
runTime = end.tv_sec * 1e6 - start.tv_sec * 1e6 + end.tv_usec - start.tv_usec;
|
||||
LOGI("printf time is runTime: %s", std::to_string(runTime).c_str());
|
||||
LOGD("printf time is runTime: %s", std::to_string(runTime).c_str());
|
||||
if (runTime < sleepTime) {
|
||||
usleep(sleepTime - runTime);
|
||||
}
|
||||
@ -283,7 +283,6 @@ FpsInfoProfiler ProfilerFPS::GetFpsInfo()
|
||||
uniteLayer = gameLayerName;
|
||||
isGameSurface = true;
|
||||
} else if (!rkFlag) {
|
||||
LOGI("uniteLayer is UniRender");
|
||||
uniteLayer = "UniRender";
|
||||
} else {
|
||||
ProfilerFPS &profilerFps = ProfilerFPS::GetInstance();
|
||||
@ -293,7 +292,7 @@ FpsInfoProfiler ProfilerFPS::GetFpsInfo()
|
||||
uniteLayer = GetSurface();
|
||||
}
|
||||
if (pkgName.empty() || pkgName.find("sceneboard") != std::string::npos || isGameSurface) {
|
||||
LOGI("ProfilerFPS.pkgName: %s", pkgName.c_str());
|
||||
LOGD("ProfilerFPS.pkgName: %s", pkgName.c_str());
|
||||
OHOS::SmartPerf::SPUtils::GetCurrentTime(fifty, lastFpsInfoResult.curTime);
|
||||
fpsInfoMax = GetSurfaceFrame(uniteLayer);
|
||||
} else {
|
||||
@ -302,7 +301,6 @@ FpsInfoProfiler ProfilerFPS::GetFpsInfo()
|
||||
OHOS::SmartPerf::SPUtils::GetCurrentTime(fifty, lastFpsInfoResult.curTime);
|
||||
fpsInfoMax = GetSurfaceFrame(uniteLayer);
|
||||
} else {
|
||||
LOGI("ProfilerFPS::app is in the background");
|
||||
if (processId.empty()) {
|
||||
processFlag = true;
|
||||
fpsInfoMax.Clear();
|
||||
@ -347,12 +345,11 @@ FpsInfoProfiler ProfilerFPS::GetFrameInfoFromMap(std::string name)
|
||||
}
|
||||
fpsNum = 0;
|
||||
prevScreenTimestamp = -1;
|
||||
LOGI("ProfilerFPS dump time: start!");
|
||||
struct timespec time1 = { 0 };
|
||||
clock_gettime(CLOCK_MONOTONIC, &time1);
|
||||
fpsInfo.curTime = static_cast<int>(time1.tv_sec - 1);
|
||||
fpsInfo.currTimeDump = (time1.tv_sec - 1) * mod + time1.tv_nsec;
|
||||
LOGI("ProfilerFPS fpsInfo.curTime: %d", fpsInfo.curTime);
|
||||
LOGD("ProfilerFPS fpsInfo.curTime: %d", fpsInfo.curTime);
|
||||
while (fgets(tmp, sizeof(tmp), fp) != nullptr) {
|
||||
std::string str(tmp);
|
||||
LOGD("ProfilerFPS dump time: %s", str.c_str());
|
||||
@ -369,7 +366,7 @@ FpsInfoProfiler ProfilerFPS::GetFrameInfoFromMap(std::string name)
|
||||
LOGE("Error: Failed to close file");
|
||||
return fpsInfo;
|
||||
}
|
||||
LOGI("ProfilerFPS fpsNum: %d", fpsNum);
|
||||
LOGD("ProfilerFPS fpsNum: %d", fpsNum);
|
||||
return fpsInfo;
|
||||
}
|
||||
|
||||
@ -444,14 +441,14 @@ std::string ProfilerFPS::GetGameLayer()
|
||||
return gameLayer;
|
||||
}
|
||||
std::string cmdResult;
|
||||
std::string dumperSurface = HIDUMPER_CMD_MAP.at(HidumperCmd::DUMPER_SURFACE);
|
||||
const std::string dumperSurface = HIDUMPER_CMD_MAP.at(HidumperCmd::DUMPER_SURFACE);
|
||||
char buf[1024] = {'\0'};
|
||||
std::string start = "NodeId[";
|
||||
std::string end = "] LayerId";
|
||||
std::string nodeIdStr;
|
||||
uint64_t nodeId;
|
||||
if (dumperSurface.empty()) {
|
||||
LOGI("ProfilerFPS::DUMPER_SURFACE failed");
|
||||
LOGE("ProfilerFPS::DUMPER_SURFACE failed");
|
||||
return gameLayer;
|
||||
}
|
||||
FILE *fd = popen(dumperSurface.c_str(), "r");
|
||||
@ -464,7 +461,7 @@ std::string ProfilerFPS::GetGameLayer()
|
||||
size_t endPos = line.find(end);
|
||||
if (startPos != std::string::npos && endPos != std::string::npos) {
|
||||
nodeIdStr = line.substr(startPos + start.length(), endPos - startPos - start.length());
|
||||
LOGI("ProfilerFPS::nodeIdStr: (%s)", nodeIdStr.c_str());
|
||||
LOGD("ProfilerFPS::nodeIdStr: (%s)", nodeIdStr.c_str());
|
||||
}
|
||||
const int kShiftAmount = 32;
|
||||
if (!nodeIdStr.empty()) {
|
||||
@ -474,7 +471,7 @@ std::string ProfilerFPS::GetGameLayer()
|
||||
return gameLayer;
|
||||
}
|
||||
nodeId = nodeId >> kShiftAmount;
|
||||
LOGI("ProfilerFPS::nodeId: (%d)", nodeId);
|
||||
LOGD("ProfilerFPS::nodeId: (%d)", nodeId);
|
||||
GetLayerName(gameLayer, nodeId, line, endPos);
|
||||
}
|
||||
}
|
||||
@ -482,7 +479,7 @@ std::string ProfilerFPS::GetGameLayer()
|
||||
LOGE("Error: Failed to close file");
|
||||
return gameLayer;
|
||||
}
|
||||
LOGI("ProfilerFPS::gameLayer: (%s)", gameLayer.c_str());
|
||||
LOGD("ProfilerFPS::gameLayer: (%s)", gameLayer.c_str());
|
||||
return gameLayer;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ namespace OHOS {
|
||||
params.receiveFd[index] = -1;
|
||||
return "";
|
||||
}
|
||||
LOGI("Fd %d,%d, receove %s", index, params.receiveFd[index], receiveBuf);
|
||||
LOGD("Fd %d,%d, receove %s", index, params.receiveFd[index], receiveBuf);
|
||||
receiveBuffer = receiveBuf;
|
||||
|
||||
bool processFlag = true;
|
||||
|
@ -33,7 +33,7 @@ namespace OHOS {
|
||||
namespace SmartPerf {
|
||||
SmartPerfCommand::SmartPerfCommand(std::vector<std::string> argv)
|
||||
{
|
||||
LOGI("SmartPerfCommand::SmartPerfCommand size(%u)", argv.size());
|
||||
LOGD("SmartPerfCommand::SmartPerfCommand size(%u)", argv.size());
|
||||
if (argv.size() == oneParam) {
|
||||
OHOS::SmartPerf::StartUpDelay sd;
|
||||
sd.GetSpTcp();
|
||||
@ -71,12 +71,10 @@ SmartPerfCommand::SmartPerfCommand(std::vector<std::string> argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOGI("SmartPerfCommand::SmartPerfCommand complete");
|
||||
}
|
||||
void SmartPerfCommand::HelpCommand(CommandHelp type, std::string token) const
|
||||
{
|
||||
LOGI("SmartPerfCommand::HelpCommand type(%d)", type);
|
||||
LOGD("SmartPerfCommand::HelpCommand type(%d)", type);
|
||||
if (type == CommandHelp::HELP) {
|
||||
std::cout << smartPerfMsg << std::endl;
|
||||
}
|
||||
@ -127,7 +125,7 @@ void SmartPerfCommand::CreateSocketThread() const
|
||||
}
|
||||
void SmartPerfCommand::HandleCommand(std::string argStr, const std::string &argStr1)
|
||||
{
|
||||
LOGI("SmartPerfCommand::HandleCommand argStr(%s) argStr1(%s)", argStr.c_str(), argStr1.c_str());
|
||||
LOGD("SmartPerfCommand::HandleCommand argStr(%s) argStr1(%s)", argStr.c_str(), argStr1.c_str());
|
||||
switch (COMMAND_MAP.at(argStr)) {
|
||||
case CommandType::CT_N:
|
||||
num = SPUtilesTye::StringToSometype<int>(argStr1.c_str());
|
||||
@ -257,9 +255,7 @@ std::string SmartPerfCommand::ExecCommand()
|
||||
SaveGpuCounter();
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(freq));
|
||||
LOGI("SmartPerfCommand::WriteCsv start");
|
||||
SpCsvUtil::WriteCsv(std::string(outPath.c_str()), vmap);
|
||||
LOGI("SmartPerfCommand::WriteCsv finish");
|
||||
return std::string("command exec finished!");
|
||||
}
|
||||
void SmartPerfCommand::PrintfExecCommand(const std::map<std::string, std::string> data) const
|
||||
@ -286,7 +282,7 @@ void SmartPerfCommand::InitSomething()
|
||||
std::string cmdResult;
|
||||
std::string stat = CMD_COMMAND_MAP.at(CmdCommand::PROC_STAT);
|
||||
if (SPUtils::LoadCmd(stat, cmdResult)) {
|
||||
LOGI("SmartPerfCommand::InitSomething Privilege escalation!");
|
||||
LOGE("SmartPerfCommand::InitSomething Privilege escalation!");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "include/ByTrace.h"
|
||||
#include "include/sp_utils.h"
|
||||
#include "include/sp_profiler_factory.h"
|
||||
#include "include/Dubai.h"
|
||||
#include "include/Capture.h"
|
||||
#include "include/navigation.h"
|
||||
#include "include/sp_log.h"
|
||||
@ -81,9 +80,6 @@ SpProfiler *SpProfilerFactory::GetProfilerItemContinue(MessageType messageType)
|
||||
Capture::GetInstance().SocketMessage();
|
||||
profiler = &Capture::GetInstance();
|
||||
break;
|
||||
case MessageType::START_DUBAI_DB:
|
||||
Dubai::CallBeginAndFinish();
|
||||
break;
|
||||
case MessageType::CATCH_NETWORK_TRAFFIC:
|
||||
case MessageType::GET_NETWORK_TRAFFIC:
|
||||
profiler = &Network::GetInstance();
|
||||
|
@ -63,7 +63,7 @@ int SpServerSocket::Init(ProtoType type)
|
||||
}
|
||||
}
|
||||
|
||||
LOGI("SpServerSocket::Init OK,prot(%d)", sockPort);
|
||||
LOGD("SpServerSocket::Init OK,prot(%d)", sockPort);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ void SpServerSocket::Close()
|
||||
local.sin_port = htons(sockPort);
|
||||
local.sin_addr.s_addr = inet_addr("127.0.0.1");
|
||||
if (::bind(sock, reinterpret_cast<struct sockaddr *>(&local), sizeof(local)) < 0) {
|
||||
LOGI("SpServerSocket::Init Socket Bind failed");
|
||||
LOGE("SpServerSocket::Init Socket Bind failed");
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,6 +109,9 @@ int SpServerSocket::Recvfrom()
|
||||
int l = recvfrom(sock, rbuf, sizeof(rbuf) - 1, 0, reinterpret_cast<struct sockaddr *>(&client), &len);
|
||||
if (l > 0) {
|
||||
std::cout << "Client:" << rbuf << std::endl;
|
||||
} else {
|
||||
LOGE("SpServerSocket::Recvfrom Error(%d)", l);
|
||||
return -1;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
@ -111,7 +111,6 @@ static std::string MapToString(std::map<std::string, std::string> myMap)
|
||||
|
||||
ErrCode SPTask::InitTask(const std::string &recvStr)
|
||||
{
|
||||
LOGI("SPTask::InitTask start param(%s)", recvStr.c_str());
|
||||
std::string result = "";
|
||||
std::string hiprofiler = CMD_COMMAND_MAP.at(CmdCommand::HIPROFILER);
|
||||
SPUtils::LoadCmd(hiprofiler, result);
|
||||
@ -122,12 +121,11 @@ ErrCode SPTask::InitTask(const std::string &recvStr)
|
||||
ExceptionMsg exMsg = ParseToTask(recvStr, curTaskInfo);
|
||||
if (exMsg == ExceptionMsg::NO_ERR) {
|
||||
isInit = true;
|
||||
LOGI("SPTask::InitTask Ok");
|
||||
return ErrCode::OK;
|
||||
}
|
||||
|
||||
std::string errInfo = EXCEPTION_MSG_MAP.at(exMsg);
|
||||
LOGI("SPTask::InitTask error(%s)", errInfo.c_str());
|
||||
LOGE("SPTask::InitTask error(%s)", errInfo.c_str());
|
||||
return ErrCode::FAILED;
|
||||
}
|
||||
|
||||
@ -375,11 +373,10 @@ void SPTask::AsyncGetDataMap(std::function<void(std::string data)> msgTask)
|
||||
|
||||
ErrCode SPTask::StartTask(std::function<void(std::string data)> msgTask)
|
||||
{
|
||||
LOGI("SPTask::StartTask start ");
|
||||
RAM &ram = RAM::GetInstance();
|
||||
ram.SetFirstFlag();
|
||||
if (!isInit) {
|
||||
LOGW("SPTask::StartTask initialization failed");
|
||||
LOGE("SPTask::StartTask initialization failed");
|
||||
return ErrCode::FAILED;
|
||||
}
|
||||
isRunning = true;
|
||||
@ -394,7 +391,6 @@ ErrCode SPTask::StartTask(std::function<void(std::string data)> msgTask)
|
||||
AsyncGetDataMap(msgTask);
|
||||
}
|
||||
});
|
||||
LOGI("SPTask::StartTask complete");
|
||||
return ErrCode::OK;
|
||||
}
|
||||
|
||||
@ -483,7 +479,6 @@ ErrCode SPTask::StopTask()
|
||||
if (thread.joinable()) {
|
||||
thread.join();
|
||||
}
|
||||
|
||||
KillHiperfCmd();
|
||||
return ErrCode::OK;
|
||||
}
|
||||
@ -549,10 +544,9 @@ void SPTask::GetHiperf(const std::string &traceName)
|
||||
std::string result;
|
||||
std::string tmp = SetHiperf(traceName);
|
||||
std::cout << tmp << std::endl;
|
||||
LOGD("hiprofiler exec (%s)", tmp.c_str());
|
||||
LOGI("hiprofiler exec trace name(%s)", traceName.c_str());
|
||||
SPUtils::LoadCmd(tmp, result);
|
||||
LOGI("hiprofiler exec end (%s)", result.c_str());
|
||||
LOGD("hiprofiler exec (%s), hiprofiler exec trace name(%s), hiprofiler exec end (%s)",
|
||||
tmp.c_str(), traceName.c_str(), result.c_str());
|
||||
}
|
||||
|
||||
|
||||
@ -582,7 +576,6 @@ void SPTask::KillHiperfCmd()
|
||||
runTime = now > startCaptuerTime ? now - startCaptuerTime : LLONG_MAX - startCaptuerTime + now;
|
||||
runTime = runTime / RM_1000; // Convert to seconds
|
||||
|
||||
LOGI("Preparing to exit run time(%lld)", runTime);
|
||||
do {
|
||||
out.clear();
|
||||
std::string hiprofilerPid = CMD_COMMAND_MAP.at(CmdCommand::HIPROFILER_PID);
|
||||
@ -599,7 +592,6 @@ void SPTask::KillHiperfCmd()
|
||||
std::string hiprofilerPid = CMD_COMMAND_MAP.at(CmdCommand::HIPROFILER_PID);
|
||||
SPUtils::LoadCmd(hiprofilerPid, result);
|
||||
SPUtils::StrSplit(result, " ", out);
|
||||
LOGI("pidof hiprofiler_cmd size(%u)", out.size());
|
||||
for (auto it = out.begin(); out.end() != it; ++it) {
|
||||
result.clear();
|
||||
SPUtils::LoadCmd(killCmd + (*it), result);
|
||||
@ -625,7 +617,6 @@ bool SPTask::GetRecordState()
|
||||
}
|
||||
ErrCode SPTask::StartRecord()
|
||||
{
|
||||
LOGI("SPTask::StartRecord");
|
||||
startTime = SPUtils::GetCurTime();
|
||||
InitDataFile();
|
||||
recordState = true;
|
||||
@ -634,7 +625,6 @@ ErrCode SPTask::StartRecord()
|
||||
|
||||
ErrCode SPTask::StopRecord()
|
||||
{
|
||||
LOGI("SPTask::StopRecord");
|
||||
std::string outGpuCounterDataPath = baseOutPath + "/" + curTaskInfo.sessionId;
|
||||
|
||||
if (isInit) {
|
||||
|
@ -293,7 +293,7 @@ std::string SPUtils::GetDeviceInfoMap()
|
||||
deviceInfoMap.insert(deviceInfo.begin(), deviceInfo.end());
|
||||
deviceInfoMap["activeMode"] = screenSize;
|
||||
if (deviceInfoMap.empty()) {
|
||||
LOGI("Failed to obtain device information");
|
||||
LOGE("Failed to obtain device information");
|
||||
}
|
||||
for (auto iter = deviceInfoMap.cbegin(); iter != deviceInfoMap.cend(); ++iter) {
|
||||
printf("%s: %s\n", iter->first.c_str(), iter->second.c_str());
|
||||
@ -629,7 +629,7 @@ std::string SPUtils::GetCpuNum()
|
||||
cpuCores += std::to_string(cpuNum);
|
||||
if (cpuNum == 0) {
|
||||
std::cout << "CPU frequency collection failed." << std::endl;
|
||||
LOGI("CPU frequency collection failed.");
|
||||
LOGE("CPU frequency collection failed.");
|
||||
}
|
||||
return cpuCores;
|
||||
}
|
||||
@ -720,7 +720,7 @@ bool SPUtils::GetPathPermissions(const std::string &path)
|
||||
std::string result = cmdResult.substr(0, 10);
|
||||
return result == "-rw-r--r--";
|
||||
} else {
|
||||
LOGI("THE path is empty");
|
||||
LOGE("THE path is empty");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ double StallingRateTrace::StallingRateResult(std::string file)
|
||||
}
|
||||
infile.open(realPath);
|
||||
if (infile.fail()) {
|
||||
LOGI("StallingRateTrace open file(%s) fialed ", file.c_str());
|
||||
LOGE("StallingRateTrace open file(%s) fialed ", file.c_str());
|
||||
return stalligRate;
|
||||
}
|
||||
stalligRate = SmartPerf::StallingRateTrace::CalculateTime();
|
||||
@ -70,21 +70,22 @@ void StallingRateTrace::CalcFrameRate()
|
||||
} else {
|
||||
appFrameLossRate = -1;
|
||||
}
|
||||
LOGI("result.appFrameLossRate: (%s)", std::to_string(appFrameLossRate).c_str());
|
||||
|
||||
if (swiperDynamicFinishTime != 0 && swiperDynamicStartTime != 0) {
|
||||
swiperFrameLossRate = (frameLossSwiperTime / (swiperDynamicFinishTime - swiperDynamicStartTime) * oneThousand);
|
||||
} else {
|
||||
swiperFrameLossRate = -1;
|
||||
}
|
||||
LOGI("result.swiperFrameLossRate: (%s)", std::to_string(swiperFrameLossRate).c_str());
|
||||
|
||||
if (appTabsDynamicStartTime != 0 && appTabsDynamicFinishTime != 0) {
|
||||
tabsFrameLossRate = (frameLossTabsTime / (appTabsDynamicFinishTime - appTabsDynamicStartTime) * oneThousand);
|
||||
} else {
|
||||
tabsFrameLossRate = -1;
|
||||
}
|
||||
LOGI("result.tabsFrameLossRate: (%s)", std::to_string(tabsFrameLossRate).c_str());
|
||||
LOGD("result.appFrameLossRate: (%s), result.swiperFrameLossRate: (%s), result.tabsFrameLossRate: (%s)",
|
||||
std::to_string(appFrameLossRate).c_str(),
|
||||
std::to_string(swiperFrameLossRate).c_str(),
|
||||
std::to_string(tabsFrameLossRate).c_str());
|
||||
}
|
||||
|
||||
void StallingRateTrace::JudgFrameRate()
|
||||
@ -98,15 +99,12 @@ void StallingRateTrace::JudgFrameRate()
|
||||
bool tabsDynamicExists = hasDynamic(appTabsDynamicFinishTime, appTabsDynamicStartTime);
|
||||
|
||||
if (!appListDynamicExists) {
|
||||
LOGI("no app list Dynamic");
|
||||
frameLossRate = swiperDynamicExists ? swiperFrameLossRate :
|
||||
tabsDynamicExists ? tabsFrameLossRate : -1;
|
||||
} else if (!swiperDynamicExists) {
|
||||
LOGI("no swiper Dynamic");
|
||||
frameLossRate = appListDynamicExists ? appFrameLossRate :
|
||||
tabsDynamicExists ? tabsFrameLossRate : -1;
|
||||
} else if (!tabsDynamicExists) {
|
||||
LOGI("no tabs Dynamic");
|
||||
frameLossRate = appListDynamicExists ? appFrameLossRate :
|
||||
swiperDynamicExists ? swiperFrameLossRate : -1;
|
||||
} else {
|
||||
@ -117,7 +115,6 @@ void StallingRateTrace::JudgFrameRate()
|
||||
void StallingRateTrace::MultiLaneFrameRate()
|
||||
{
|
||||
if (appFrameLossRate == 0) {
|
||||
LOGI("no app list hitchTime");
|
||||
if (swiperFrameLossRate > 0) {
|
||||
frameLossRate = swiperFrameLossRate;
|
||||
} else if (tabsFrameLossRate > 0) {
|
||||
@ -126,7 +123,6 @@ void StallingRateTrace::MultiLaneFrameRate()
|
||||
frameLossRate = 0;
|
||||
}
|
||||
} else if (swiperFrameLossRate == 0) {
|
||||
LOGI("no swiper list hitchTime");
|
||||
if (appFrameLossRate > 0) {
|
||||
frameLossRate = appFrameLossRate;
|
||||
} else if (tabsFrameLossRate > 0) {
|
||||
@ -135,7 +131,6 @@ void StallingRateTrace::MultiLaneFrameRate()
|
||||
frameLossRate = 0;
|
||||
}
|
||||
} else if (tabsFrameLossRate == 0) {
|
||||
LOGI("no tabs list hitchTime");
|
||||
if (appFrameLossRate > 0) {
|
||||
frameLossRate = appFrameLossRate;
|
||||
} else if (swiperFrameLossRate > 0) {
|
||||
@ -182,14 +177,14 @@ void StallingRateTrace::AppList(const std::string &line, const std::string &sign
|
||||
line.find("H:LAUNCHER_APP_LAUNCH_FROM_DOCK,") != std::string::npos ||
|
||||
line.find("H:LAUNCHER_APP_LAUNCH_FROM_APPCENTER,") != std::string::npos) {
|
||||
if (listFlag) {
|
||||
LOGI("AppList line start: (%s)", line.c_str());
|
||||
appListDynamicFinishTime = GetTimes(line, signF);
|
||||
LOGI("appListDynamicFinishTime: (%s)", std::to_string(appListDynamicFinishTime).c_str());
|
||||
LOGD("AppList line start: (%s), appListDynamicFinishTime: (%s)",
|
||||
line.c_str(), std::to_string(appListDynamicFinishTime).c_str());
|
||||
listFlag = false;
|
||||
} else {
|
||||
LOGI("AppList line finish: (%s)", line.c_str());
|
||||
appListDynamicStartTime = GetTimes(line, signS);
|
||||
LOGI("appListDynamicStartTime: (%s)", std::to_string(appListDynamicStartTime).c_str());
|
||||
LOGD("AppList line finish: (%s), appListDynamicStartTime: (%s)",
|
||||
line.c_str(), std::to_string(appListDynamicStartTime).c_str());
|
||||
listFlag = true;
|
||||
frameLossTime = 0;
|
||||
}
|
||||
@ -199,13 +194,12 @@ void StallingRateTrace::AppList(const std::string &line, const std::string &sign
|
||||
if (upperScreenFlag) {
|
||||
if (line.find("|H:Present Fence ") != std::string::npos) {
|
||||
fenceId = GetFenceId(line);
|
||||
LOGI("fenceId: (%d)", fenceId);
|
||||
}
|
||||
std::string waitFenceId = "|H:Waiting for Present Fence " + std::to_string(fenceId);
|
||||
if (line.find(waitFenceId) != std::string::npos) {
|
||||
nowTime = SPUtilesTye::StringToSometype<double>(StallingRateTrace::GetOnScreenTimeStart(line));
|
||||
GetFrameLossTime(nowTime, lastTime, roundTime, frameLossTime);
|
||||
LOGI("frameLossTime: (%s)", std::to_string(frameLossTime).c_str());
|
||||
LOGD("frameLossTime: (%s)", std::to_string(frameLossTime).c_str());
|
||||
lastTime = nowTime;
|
||||
upperScreenFlag = false;
|
||||
}
|
||||
@ -217,9 +211,9 @@ void StallingRateTrace::GetFrameLossTime(double curTime, double prevTime, double
|
||||
{
|
||||
if ((curTime - prevTime) > drawTime && prevTime != 0) {
|
||||
double diffTime = (curTime - prevTime) - drawTime;
|
||||
LOGI("diffTime: (%s)", std::to_string(diffTime).c_str());
|
||||
totalFrameLossTime += diffTime;
|
||||
LOGI("totalFrameLossTime: (%s)", std::to_string(totalFrameLossTime).c_str());
|
||||
LOGD("diffTime: (%s), totalFrameLossTime: (%s)",
|
||||
std::to_string(diffTime).c_str(), std::to_string(totalFrameLossTime).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,7 +234,6 @@ void StallingRateTrace::GetRsHardWareRate(double curFrameRate, const std::string
|
||||
break;
|
||||
}
|
||||
curFrameRate = GetFrameRate(line);
|
||||
LOGI("curFrameRate1: (%s)", std::to_string(curFrameRate).c_str());
|
||||
if (curFrameRate != 0) {
|
||||
UpdateRoundTime(curFrameRate, type);
|
||||
}
|
||||
@ -259,7 +252,6 @@ void StallingRateTrace::GetRsHardWareRate(double curFrameRate, const std::string
|
||||
break;
|
||||
}
|
||||
curFrameRate = GetFrameRate(line);
|
||||
LOGI("curFrameRate2: (%s)", std::to_string(curFrameRate).c_str());
|
||||
if (curFrameRate != 0) {
|
||||
UpdateRoundTime(curFrameRate, type);
|
||||
}
|
||||
@ -293,9 +285,9 @@ void StallingRateTrace::AppSwiperScroll(const std::string &line, const std::stri
|
||||
line.find("H:APP_SWITCH_FRAME_ANIMATION") != std::string::npos ||
|
||||
line.find("H:APP_SWIPER_SCROLL,") != std::string::npos) {
|
||||
if (swiperScrollFlag == 0) {
|
||||
LOGI("AppSwiperScroll line start: (%s)", line.c_str());
|
||||
swiperDynamicStartTime = GetTimes(line, signS);
|
||||
LOGI("swiperDynamicStartTime: (%s)", std::to_string(swiperDynamicStartTime).c_str());
|
||||
LOGD("AppSwiperScroll line start: (%s), swiperDynamicStartTime: (%s)",
|
||||
line.c_str(), std::to_string(swiperDynamicStartTime).c_str());
|
||||
frameLossSwiperTime = 0;
|
||||
swiperScrollFlag = 1;
|
||||
swiperFlag = true;
|
||||
@ -305,9 +297,9 @@ void StallingRateTrace::AppSwiperScroll(const std::string &line, const std::stri
|
||||
line.find("H:APP_SWIPER_NO_ANIMATION_SWITCH") != std::string::npos ||
|
||||
line.find("H:APP_SWITCH_FRAME_ANIMATION") != std::string::npos) {
|
||||
if (swiperFlingFlag == 1) {
|
||||
LOGI("AppSwiper FinishTime line: (%s)", line.c_str());
|
||||
swiperDynamicFinishTime = GetTimes(line, signF);
|
||||
LOGI("swiperDynamicFinishTime: (%s)", std::to_string(swiperDynamicFinishTime).c_str());
|
||||
LOGD("AppSwiper FinishTime line: (%s), swiperDynamicFinishTime: (%s)",
|
||||
line.c_str(), std::to_string(swiperDynamicFinishTime).c_str());
|
||||
swiperFlag = false;
|
||||
}
|
||||
if (swiperDynamicFinishTime == 0) {
|
||||
@ -320,14 +312,13 @@ void StallingRateTrace::AppSwiperScroll(const std::string &line, const std::stri
|
||||
if (upperScreenSwiperFlag) {
|
||||
if (line.find("|H:Present Fence ") != std::string::npos) {
|
||||
fenceIdSwiper = GetFenceId(line);
|
||||
LOGI("fenceIdSwiper: (%d)", fenceIdSwiper);
|
||||
}
|
||||
std::string waitFenceId = "|H:Waiting for Present Fence " + std::to_string(fenceIdSwiper);
|
||||
if (line.find(waitFenceId) != std::string::npos) {
|
||||
nowSwiperTime = SPUtilesTye::StringToSometype<double>(StallingRateTrace::GetOnScreenTimeStart(line));
|
||||
LOGI("nowSwiperTime: (%s)", std::to_string(nowSwiperTime).c_str());
|
||||
GetFrameLossTime(nowSwiperTime, lastSwiperTime, roundSwiperTime, frameLossSwiperTime);
|
||||
LOGI("frameLossSwiperTime: (%s)", std::to_string(frameLossSwiperTime).c_str());
|
||||
LOGD("nowSwiperTime: (%s), frameLossSwiperTime: (%s)",
|
||||
std::to_string(nowSwiperTime).c_str(), std::to_string(frameLossSwiperTime).c_str());
|
||||
lastSwiperTime = nowSwiperTime;
|
||||
upperScreenSwiperFlag = false;
|
||||
}
|
||||
@ -345,14 +336,14 @@ void StallingRateTrace::APPTabs(const std::string &line, const std::string &sign
|
||||
line.find(appTabsFrameAnimation) != std::string::npos ||
|
||||
line.find(appTabsScroll) != std::string::npos) {
|
||||
if (tabsFlag) {
|
||||
LOGI("APPTabs line start: (%s)", line.c_str());
|
||||
appTabsDynamicFinishTime = GetTimes(line, signF);
|
||||
LOGI("appTabsDynamicFinishTime: (%s)", std::to_string(appTabsDynamicFinishTime).c_str());
|
||||
LOGD("APPTabs line start: (%s), appTabsDynamicFinishTime: (%s)",
|
||||
line.c_str(), std::to_string(appTabsDynamicFinishTime).c_str());
|
||||
tabsFlag = false;
|
||||
} else {
|
||||
LOGI("APPTabs line finish: (%s)", line.c_str());
|
||||
appTabsDynamicStartTime = GetTimes(line, signS);
|
||||
LOGI("appTabsDynamicStartTime: (%s)", std::to_string(appTabsDynamicStartTime).c_str());
|
||||
LOGD("APPTabs line finish: (%s), appTabsDynamicStartTime: (%s)",
|
||||
line.c_str(), std::to_string(appTabsDynamicStartTime).c_str());
|
||||
tabsFlag = true;
|
||||
frameLossTabsTime = 0;
|
||||
}
|
||||
@ -362,16 +353,11 @@ void StallingRateTrace::APPTabs(const std::string &line, const std::string &sign
|
||||
if (upperScreenTabsFlag) {
|
||||
if (line.find("|H:Present Fence ") != std::string::npos) {
|
||||
fenceIdTabs = GetFenceId(line);
|
||||
LOGI("fenceIdTabs: (%s)", std::to_string(fenceIdTabs).c_str());
|
||||
}
|
||||
std::string waitFenceId = "|H:Waiting for Present Fence " + std::to_string(fenceIdTabs);
|
||||
if (line.find(waitFenceId) != std::string::npos) {
|
||||
nowTabsTime = std::stod(SmartPerf::StallingRateTrace::GetOnScreenTimeStart(line));
|
||||
LOGI("nowTabsTime: (%s)", std::to_string(nowTabsTime).c_str());
|
||||
LOGI("lastTabsTime: (%s)", std::to_string(lastTabsTime).c_str());
|
||||
LOGI("roundTabsTime: (%s)", std::to_string(roundTabsTime).c_str());
|
||||
GetFrameLossTime(nowTabsTime, lastTabsTime, roundTabsTime, frameLossTabsTime);
|
||||
LOGI("app tabs frameLossTabsTime: (%s)", std::to_string(frameLossTabsTime).c_str());
|
||||
lastTabsTime = nowTabsTime;
|
||||
upperScreenTabsFlag = false;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ void StartUpDelay::ClearOldServer() const
|
||||
|
||||
if (token != curPid) {
|
||||
SPUtils::LoadCmd(killCmd + token, killResult);
|
||||
LOGI("Find old server: %s, killed.", token.c_str());
|
||||
LOGD("Find old server: %s, killed.", token.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ std::string StartUpDelay::GetPidByPkg(const std::string &curPkgName)
|
||||
std::string resultProcId = ExecuteCommand(args);
|
||||
if (!resultProcId.empty() && resultProcId.back() == '\n') {
|
||||
resultProcId.pop_back();
|
||||
LOGI("startup_delay::output: (%s)", resultProcId.c_str());
|
||||
LOGD("startup_delay::output: (%s)", resultProcId.c_str());
|
||||
}
|
||||
return resultProcId;
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ ohos_unittest("plugin_module_api_ut") {
|
||||
"googletest:gtest",
|
||||
"hidumper:lib_dump_usage",
|
||||
"hilog:libhilog_base",
|
||||
"hisysevent:libhisysevent",
|
||||
"hiview:libucollection_graphic",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user