mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-23 06:50:12 +00:00
add hisysevent
Signed-off-by: hw-wLiu <liuwei573@huawei.com>
This commit is contained in:
parent
c5a78217f0
commit
e7fd76fa86
@ -56,7 +56,8 @@
|
|||||||
"zlib",
|
"zlib",
|
||||||
"grpc",
|
"grpc",
|
||||||
"storage_service",
|
"storage_service",
|
||||||
"abseil-cpp"
|
"abseil-cpp",
|
||||||
|
"hisysevent"
|
||||||
],
|
],
|
||||||
"third_party": [
|
"third_party": [
|
||||||
"cJSON",
|
"cJSON",
|
||||||
@ -64,6 +65,9 @@
|
|||||||
"libpng"
|
"libpng"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"hisysevent_config": [
|
||||||
|
"//developtools/profiler/hiprofiler.yaml"
|
||||||
|
],
|
||||||
"build": {
|
"build": {
|
||||||
"sub_component": [
|
"sub_component": [
|
||||||
"//developtools/profiler/device:hiprofiler_targets",
|
"//developtools/profiler/device:hiprofiler_targets",
|
||||||
|
@ -54,5 +54,16 @@ bool IsBetaVersion();
|
|||||||
std::pair<bool, std::string> CheckNotExistsFilePath(const std::string& filePath);
|
std::pair<bool, std::string> CheckNotExistsFilePath(const std::string& filePath);
|
||||||
bool CheckWhiteList(const std::string& cmdPath);
|
bool CheckWhiteList(const std::string& cmdPath);
|
||||||
bool CheckCmdLineArgValid(const std::string& cmdLine);
|
bool CheckCmdLineArgValid(const std::string& cmdLine);
|
||||||
|
int PluginWriteToHisysevent (std::string pluginName, std::string caller, std::string args, int errorCode,
|
||||||
|
std::string errorMessage);
|
||||||
|
|
||||||
|
enum ErrorType {
|
||||||
|
RET_NOT_SUPPORT,
|
||||||
|
RET_NULL_ADDR,
|
||||||
|
RET_IVALID_PID,
|
||||||
|
RET_MSG_EMPTY,
|
||||||
|
RET_FAIL = -1,
|
||||||
|
RET_SUCC = 0,
|
||||||
|
};
|
||||||
} // COMMON
|
} // COMMON
|
||||||
#endif // COMMON_H
|
#endif // COMMON_H
|
@ -33,6 +33,7 @@
|
|||||||
#include "application_info.h"
|
#include "application_info.h"
|
||||||
#include "bundle_mgr_proxy.h"
|
#include "bundle_mgr_proxy.h"
|
||||||
#include "file_ex.h"
|
#include "file_ex.h"
|
||||||
|
#include "hisysevent.h"
|
||||||
#include "iservice_registry.h"
|
#include "iservice_registry.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "system_ability_definition.h"
|
#include "system_ability_definition.h"
|
||||||
@ -773,4 +774,16 @@ bool CheckCmdLineArgValid(const std::string& cmdLine)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PluginWriteToHisysevent (std::string pluginName, std::string caller, std::string args, int errorCode,
|
||||||
|
std::string errorMessage)
|
||||||
|
{
|
||||||
|
return HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::HIPROFILER, "HIPROFILER_USAGE",
|
||||||
|
OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC,
|
||||||
|
"PLUGIN_NAME", pluginName,
|
||||||
|
"CALLER", caller,
|
||||||
|
"ARGS", args,
|
||||||
|
"ERROR_CODE", errorCode,
|
||||||
|
"ERROR_MESSAFE", errorMessage);
|
||||||
|
}
|
||||||
} // namespace COMMON
|
} // namespace COMMON
|
||||||
|
@ -37,6 +37,7 @@ ohos_source_set("cpudataplugin_source") {
|
|||||||
defines = [ "HAVE_HILOG" ]
|
defines = [ "HAVE_HILOG" ]
|
||||||
external_deps = [
|
external_deps = [
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -46,7 +47,10 @@ ohos_source_set("cpudataplugin_source") {
|
|||||||
ohos_shared_library("cpudataplugin") {
|
ohos_shared_library("cpudataplugin") {
|
||||||
output_name = "cpudataplugin"
|
output_name = "cpudataplugin"
|
||||||
version_script = "libcpu_plugin.map"
|
version_script = "libcpu_plugin.map"
|
||||||
deps = [ ":cpudataplugin_source" ]
|
deps = [
|
||||||
|
":cpudataplugin_source",
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
|
]
|
||||||
if (current_toolchain != host_toolchain) {
|
if (current_toolchain != host_toolchain) {
|
||||||
defines = [ "HAVE_HILOG" ]
|
defines = [ "HAVE_HILOG" ]
|
||||||
external_deps = [
|
external_deps = [
|
||||||
|
@ -99,6 +99,7 @@ private:
|
|||||||
DIR* OpenDestDir(std::string& dirPath);
|
DIR* OpenDestDir(std::string& dirPath);
|
||||||
int32_t GetValidTid(DIR* dirp);
|
int32_t GetValidTid(DIR* dirp);
|
||||||
ThreadState GetThreadState(const char threadState);
|
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);
|
template <typename T> void WriteThread(T& threadInfo, const char* pFile, uint32_t fileLen, int32_t tid);
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "cpu_plugin_result.pbencoder.h"
|
#include "cpu_plugin_result.pbencoder.h"
|
||||||
#include "buffer_splitter.h"
|
#include "buffer_splitter.h"
|
||||||
|
|
||||||
@ -68,6 +70,15 @@ CpuDataPlugin::~CpuDataPlugin()
|
|||||||
minFrequencyVec_.clear();
|
minFrequencyVec_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CpuDataPlugin::GetCmdArgs(CpuConfig protoConfig)
|
||||||
|
{
|
||||||
|
std::string args;
|
||||||
|
args += "pid: " + std::to_string(protoConfig.pid());
|
||||||
|
args += " report_process_info: ";
|
||||||
|
args += (protoConfig.report_process_info() ? "true" : "false");
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
int CpuDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
int CpuDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||||
{
|
{
|
||||||
buffer_ = malloc(READ_BUFFER_SIZE);
|
buffer_ = malloc(READ_BUFFER_SIZE);
|
||||||
@ -77,15 +88,19 @@ int CpuDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
|||||||
}
|
}
|
||||||
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, RET_FAIL,
|
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, RET_FAIL,
|
||||||
"%s:parseFromArray failed!", __func__);
|
"%s:parseFromArray failed!", __func__);
|
||||||
|
auto args = GetCmdArgs(protoConfig_);
|
||||||
if (protoConfig_.pid() > 0) {
|
if (protoConfig_.pid() > 0) {
|
||||||
pid_ = protoConfig_.pid();
|
pid_ = protoConfig_.pid();
|
||||||
} else if (protoConfig_.report_process_info()) {
|
} else if (protoConfig_.report_process_info()) {
|
||||||
PROFILER_LOG_INFO(LOG_CORE, "%s:need report process info", __func__);
|
PROFILER_LOG_INFO(LOG_CORE, "%s:need report process info", __func__);
|
||||||
} else {
|
} 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", __func__, ret);
|
||||||
return RET_FAIL;
|
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;
|
return RET_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ ohos_unittest("cpudataplugin_ut") {
|
|||||||
module_out_path = module_output_path
|
module_out_path = module_output_path
|
||||||
sources = [ "unittest/cpu_data_plugin_unittest.cpp" ]
|
sources = [ "unittest/cpu_data_plugin_unittest.cpp" ]
|
||||||
deps = [
|
deps = [
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugin_source",
|
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugin_source",
|
||||||
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugintest",
|
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugintest",
|
||||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/cpu_data:cpu_data_cpp",
|
"${OHOS_PROFILER_DIR}/protos/types/plugins/cpu_data:cpu_data_cpp",
|
||||||
|
@ -27,6 +27,7 @@ ohos_fuzztest("CpuStartPluginFuzzTest") {
|
|||||||
]
|
]
|
||||||
sources = [ "cpustartplugin_fuzzer.cpp" ]
|
sources = [ "cpustartplugin_fuzzer.cpp" ]
|
||||||
deps = [
|
deps = [
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugin_source",
|
"${OHOS_PROFILER_DIR}/device/plugins/cpu_plugin:cpudataplugin_source",
|
||||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/cpu_data:cpu_data_cpp",
|
"${OHOS_PROFILER_DIR}/protos/types/plugins/cpu_data:cpu_data_cpp",
|
||||||
]
|
]
|
||||||
|
@ -38,6 +38,7 @@ ohos_source_set("diskiodataplugin_source") {
|
|||||||
defines = [ "HAVE_HILOG" ]
|
defines = [ "HAVE_HILOG" ]
|
||||||
external_deps = [
|
external_deps = [
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -47,7 +48,10 @@ ohos_source_set("diskiodataplugin_source") {
|
|||||||
ohos_shared_library("diskiodataplugin") {
|
ohos_shared_library("diskiodataplugin") {
|
||||||
output_name = "diskiodataplugin"
|
output_name = "diskiodataplugin"
|
||||||
version_script = "libdiskio_plugin.map"
|
version_script = "libdiskio_plugin.map"
|
||||||
deps = [ ":diskiodataplugin_source" ]
|
deps = [
|
||||||
|
":diskiodataplugin_source",
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
|
]
|
||||||
if (current_toolchain != host_toolchain) {
|
if (current_toolchain != host_toolchain) {
|
||||||
defines = [ "HAVE_HILOG" ]
|
defines = [ "HAVE_HILOG" ]
|
||||||
external_deps = [
|
external_deps = [
|
||||||
|
@ -56,6 +56,8 @@ private:
|
|||||||
|
|
||||||
template <typename T> void WriteDiskioData(T& diskioData);
|
template <typename T> void WriteDiskioData(T& diskioData);
|
||||||
|
|
||||||
|
std::string GetCmdArgs(DiskioConfig protoConfig);
|
||||||
|
|
||||||
// for UT
|
// for UT
|
||||||
void SetPath(std::string path)
|
void SetPath(std::string path)
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include "buffer_splitter.h"
|
#include "buffer_splitter.h"
|
||||||
|
#include "common.h"
|
||||||
#include "diskio_plugin_result.pbencoder.h"
|
#include "diskio_plugin_result.pbencoder.h"
|
||||||
|
|
||||||
namespace {
|
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)
|
int DiskioDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||||
{
|
{
|
||||||
buffer_ = malloc(READ_BUFFER_SIZE);
|
buffer_ = malloc(READ_BUFFER_SIZE);
|
||||||
@ -57,7 +65,9 @@ int DiskioDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
|||||||
if (protoConfig_.report_io_stats()) {
|
if (protoConfig_.report_io_stats()) {
|
||||||
ioEntry_ = std::make_shared<IoStats>(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;
|
return RET_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ ohos_source_set("ftrace_plugin_source") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"hiview:libucollection_client",
|
"hiview:libucollection_client",
|
||||||
"init:libbegetutil",
|
"init:libbegetutil",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
|
@ -76,6 +76,7 @@ private:
|
|||||||
void EnableTraceEvents(void);
|
void EnableTraceEvents(void);
|
||||||
void DisableTraceEvents(void);
|
void DisableTraceEvents(void);
|
||||||
void DisableAllCategories(void);
|
void DisableAllCategories(void);
|
||||||
|
std::string GetCmdArgs(TracePluginConfig traceConfig);
|
||||||
|
|
||||||
template <typename T> bool ReportClockTimes(T& tracePluginResult);
|
template <typename T> bool ReportClockTimes(T& tracePluginResult);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "file_utils.h"
|
#include "file_utils.h"
|
||||||
#include "ftrace_field_parser.h"
|
#include "ftrace_field_parser.h"
|
||||||
#include "ftrace_fs_ops.h"
|
#include "ftrace_fs_ops.h"
|
||||||
@ -746,6 +747,36 @@ bool FlowController::AddPlatformEventsToParser(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string FlowController::GetCmdArgs(TracePluginConfig traceConfig)
|
||||||
|
{
|
||||||
|
std::string 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: ";
|
||||||
|
args += (traceConfig.parse_ksyms() ? "true" : "false");
|
||||||
|
args += ", clock: " + traceConfig.clock() + ", ";
|
||||||
|
args += "raw_data_prefix: " + traceConfig.raw_data_prefix() + ", ";
|
||||||
|
args += "debug_on: ";
|
||||||
|
args += (traceConfig.debug_on() ? "true" : "false");
|
||||||
|
args += ", discard_cache_data: ";
|
||||||
|
args += (traceConfig.discard_cache_data() ? "true" : "false");
|
||||||
|
args += ", parse_mode: " + std::to_string(traceConfig.parse_mode());
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
int FlowController::LoadConfig(const uint8_t configData[], uint32_t size)
|
int FlowController::LoadConfig(const uint8_t configData[], uint32_t size)
|
||||||
{
|
{
|
||||||
CHECK_TRUE(size > 0, -1, "config data size is zero!");
|
CHECK_TRUE(size > 0, -1, "config data size is zero!");
|
||||||
@ -790,6 +821,10 @@ int FlowController::LoadConfig(const uint8_t configData[], uint32_t size)
|
|||||||
SetupTraceReadPeriod(traceConfig.trace_period_ms());
|
SetupTraceReadPeriod(traceConfig.trace_period_ms());
|
||||||
flushCacheData_ = traceConfig.discard_cache_data();
|
flushCacheData_ = traceConfig.discard_cache_data();
|
||||||
hitraceTime_ = traceConfig.hitrace_time();
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ ohos_source_set("gpudataplugin_source") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -47,7 +48,10 @@ ohos_source_set("gpudataplugin_source") {
|
|||||||
ohos_shared_library("gpudataplugin") {
|
ohos_shared_library("gpudataplugin") {
|
||||||
output_name = "gpudataplugin"
|
output_name = "gpudataplugin"
|
||||||
version_script = "libgpu_plugin.map"
|
version_script = "libgpu_plugin.map"
|
||||||
deps = [ ":gpudataplugin_source" ]
|
deps = [
|
||||||
|
":gpudataplugin_source",
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
|
]
|
||||||
if (current_toolchain != host_toolchain) {
|
if (current_toolchain != host_toolchain) {
|
||||||
defines = [ "HAVE_HILOG" ]
|
defines = [ "HAVE_HILOG" ]
|
||||||
external_deps = [ "hilog:libhilog_base" ]
|
external_deps = [ "hilog:libhilog_base" ]
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int ReadFile();
|
int ReadFile();
|
||||||
|
std::string GetCmdArgs(GpuConfig traceConfig);
|
||||||
template <typename T> void WriteGpuDataInfo(T& gpuData);
|
template <typename T> void WriteGpuDataInfo(T& gpuData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "gpu_data_plugin.h"
|
#include "gpu_data_plugin.h"
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include "common.h"
|
||||||
#include "gpu_plugin_result.pbencoder.h"
|
#include "gpu_plugin_result.pbencoder.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -32,14 +33,27 @@ int GpuDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
file_.open(GPU_PATH);
|
file_.open(GPU_PATH);
|
||||||
|
auto args = GetCmdArgs(protoConfig_);
|
||||||
if (!file_.is_open()) {
|
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;
|
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;
|
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)
|
int GpuDataPlugin::ReportOptimize(RandomWriteCtx* randomWrite)
|
||||||
{
|
{
|
||||||
ProtoEncoder::GpuData dataProto(randomWrite);
|
ProtoEncoder::GpuData dataProto(randomWrite);
|
||||||
|
@ -36,6 +36,7 @@ ohos_source_set("hidumpplugin_source") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ private:
|
|||||||
// for ut
|
// for ut
|
||||||
void SetConfig(HidumpConfig& config);
|
void SetConfig(HidumpConfig& config);
|
||||||
int SetTestCmd(const char *test_cmd);
|
int SetTestCmd(const char *test_cmd);
|
||||||
|
std::string GetCmdArgs(HidumpConfig protoConfig);
|
||||||
const char *GetTestCmd();
|
const char *GetTestCmd();
|
||||||
char *testCmd_ = nullptr;
|
char *testCmd_ = nullptr;
|
||||||
private:
|
private:
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include "hidump_plugin_result.pbencoder.h"
|
|
||||||
#include "securec.h"
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "hidump_plugin_result.pbencoder.h"
|
||||||
|
#include "hisysevent.h"
|
||||||
|
#include "securec.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using namespace OHOS::Developtools::Profiler;
|
using namespace OHOS::Developtools::Profiler;
|
||||||
@ -58,6 +59,14 @@ HidumpPlugin::~HidumpPlugin()
|
|||||||
PROFILER_LOG_INFO(LOG_CORE, "%s: success!", __func__);
|
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)
|
int HidumpPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||||
{
|
{
|
||||||
PROFILER_LOG_INFO(LOG_CORE, "HidumpPlugin:Start ----> !");
|
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 {
|
COMMON::CustomPopen(fullCmd, "r", pipeFds_, childPid_, true), [this](FILE* fp) -> int {
|
||||||
return COMMON::CustomPclose(fp, pipeFds_, childPid_, true);
|
return COMMON::CustomPclose(fp, pipeFds_, childPid_, true);
|
||||||
});
|
});
|
||||||
|
auto args = GetCmdArgs(protoConfig_);
|
||||||
if (fp_.get() == nullptr) {
|
if (fp_.get() == nullptr) {
|
||||||
const int bufSize = 256;
|
const int bufSize = 256;
|
||||||
char buf[bufSize] = {0};
|
char buf[bufSize] = {0};
|
||||||
strerror_r(errno, buf, bufSize);
|
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);
|
PROFILER_LOG_ERROR(LOG_CORE, "HidumpPlugin: CustomPopen(%s) Failed, errno(%d:%s)", FPS_FORMAT, errno, buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -86,7 +97,8 @@ int HidumpPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
|||||||
std::unique_lock<std::mutex> locker(mutex_);
|
std::unique_lock<std::mutex> locker(mutex_);
|
||||||
running_ = true;
|
running_ = true;
|
||||||
writeThread_ = std::thread([this] { this->Loop(); });
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ ohos_source_set("hilogplugin_source") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ private:
|
|||||||
bool FindFirstNum(char** p);
|
bool FindFirstNum(char** p);
|
||||||
bool RemoveSpaces(char** p);
|
bool RemoveSpaces(char** p);
|
||||||
bool FindFirstSpace(char** p);
|
bool FindFirstSpace(char** p);
|
||||||
|
std::string GetCmdArgs(HilogConfig protoConfig);
|
||||||
|
|
||||||
bool StringToL(const char* word, long& value);
|
bool StringToL(const char* word, long& value);
|
||||||
// for ut
|
// for ut
|
||||||
|
@ -68,6 +68,17 @@ HilogPlugin::~HilogPlugin()
|
|||||||
PROFILER_LOG_INFO(LOG_CORE, "%s: success!", __func__);
|
PROFILER_LOG_INFO(LOG_CORE, "%s: success!", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string HilogPlugin::GetCmdArgs(HilogConfig protoConfig)
|
||||||
|
{
|
||||||
|
std::string args;
|
||||||
|
args += "log_level: " + std::to_string(protoConfig.log_level());
|
||||||
|
args += "pid: " + std::to_string(protoConfig.pid()) + ", need_record: ";
|
||||||
|
args += (protoConfig.need_record() ? "true" : "false");
|
||||||
|
args += ", need_clear: ";
|
||||||
|
args += (protoConfig.need_clear() ? "true" : "false");
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
int HilogPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
int HilogPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
||||||
{
|
{
|
||||||
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, -1, "HilogPlugin: ParseFromArray failed");
|
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, -1, "HilogPlugin: ParseFromArray failed");
|
||||||
@ -106,8 +117,11 @@ int HilogPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
|||||||
fcntl(fileno(fp_.get()), F_SETPIPE_SZ, oldPipeSize * PIPE_SIZE_RATIO);
|
fcntl(fileno(fp_.get()), F_SETPIPE_SZ, oldPipeSize * PIPE_SIZE_RATIO);
|
||||||
int pipeSize = fcntl(fileno(fp_.get()), F_GETPIPE_SZ);
|
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);
|
PROFILER_LOG_INFO(LOG_CORE, "{fp = %d, pipeSize=%d, oldPipeSize=%d}", fileno(fp_.get()), pipeSize, oldPipeSize);
|
||||||
|
|
||||||
workThread_ = std::thread([this] { this->Run(); });
|
workThread_ = std::thread([this] { this->Run(); });
|
||||||
|
|
||||||
|
int ret = COMMON::PluginWriteToHisysevent("hidump_plugin", "sh", GetCmdArgs(protoConfig_),
|
||||||
|
COMMON::ErrorType::RET_SUCC, "success");
|
||||||
|
PROFILER_LOG_INFO(LOG_CORE, "hisysevent report hilog_plugin result:%d", ret);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ ohos_source_set("hiperfplugin_source") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"openssl:libcrypto_shared",
|
"openssl:libcrypto_shared",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
|
@ -22,10 +22,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "hiperf_plugin_config.pb.h"
|
#include "hiperf_plugin_config.pb.h"
|
||||||
|
#include "hisysevent.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "common.h"
|
|
||||||
#include "trace_file_writer.h"
|
#include "trace_file_writer.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -111,6 +112,18 @@ bool RunCommand(const std::string& cmd)
|
|||||||
CHECK_TRUE(res, false, "HiperfPlugin::RunCommand: execute command FAILED!");
|
CHECK_TRUE(res, false, "HiperfPlugin::RunCommand: execute command FAILED!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GetCmdArgs(HiperfPluginConfig protoConfig)
|
||||||
|
{
|
||||||
|
std::string args;
|
||||||
|
args += "is_root: ";
|
||||||
|
args += (protoConfig.is_root() ? "true" : "false");
|
||||||
|
args += ", outfile_name: " + protoConfig.outfile_name();
|
||||||
|
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;
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int HiperfPluginSessionStart(const uint8_t* configData, const uint32_t configSize)
|
int HiperfPluginSessionStart(const uint8_t* configData, const uint32_t configSize)
|
||||||
@ -141,6 +154,9 @@ int HiperfPluginSessionStart(const uint8_t* configData, const uint32_t configSiz
|
|||||||
CHECK_TRUE(res, -1, "HiperfPluginSessionStart, RunCommand(%s) FAILED!", cmd.c_str());
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ ohos_source_set("hisyseventplugin_source") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::string GetFullCmd();
|
std::string GetFullCmd();
|
||||||
bool InitHisyseventCmd();
|
bool InitHisyseventCmd();
|
||||||
|
std::string GetCmdArgs(HisyseventConfig protoConfig);
|
||||||
|
|
||||||
template <typename T> bool ParseSyseventLineInfo(const char* data, size_t len, T hisyseventInfoProto);
|
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;
|
running_ = true;
|
||||||
workThread_ = std::thread([this] { this->Run(); });
|
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;
|
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()
|
int HisyseventPlugin::Stop()
|
||||||
{
|
{
|
||||||
PROFILER_LOG_INFO(LOG_CORE, "BEGN %s: ready!", __func__);
|
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",
|
"drivers_interface_memorytracker:libmemorytracker_proxy_1.0",
|
||||||
"hidumper:lib_dump_usage",
|
"hidumper:lib_dump_usage",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"hiview:libucollection_graphic",
|
"hiview:libucollection_graphic",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
|
@ -349,7 +349,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> void WriteProcesseList(T& memoryData);
|
template <typename T> void WriteProcesseList(T& memoryData);
|
||||||
|
std::string GetCmdArgs(MemoryConfig traceConfig);
|
||||||
template <typename T> void WriteProcinfoByPidfds(T& processMemoryInfo, int32_t pid);
|
template <typename T> void WriteProcinfoByPidfds(T& processMemoryInfo, int32_t pid);
|
||||||
|
|
||||||
DIR* OpenDestDir(const char* dirPath);
|
DIR* OpenDestDir(const char* dirPath);
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
#include "memory_plugin_result.pbencoder.h"
|
#include "memory_plugin_result.pbencoder.h"
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "smaps_stats.h"
|
#include "smaps_stats.h"
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using namespace OHOS::HDI::Memorytracker::V1_0;
|
using namespace OHOS::HDI::Memorytracker::V1_0;
|
||||||
@ -199,10 +199,55 @@ 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;
|
return RET_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string MemoryDataPlugin::GetCmdArgs(MemoryConfig traceConfig)
|
||||||
|
{
|
||||||
|
std::string args;
|
||||||
|
args += "report_process_tree: ";
|
||||||
|
args += (traceConfig.report_process_tree() ? "true" : "false");
|
||||||
|
args += ", report_sysmem_mem_info: ";
|
||||||
|
args += (traceConfig.report_sysmem_mem_info() ? "true" : "false");
|
||||||
|
args += ", report_sysmem_vmem_info: ";
|
||||||
|
args += (traceConfig.report_sysmem_vmem_info() ? "true" : "false");
|
||||||
|
args += ", report_process_mem_info: ";
|
||||||
|
args += (traceConfig.report_process_mem_info() ? "true" : "false");
|
||||||
|
args += ", report_app_mem_info: ";
|
||||||
|
args += (traceConfig.report_app_mem_info() ? "true" : "false");
|
||||||
|
args += ", report_app_mem_by_memory_service: ";
|
||||||
|
args += (traceConfig.report_app_mem_by_memory_service() ? "true" : "false");
|
||||||
|
args += ", report_smaps_mem_info: ";
|
||||||
|
args += (traceConfig.report_smaps_mem_info() ? "true" : "false");
|
||||||
|
args += ", report_purgeable_ashmem_info: ";
|
||||||
|
args += (traceConfig.report_purgeable_ashmem_info() ? "true" : "false");
|
||||||
|
args += ", report_dma_mem_info: ";
|
||||||
|
args += (traceConfig.report_dma_mem_info() ? "true" : "false");
|
||||||
|
args += ", report_gpu_mem_info: ";
|
||||||
|
args += (traceConfig.report_gpu_mem_info() ? "true" : "false");
|
||||||
|
args += ", report_gpu_dump_info: ";
|
||||||
|
args += (traceConfig.report_gpu_dump_info() ? "true" : "false");
|
||||||
|
args += ", report_fake_data: ";
|
||||||
|
args += (traceConfig.report_fake_data() ? "true" : "false");
|
||||||
|
|
||||||
|
args += ", ";
|
||||||
|
for (const auto& count : traceConfig.sys_meminfo_counters()) {
|
||||||
|
args += "sys_meminfo_counters: " + std::to_string(count) + ", ";
|
||||||
|
}
|
||||||
|
for (const auto& count : traceConfig.sys_vmeminfo_counters()) {
|
||||||
|
args += "sys_vmeminfo_counters: " + std::to_string(count) + ", ";
|
||||||
|
}
|
||||||
|
for (const auto& p : traceConfig.pid()) {
|
||||||
|
args += "pid: " + std::to_string(p) + ", ";
|
||||||
|
}
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T> void MemoryDataPlugin::WriteMeminfo(T& memoryData)
|
template <typename T> void MemoryDataPlugin::WriteMeminfo(T& memoryData)
|
||||||
{
|
{
|
||||||
int readsize = ReadFile(meminfoFd_);
|
int readsize = ReadFile(meminfoFd_);
|
||||||
|
@ -126,6 +126,7 @@ ohos_executable("native_daemon") {
|
|||||||
"access_token:libaccesstoken_sdk",
|
"access_token:libaccesstoken_sdk",
|
||||||
"access_token:libtokensetproc_shared",
|
"access_token:libtokensetproc_shared",
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"init:libbegetutil",
|
"init:libbegetutil",
|
||||||
"ipc:ipc_core",
|
"ipc:ipc_core",
|
||||||
"openssl:libcrypto_shared",
|
"openssl:libcrypto_shared",
|
||||||
@ -202,6 +203,7 @@ ohos_shared_library("libnative_daemon_client") {
|
|||||||
"bundle_framework:appexecfwk_base",
|
"bundle_framework:appexecfwk_base",
|
||||||
"bundle_framework:appexecfwk_core",
|
"bundle_framework:appexecfwk_core",
|
||||||
"c_utils:utils",
|
"c_utils:utils",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"init:libbegetutil",
|
"init:libbegetutil",
|
||||||
"ipc:ipc_core",
|
"ipc:ipc_core",
|
||||||
"os_account:os_account_innerkits",
|
"os_account:os_account_innerkits",
|
||||||
|
@ -104,6 +104,7 @@ public:
|
|||||||
int32_t CreatePluginSession();
|
int32_t CreatePluginSession();
|
||||||
void RegisterWriter(const std::shared_ptr<Writer> writer);
|
void RegisterWriter(const std::shared_ptr<Writer> writer);
|
||||||
void WriteHookConfig();
|
void WriteHookConfig();
|
||||||
|
std::string GetCmdArgs(NativeHookConfig traceConfig);
|
||||||
std::pair<int, int> GetFds(int32_t pid, const std::string& name);
|
std::pair<int, int> GetFds(int32_t pid, const std::string& name);
|
||||||
inline void SetSaServiceConfig(bool saFlag, bool isProtobufSerialize)
|
inline void SetSaServiceConfig(bool saFlag, bool isProtobufSerialize)
|
||||||
{
|
{
|
||||||
|
@ -127,6 +127,7 @@ ohos_unittest("native_memory_profiler_sa_ut") {
|
|||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"c_utils:utils",
|
"c_utils:utils",
|
||||||
"googletest:gtest",
|
"googletest:gtest",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"init:libbegetutil",
|
"init:libbegetutil",
|
||||||
"ipc:ipc_core",
|
"ipc:ipc_core",
|
||||||
"openssl:libcrypto_shared",
|
"openssl:libcrypto_shared",
|
||||||
|
@ -763,6 +763,57 @@ void HookManager::StartPluginSession()
|
|||||||
PROFILER_LOG_INFO(LOG_CORE, "StartPluginSession: pid(%d) is less or equal zero.", item->pid);
|
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::string args;
|
||||||
|
args += "pid: " + std::to_string(traceConfig.pid()) + ", save_file: ";
|
||||||
|
args += (traceConfig.save_file() ? "true" : "false");
|
||||||
|
args += ", file_name: " + traceConfig.file_name();
|
||||||
|
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() + ", malloc_disable: ";
|
||||||
|
args += (traceConfig.malloc_disable() ? "true" : "false");
|
||||||
|
args += ", mmap_disable: "
|
||||||
|
args += (traceConfig.mmap_disable() ? "true" : "false");
|
||||||
|
args += ", free_stack_report: "
|
||||||
|
args += (traceConfig.free_stack_report() ? "true" : "false");
|
||||||
|
args += ", munmap_stack_report: "
|
||||||
|
args += (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: "
|
||||||
|
args += (traceConfig.string_compressed() ? "true" : "false");
|
||||||
|
args += ", fp_unwind: "
|
||||||
|
args += (traceConfig.fp_unwind() ? "true" : "false");
|
||||||
|
args += ", blocked: "
|
||||||
|
args += (traceConfig.blocked() ? "true" : "false");
|
||||||
|
args += ", record_accurately: "
|
||||||
|
args += (traceConfig.record_accurately() ? "true" : "false");
|
||||||
|
args += ", startup_mode: "
|
||||||
|
args += (traceConfig.startup_mode() ? "true" : "false");
|
||||||
|
args += ", memtrace_enable: "
|
||||||
|
args += (traceConfig.memtrace_enable() ? "true" : "false");
|
||||||
|
args += ", offline_symbolization: "
|
||||||
|
args += (traceConfig.offline_symbolization() ? "true" : "false");
|
||||||
|
args += ", callframe_compress: "
|
||||||
|
args += (traceConfig.callframe_compress() ? "true" : "false");
|
||||||
|
args += ", statistics_interval: " + std::to_string(traceConfig.statistics_interval());
|
||||||
|
args += ", clock: " + traceConfig.clock() + ", sample_interval: ";
|
||||||
|
args += std::to_string(traceConfig.sample_interval()) + ", response_library_mode: ";
|
||||||
|
args += (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(p) + ", ";
|
||||||
|
}
|
||||||
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HookManager::WriteHookConfig()
|
void HookManager::WriteHookConfig()
|
||||||
|
@ -126,6 +126,7 @@ ohos_unittest("native_daemon_ut") {
|
|||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"faultloggerd:libunwinder",
|
"faultloggerd:libunwinder",
|
||||||
"googletest:gtest",
|
"googletest:gtest",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"init:libbegetutil",
|
"init:libbegetutil",
|
||||||
"openssl:libcrypto_shared",
|
"openssl:libcrypto_shared",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
|
@ -39,6 +39,7 @@ ohos_source_set("networkplugin_source") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -47,7 +48,10 @@ ohos_source_set("networkplugin_source") {
|
|||||||
ohos_shared_library("networkplugin") {
|
ohos_shared_library("networkplugin") {
|
||||||
output_name = "networkplugin"
|
output_name = "networkplugin"
|
||||||
version_script = "libnetwork_plugin.map"
|
version_script = "libnetwork_plugin.map"
|
||||||
deps = [ ":networkplugin_source" ]
|
deps = [
|
||||||
|
":networkplugin_source",
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
|
]
|
||||||
if (current_toolchain != host_toolchain) {
|
if (current_toolchain != host_toolchain) {
|
||||||
defines = [ "HAVE_HILOG" ]
|
defines = [ "HAVE_HILOG" ]
|
||||||
external_deps = [ "hilog:libhilog_base" ]
|
external_deps = [ "hilog:libhilog_base" ]
|
||||||
|
@ -93,6 +93,7 @@ protected:
|
|||||||
bool ReadSystemTxRxBytes(NetSystemData &systemData);
|
bool ReadSystemTxRxBytes(NetSystemData &systemData);
|
||||||
void AddNetDetails(NetworkCell& cell, NetDetails& data);
|
void AddNetDetails(NetworkCell& cell, NetDetails& data);
|
||||||
void AddNetSystemDetails(NetSystemData& systemData, NetSystemDetails& data);
|
void AddNetSystemDetails(NetSystemData& systemData, NetSystemDetails& data);
|
||||||
|
std::string GetCmdArgs(NetworkConfig traceConfig);
|
||||||
// for UT
|
// for UT
|
||||||
void setPathForTest(std::string path)
|
void setPathForTest(std::string path)
|
||||||
{
|
{
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "buffer_splitter.h"
|
#include "buffer_splitter.h"
|
||||||
|
#include "common.h"
|
||||||
#include "network_plugin_result.pbencoder.h"
|
#include "network_plugin_result.pbencoder.h"
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
|
|
||||||
@ -47,11 +48,22 @@ int NetworkPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
|||||||
pidUid_.emplace(pid, GetUid(pid));
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string NetworkPlugin::GetCmdArgs(NetworkConfig traceConfig)
|
||||||
|
{
|
||||||
|
std::string args;
|
||||||
|
for (const auto& p : traceConfig.pid()) {
|
||||||
|
args += "pid: " + std::to_string(p) + ", ";
|
||||||
|
}
|
||||||
|
args += "test_file: " + traceConfig.test_file();
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T> bool NetworkPlugin::WriteNetWorkData(T& networkDatasProto)
|
template <typename T> bool NetworkPlugin::WriteNetWorkData(T& networkDatasProto)
|
||||||
{
|
{
|
||||||
std::string file = GetRateNodePath();
|
std::string file = GetRateNodePath();
|
||||||
|
@ -26,6 +26,7 @@ ohos_unittest("networkplugin_ut") {
|
|||||||
module_out_path = module_output_path
|
module_out_path = module_output_path
|
||||||
sources = [ "unittest/network_plugin_test.cpp" ]
|
sources = [ "unittest/network_plugin_test.cpp" ]
|
||||||
deps = [
|
deps = [
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
"${OHOS_PROFILER_DIR}/device/plugins/network_plugin:networkplugin_source",
|
"${OHOS_PROFILER_DIR}/device/plugins/network_plugin:networkplugin_source",
|
||||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/network_data:network_data_cpp",
|
"${OHOS_PROFILER_DIR}/protos/types/plugins/network_data:network_data_cpp",
|
||||||
]
|
]
|
||||||
|
@ -28,6 +28,7 @@ ohos_fuzztest("NetworkStartPluginFuzzTest") {
|
|||||||
]
|
]
|
||||||
sources = [ "networkstartplugin_fuzzer.cpp" ]
|
sources = [ "networkstartplugin_fuzzer.cpp" ]
|
||||||
deps = [
|
deps = [
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
"${OHOS_PROFILER_DIR}/device/plugins/network_plugin:networkplugin_source",
|
"${OHOS_PROFILER_DIR}/device/plugins/network_plugin:networkplugin_source",
|
||||||
"${OHOS_PROFILER_DIR}/protos/types/plugins/network_data:network_data_cpp",
|
"${OHOS_PROFILER_DIR}/protos/types/plugins/network_data:network_data_cpp",
|
||||||
]
|
]
|
||||||
|
@ -49,6 +49,7 @@ ohos_source_set("network_profiler_service") {
|
|||||||
]
|
]
|
||||||
|
|
||||||
external_deps = [
|
external_deps = [
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"init:libbegetutil",
|
"init:libbegetutil",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
|
@ -71,9 +71,13 @@ public:
|
|||||||
bool ResetWriter(uint32_t pluginId) override;
|
bool ResetWriter(uint32_t pluginId) override;
|
||||||
void SetCommandPoller(const std::shared_ptr<CommandPoller>& p) override;
|
void SetCommandPoller(const std::shared_ptr<CommandPoller>& p) override;
|
||||||
bool RegisterAgentPlugin(const std::string& pluginPath);
|
bool RegisterAgentPlugin(const std::string& pluginPath);
|
||||||
|
std::string GetCmdArgs(NetworkProfilerConfig traceConfig);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool CheckConfig();
|
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);
|
bool HandleNetworkProfilerContext(const std::shared_ptr<NetworkProfilerCtx>& ctx);
|
||||||
clockid_t GetClockId(NetworkProfilerConfig::ClockId clockType);
|
clockid_t GetClockId(NetworkProfilerConfig::ClockId clockType);
|
||||||
|
|
||||||
|
@ -57,9 +57,8 @@ void NetworkProfilerManager::Init()
|
|||||||
RegisterAgentPlugin("network-profiler");
|
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()) {
|
for (const auto& pid : config_.pid()) {
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
if (COMMON::IsUserMode() && (!COMMON::CheckApplicationPermission(pid, ""))) {
|
if (COMMON::IsUserMode() && (!COMMON::CheckApplicationPermission(pid, ""))) {
|
||||||
@ -70,17 +69,19 @@ bool NetworkProfilerManager::CheckConfig()
|
|||||||
if (stat(pidPath.c_str(), &statBuf) != 0) {
|
if (stat(pidPath.c_str(), &statBuf) != 0) {
|
||||||
PROFILER_LOG_ERROR(LOG_CORE, "%s: hook process does not exist", __func__);
|
PROFILER_LOG_ERROR(LOG_CORE, "%s: hook process does not exist", __func__);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
auto [iter, ret] = pidCache.emplace(pid);
|
auto [iter, ret] = pidCache.emplace(pid);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
networkCtx_.emplace_back(std::make_shared<NetworkProfilerCtx>(pid));
|
networkCtx_.emplace_back(std::make_shared<NetworkProfilerCtx>(pid));
|
||||||
paramValue_ += std::to_string(pid) + ",";
|
paramValue_ += std::to_string(pid) + ",";
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NetworkProfilerManager::CheckStartupProcessName()
|
||||||
|
{
|
||||||
for (const auto& name : config_.startup_process_name()) {
|
for (const auto& name : config_.startup_process_name()) {
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
continue;
|
continue;
|
||||||
@ -98,7 +99,11 @@ bool NetworkProfilerManager::CheckConfig()
|
|||||||
networkCtx_.emplace_back(std::make_shared<NetworkProfilerCtx>(name));
|
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()) {
|
for (const auto& name : config_.restart_process_name()) {
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
continue;
|
continue;
|
||||||
@ -123,6 +128,21 @@ bool NetworkProfilerManager::CheckConfig()
|
|||||||
return false;
|
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) {
|
if (config_.flush_interval() == 0) {
|
||||||
config_.set_flush_interval(1);
|
config_.set_flush_interval(1);
|
||||||
@ -170,15 +190,42 @@ bool NetworkProfilerManager::StartNetworkProfiler()
|
|||||||
|
|
||||||
int ret = SystemSetParameter(PARAM_KAY.c_str(), paramValue_.c_str());
|
int ret = SystemSetParameter(PARAM_KAY.c_str(), paramValue_.c_str());
|
||||||
PROFILER_LOG_INFO(LOG_CORE, "StartNetworkProfiler parameter: %s", paramValue_.c_str());
|
PROFILER_LOG_INFO(LOG_CORE, "StartNetworkProfiler parameter: %s", paramValue_.c_str());
|
||||||
|
|
||||||
|
auto args = GetCmdArgs(config_);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
PROFILER_LOG_ERROR(LOG_CORE, "StartNetworkProfiler set parameter failed");
|
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;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
PROFILER_LOG_INFO(LOG_CORE, "StartNetworkProfiler set parameter success");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string NetworkProfilerManager::GetCmdArgs(NetworkProfilerConfig traceConfig)
|
||||||
|
{
|
||||||
|
std::string args;
|
||||||
|
for (const auto& p : traceConfig.pid()) {
|
||||||
|
args += "pid: " + std::to_string(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: ";
|
||||||
|
args += (traceConfig.block() ? "true" : "false");
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkProfilerManager::StopNetworkProfiler()
|
void NetworkProfilerManager::StopNetworkProfiler()
|
||||||
{
|
{
|
||||||
int ret = SystemSetParameter(PARAM_KAY.c_str(), "");
|
int ret = SystemSetParameter(PARAM_KAY.c_str(), "");
|
||||||
|
@ -37,6 +37,7 @@ ohos_source_set("processplugin_source") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -48,7 +49,10 @@ ohos_source_set("processplugin_source") {
|
|||||||
ohos_shared_library("processplugin") {
|
ohos_shared_library("processplugin") {
|
||||||
output_name = "processplugin"
|
output_name = "processplugin"
|
||||||
version_script = "libprocess_plugin.map"
|
version_script = "libprocess_plugin.map"
|
||||||
deps = [ ":processplugin_source" ]
|
deps = [
|
||||||
|
":processplugin_source",
|
||||||
|
"${OHOS_PROFILER_DIR}/device/base:hiprofiler_base",
|
||||||
|
]
|
||||||
if (current_toolchain != host_toolchain) {
|
if (current_toolchain != host_toolchain) {
|
||||||
defines = [ "HAVE_HILOG" ]
|
defines = [ "HAVE_HILOG" ]
|
||||||
external_deps = [ "hilog:libhilog_base" ]
|
external_deps = [ "hilog:libhilog_base" ]
|
||||||
|
@ -95,6 +95,8 @@ private:
|
|||||||
|
|
||||||
template <typename T> bool WritePssData(int pid, T& processinfo);
|
template <typename T> bool WritePssData(int pid, T& processinfo);
|
||||||
|
|
||||||
|
std::string GetCmdArgs(ProcessConfig traceConfig);
|
||||||
|
|
||||||
ProcessConfig protoConfig_;
|
ProcessConfig protoConfig_;
|
||||||
std::unique_ptr<uint8_t[]> buffer_;
|
std::unique_ptr<uint8_t[]> buffer_;
|
||||||
std::vector<int32_t> pids_;
|
std::vector<int32_t> pids_;
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "buffer_splitter.h"
|
#include "buffer_splitter.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "hisysevent.h"
|
||||||
#include "process_plugin_result.pbencoder.h"
|
#include "process_plugin_result.pbencoder.h"
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
|
|
||||||
@ -56,10 +58,26 @@ int ProcessDataPlugin::Start(const uint8_t* configData, uint32_t configSize)
|
|||||||
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, RET_FAIL,
|
CHECK_TRUE(protoConfig_.ParseFromArray(configData, configSize) > 0, RET_FAIL,
|
||||||
"%s:parseFromArray failed!", __func__);
|
"%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;
|
return RET_SUCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ProcessDataPlugin::GetCmdArgs(ProcessConfig traceConfig)
|
||||||
|
{
|
||||||
|
std::string args;
|
||||||
|
args += "report_process_tree: ";
|
||||||
|
args += (traceConfig.report_process_tree() ? "true" : "false");
|
||||||
|
args += ", report_cpu: ";
|
||||||
|
args += (traceConfig.report_cpu() ? "true" : "false");
|
||||||
|
args += ", report_diskio: ";
|
||||||
|
args += (traceConfig.report_diskio() ? "true" : "false");
|
||||||
|
args += ", report_pss: ";
|
||||||
|
args += (traceConfig.report_pss() ? "true" : "false");
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
int ProcessDataPlugin::ReportOptimize(RandomWriteCtx* randomWrite)
|
int ProcessDataPlugin::ReportOptimize(RandomWriteCtx* randomWrite)
|
||||||
{
|
{
|
||||||
ProtoEncoder::ProcessData dataProto(randomWrite);
|
ProtoEncoder::ProcessData dataProto(randomWrite);
|
||||||
|
@ -36,6 +36,7 @@ ohos_shared_library("xpowerplugin") {
|
|||||||
external_deps = [
|
external_deps = [
|
||||||
"bounds_checking_function:libsec_shared",
|
"bounds_checking_function:libsec_shared",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public:
|
|||||||
void OptimizeCallback(const std::uint32_t messageType, const uint8_t* protoData, size_t protoSize);
|
void OptimizeCallback(const std::uint32_t messageType, const uint8_t* protoData, size_t protoSize);
|
||||||
void SetWriter(WriterStruct* writer);
|
void SetWriter(WriterStruct* writer);
|
||||||
bool StartPowerManager(std::uint32_t messageType, std::string& bundleName);
|
bool StartPowerManager(std::uint32_t messageType, std::string& bundleName);
|
||||||
|
std::string GetCmdArgs(XpowerConfig traceConfig);
|
||||||
private:
|
private:
|
||||||
void* powerClientHandle_ = nullptr;
|
void* powerClientHandle_ = nullptr;
|
||||||
XpowerConfig protoConfig_;
|
XpowerConfig protoConfig_;
|
||||||
|
@ -48,6 +48,17 @@ XpowerPlugin::~XpowerPlugin()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string XpowerPlugin::GetCmdArgs(XpowerConfig traceConfig)
|
||||||
|
{
|
||||||
|
std::string args;
|
||||||
|
|
||||||
|
args += "bundle_name: " + traceConfig.bundle_name() + ", ";
|
||||||
|
for (const auto& type : traceConfig.message_type()) {
|
||||||
|
args += "type: " + std::to_string(type) + ", ";
|
||||||
|
}
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
||||||
{
|
{
|
||||||
PROFILER_LOG_INFO(LOG_CORE, "%s:config data -->configSize=%d", __func__, 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;
|
messageType |= mesType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
auto args = GetCmdArgs(protoConfig_);
|
||||||
if (messageType == 0) {
|
if (messageType == 0) {
|
||||||
PROFILER_LOG_ERROR(LOG_CORE, "XpowerPlugin error : messageType is empty!");
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
PROFILER_LOG_INFO(LOG_CORE, "bundleName is %s,messagetype is %d", bundleName.c_str(), messageType);
|
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) {
|
(messageType & OptimizeMessageType::MESSAGE_ABNORMAL_EVENTS) != 0) {
|
||||||
if (bundleName.empty()) {
|
if (bundleName.empty()) {
|
||||||
PROFILER_LOG_ERROR(LOG_CORE, "XpowerPlugin error : bundle name is 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;
|
return -1;
|
||||||
}
|
}
|
||||||
// check bundleName
|
// check bundleName
|
||||||
int32_t uid = COMMON::GetPackageUid(bundleName);
|
int32_t uid = COMMON::GetPackageUid(bundleName);
|
||||||
if (uid < AID_HAP_START || uid > AID_HAP_END) {
|
if (uid < AID_HAP_START || uid > AID_HAP_END) {
|
||||||
PROFILER_LOG_ERROR(LOG_CORE, "the bundle name %s is not supported", bundleName.c_str());
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,6 +105,8 @@ int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
|||||||
bool isExsit = COMMON::IsProcessExist(bundleName, processId);
|
bool isExsit = COMMON::IsProcessExist(bundleName, processId);
|
||||||
if (!isExsit) {
|
if (!isExsit) {
|
||||||
PROFILER_LOG_ERROR(LOG_CORE, "%s:the process %s does not exist.", __func__, bundleName.c_str());
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,9 +114,13 @@ int XpowerPlugin::Start(const uint8_t *configData, uint32_t configSize)
|
|||||||
// 加载对应so 库文件
|
// 加载对应so 库文件
|
||||||
if (!StartPowerManager(messageType, bundleName)) {
|
if (!StartPowerManager(messageType, bundleName)) {
|
||||||
PROFILER_LOG_ERROR(LOG_CORE, "start power manager failed!");
|
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;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
hiprofiler.yaml
Normal file
22
hiprofiler.yaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
domain: PROFILER
|
||||||
|
|
||||||
|
HIPROFILER_USAGE:
|
||||||
|
__BASE: {type: STATISTIC, level: CRITICAL, tag: usageStats, desc: cpu_plugin usage statistics}
|
||||||
|
PLUGIN_NAME: { type: STRING desc: hiprofiler plugin name }
|
||||||
|
CALLER: {type: STRING, desc: hiprofiler caller} sh
|
||||||
|
ARGS: {type: STRING, desc: hiprofiler plugin args}
|
||||||
|
ERROR_CODE: { type: INT32. desc: hiprofiler request error code }
|
||||||
|
ERROR_MESSAGE: { type: STRING, desc: hiprofiler request error message}
|
@ -60,6 +60,7 @@ ohos_unittest("plugin_module_api_ut") {
|
|||||||
"googletest:gtest",
|
"googletest:gtest",
|
||||||
"hidumper:lib_dump_usage",
|
"hidumper:lib_dump_usage",
|
||||||
"hilog:libhilog_base",
|
"hilog:libhilog_base",
|
||||||
|
"hisysevent:libhisysevent",
|
||||||
"hiview:libucollection_graphic",
|
"hiview:libucollection_graphic",
|
||||||
"protobuf:protobuf_lite",
|
"protobuf:protobuf_lite",
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user