mirror of
https://gitee.com/openharmony/hiviewdfx_hiview
synced 2024-11-23 00:59:49 +00:00
dft rom optimize
Signed-off-by: negegne <zhengshunxin@huawei.com>
This commit is contained in:
parent
63e0aac337
commit
7e2156c753
@ -70,7 +70,7 @@ bool ConditionParser::ParseJsonString(const Json::Value& root, const std::string
|
||||
|
||||
EventStore::Op ConditionParser::GetOpEnum(const std::string& op)
|
||||
{
|
||||
const std::unordered_map<std::string, EventStore::Op> opMap = {
|
||||
const std::map<std::string, EventStore::Op> opMap = {
|
||||
{ "=", EventStore::Op::EQ },
|
||||
{ "<", EventStore::Op::LT },
|
||||
{ ">", EventStore::Op::GT },
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -16,6 +16,8 @@
|
||||
#ifndef HIVIEW_SERVICE_ABILITY_STUB_H
|
||||
#define HIVIEW_SERVICE_ABILITY_STUB_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "ihiview_service_ability.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "message_parcel.h"
|
||||
@ -58,10 +60,10 @@ private:
|
||||
|
||||
bool IsPermissionGranted(uint32_t code);
|
||||
RequestHandler GetRequestHandler(uint32_t code);
|
||||
std::unordered_map<uint32_t, RequestHandler> GetRequestHandlers();
|
||||
std::unordered_map<uint32_t, RequestHandler> GetTraceRequestHandlers();
|
||||
std::unordered_map<uint32_t, RequestHandler> GetCpuRequestHandlers();
|
||||
std::unordered_map<uint32_t, RequestHandler> GetMemoryRequestHandlers();
|
||||
std::map<uint32_t, RequestHandler> GetRequestHandlers();
|
||||
std::map<uint32_t, RequestHandler> GetTraceRequestHandlers();
|
||||
std::map<uint32_t, RequestHandler> GetCpuRequestHandlers();
|
||||
std::map<uint32_t, RequestHandler> GetMemoryRequestHandlers();
|
||||
};
|
||||
} // namespace HiviewDFX
|
||||
} // namespace OHOS
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include "hiview_service_ability_stub.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
@ -35,7 +34,7 @@ DEFINE_LOG_TAG("HiViewSA-HiViewServiceAbilityStub");
|
||||
const std::string ASH_MEM_NAME = "HiviewLogLibrary SharedMemory";
|
||||
constexpr uint32_t ASH_MEM_SIZE = 107 * 5000; // 535k
|
||||
|
||||
const std::unordered_map<uint32_t, std::string> ALL_PERMISSION_MAP = {
|
||||
const std::map<uint32_t, std::string> ALL_PERMISSION_MAP = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_LIST),
|
||||
"ohos.permission.READ_HIVIEW_SYSTEM"},
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_COPY),
|
||||
@ -60,7 +59,7 @@ const std::unordered_map<uint32_t, std::string> ALL_PERMISSION_MAP = {
|
||||
"ohos.permission.WRITE_HIVIEW_SYSTEM"}
|
||||
};
|
||||
|
||||
const std::unordered_map<uint32_t, std::string> TRACE_PERMISSION_MAP = {
|
||||
const std::map<uint32_t, std::string> TRACE_PERMISSION_MAP = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_OPEN_SNAPSHOT_TRACE),
|
||||
"ohos.permission.DUMP"},
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_DUMP_SNAPSHOT_TRACE),
|
||||
@ -78,16 +77,16 @@ const std::unordered_map<uint32_t, std::string> TRACE_PERMISSION_MAP = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_GET_APP_TRACE), ""},
|
||||
};
|
||||
|
||||
const std::unordered_map<uint32_t, std::string> CPU_PERMISSION_MAP = {
|
||||
const std::map<uint32_t, std::string> CPU_PERMISSION_MAP = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_GET_SYSTEM_CPU_USAGE), ""}
|
||||
};
|
||||
|
||||
const std::unordered_map<uint32_t, std::string> MEMORY_PERMISSION_MAP = {
|
||||
const std::map<uint32_t, std::string> MEMORY_PERMISSION_MAP = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_SET_APPRESOURCE_LIMIT), ""},
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_GET_GRAPHIC_USAGE), ""}
|
||||
};
|
||||
|
||||
bool HasAccessPermission(uint32_t code, const std::unordered_map<uint32_t, std::string>& permissions)
|
||||
bool HasAccessPermission(uint32_t code, const std::map<uint32_t, std::string>& permissions)
|
||||
{
|
||||
using namespace Security::AccessToken;
|
||||
auto iter = permissions.find(code);
|
||||
@ -141,9 +140,9 @@ bool HiviewServiceAbilityStub::IsPermissionGranted(uint32_t code)
|
||||
HasAccessPermission(code, CPU_PERMISSION_MAP) || HasAccessPermission(code, MEMORY_PERMISSION_MAP);
|
||||
}
|
||||
|
||||
std::unordered_map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetRequestHandlers()
|
||||
std::map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetRequestHandlers()
|
||||
{
|
||||
static std::unordered_map<uint32_t, RequestHandler> requestHandlers = {
|
||||
static std::map<uint32_t, RequestHandler> requestHandlers = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_LIST),
|
||||
[this] (MessageParcel& data, MessageParcel& reply, MessageOption& option) {
|
||||
return this->HandleListRequest(data, reply, option);
|
||||
@ -168,9 +167,9 @@ std::unordered_map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetReques
|
||||
return requestHandlers;
|
||||
}
|
||||
|
||||
std::unordered_map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetTraceRequestHandlers()
|
||||
std::map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetTraceRequestHandlers()
|
||||
{
|
||||
static std::unordered_map<uint32_t, RequestHandler> requestHandlers = {
|
||||
static std::map<uint32_t, RequestHandler> requestHandlers = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_OPEN_SNAPSHOT_TRACE),
|
||||
[this] (MessageParcel& data, MessageParcel& reply, MessageOption& option) {
|
||||
return this->HandleOpenSnapshotTraceRequest(data, reply, option);
|
||||
@ -215,9 +214,9 @@ std::unordered_map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetTraceR
|
||||
return requestHandlers;
|
||||
}
|
||||
|
||||
std::unordered_map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetCpuRequestHandlers()
|
||||
std::map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetCpuRequestHandlers()
|
||||
{
|
||||
static std::unordered_map<uint32_t, RequestHandler> cpuRequestHandlers = {
|
||||
static std::map<uint32_t, RequestHandler> cpuRequestHandlers = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_GET_SYSTEM_CPU_USAGE),
|
||||
[this] (MessageParcel& data, MessageParcel& reply, MessageOption& option) {
|
||||
return HandleGetSysCpuUsageRequest(data, reply, option);
|
||||
@ -227,9 +226,9 @@ std::unordered_map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetCpuReq
|
||||
return cpuRequestHandlers;
|
||||
}
|
||||
|
||||
std::unordered_map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetMemoryRequestHandlers()
|
||||
std::map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetMemoryRequestHandlers()
|
||||
{
|
||||
static std::unordered_map<uint32_t, RequestHandler> memoryRequestHandlers = {
|
||||
static std::map<uint32_t, RequestHandler> memoryRequestHandlers = {
|
||||
{static_cast<uint32_t>(HiviewServiceInterfaceCode::HIVIEW_SERVICE_ID_SET_APPRESOURCE_LIMIT),
|
||||
[this] (MessageParcel& data, MessageParcel& reply, MessageOption& option) {
|
||||
return HandleSetAppResourceLimitRequest(data, reply, option);
|
||||
@ -246,7 +245,7 @@ std::unordered_map<uint32_t, RequestHandler> HiviewServiceAbilityStub::GetMemory
|
||||
|
||||
RequestHandler HiviewServiceAbilityStub::GetRequestHandler(uint32_t code)
|
||||
{
|
||||
std::vector<std::unordered_map<uint32_t, RequestHandler>> allHandlerMaps = {
|
||||
std::vector<std::map<uint32_t, RequestHandler>> allHandlerMaps = {
|
||||
GetRequestHandlers(),
|
||||
GetTraceRequestHandlers(),
|
||||
GetCpuRequestHandlers(),
|
||||
|
@ -30,24 +30,24 @@ namespace {
|
||||
DEFINE_LOG_TAG("HiView-EventPublish");
|
||||
constexpr int VALUE_MOD = 200000;
|
||||
constexpr int DELAY_TIME = 30;
|
||||
const std::string PATH_DIR = "/data/log/hiview/system_event_db/events/temp";
|
||||
const std::string SANDBOX_DIR = "/data/storage/el2/log";
|
||||
const std::string FILE_PREFIX = "/hiappevent_";
|
||||
const std::string FILE_SUFFIX = ".evt";
|
||||
const std::string DOMAIN_PROPERTY = "domain";
|
||||
const std::string NAME_PROPERTY = "name";
|
||||
const std::string EVENT_TYPE_PROPERTY = "eventType";
|
||||
const std::string PARAM_PROPERTY = "params";
|
||||
const std::string LOG_OVER_LIMIT = "log_over_limit";
|
||||
const std::string EXTERNAL_LOG = "external_log";
|
||||
const std::string PID = "pid";
|
||||
const std::string IS_BUSINESS_JANK = "is_business_jank";
|
||||
constexpr const char* const PATH_DIR = "/data/log/hiview/system_event_db/events/temp";
|
||||
constexpr const char* const SANDBOX_DIR = "/data/storage/el2/log";
|
||||
constexpr const char* const FILE_PREFIX = "/hiappevent_";
|
||||
constexpr const char* const FILE_SUFFIX = ".evt";
|
||||
constexpr const char* const DOMAIN_PROPERTY = "domain";
|
||||
constexpr const char* const NAME_PROPERTY = "name";
|
||||
constexpr const char* const EVENT_TYPE_PROPERTY = "eventType";
|
||||
constexpr const char* const PARAM_PROPERTY = "params";
|
||||
constexpr const char* const LOG_OVER_LIMIT = "log_over_limit";
|
||||
constexpr const char* const EXTERNAL_LOG = "external_log";
|
||||
constexpr const char* const PID = "pid";
|
||||
constexpr const char* const IS_BUSINESS_JANK = "is_business_jank";
|
||||
constexpr uint64_t MAX_FILE_SIZE = 5 * 1024 * 1024; // 5M
|
||||
constexpr uint64_t WATCHDOG_MAX_FILE_SIZE = 10 * 1024 * 1024; // 10M
|
||||
constexpr uint64_t RESOURCE_OVERLIMIT_MAX_FILE_SIZE = 2048ull * 1024 * 1024; // 2G
|
||||
const std::string XATTR_NAME = "user.appevent";
|
||||
constexpr const char* const XATTR_NAME = "user.appevent";
|
||||
constexpr uint64_t BIT_MASK = 1;
|
||||
const std::unordered_map<std::string, uint8_t> OS_EVENT_POS_INFOS = {
|
||||
const std::map<std::string, uint8_t> OS_EVENT_POS_INFOS = {
|
||||
{ EVENT_APP_CRASH, 0 },
|
||||
{ EVENT_APP_FREEZE, 1 },
|
||||
{ EVENT_APP_LAUNCH, 2 },
|
||||
@ -400,8 +400,8 @@ void EventPublish::PushEvent(int32_t uid, const std::string& eventName, HiSysEve
|
||||
return;
|
||||
}
|
||||
eventJson[PARAM_PROPERTY] = params;
|
||||
const std::unordered_set<std::string> immediateEvents = {"APP_CRASH", "APP_FREEZE", "ADDRESS_SANITIZER",
|
||||
"APP_LAUNCH", "CPU_USAGE_HIGH", EVENT_MAIN_THREAD_JANK};
|
||||
const std::set<std::string> immediateEvents = {EVENT_APP_CRASH, EVENT_APP_FREEZE, EVENT_ADDRESS_SANITIZER,
|
||||
EVENT_APP_LAUNCH, EVENT_CPU_USAGE_HIGH, EVENT_MAIN_THREAD_JANK};
|
||||
if (immediateEvents.find(eventName) != immediateEvents.end()) {
|
||||
SaveEventAndLogToSandBox(uid, eventName, bundleName, eventJson);
|
||||
} else if (eventName == EVENT_RESOURCE_OVERLIMIT) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-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
|
||||
@ -27,18 +27,18 @@
|
||||
namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
namespace HiAppEvent {
|
||||
const std::string DOMAIN_OS = "OS";
|
||||
const std::string EVENT_APP_CRASH = "APP_CRASH";
|
||||
const std::string EVENT_APP_FREEZE = "APP_FREEZE";
|
||||
const std::string EVENT_APP_LAUNCH = "APP_LAUNCH";
|
||||
const std::string EVENT_SCROLL_JANK = "SCROLL_JANK";
|
||||
const std::string EVENT_CPU_USAGE_HIGH = "CPU_USAGE_HIGH";
|
||||
const std::string EVENT_BATTERY_USAGE = "BATTERY_USAGE";
|
||||
const std::string EVENT_RESOURCE_OVERLIMIT = "RESOURCE_OVERLIMIT";
|
||||
const std::string EVENT_ADDRESS_SANITIZER = "ADDRESS_SANITIZER";
|
||||
const std::string EVENT_MAIN_THREAD_JANK = "MAIN_THREAD_JANK";
|
||||
const std::string EVENT_APP_START = "APP_START";
|
||||
} // namespace HiAppEvent
|
||||
constexpr const char* const DOMAIN_OS = "OS";
|
||||
constexpr const char* const EVENT_APP_CRASH = "APP_CRASH";
|
||||
constexpr const char* const EVENT_APP_FREEZE = "APP_FREEZE";
|
||||
constexpr const char* const EVENT_APP_LAUNCH = "APP_LAUNCH";
|
||||
constexpr const char* const EVENT_SCROLL_JANK = "SCROLL_JANK";
|
||||
constexpr const char* const EVENT_CPU_USAGE_HIGH = "CPU_USAGE_HIGH";
|
||||
constexpr const char* const EVENT_BATTERY_USAGE = "BATTERY_USAGE";
|
||||
constexpr const char* const EVENT_RESOURCE_OVERLIMIT = "RESOURCE_OVERLIMIT";
|
||||
constexpr const char* const EVENT_ADDRESS_SANITIZER = "ADDRESS_SANITIZER";
|
||||
constexpr const char* const EVENT_MAIN_THREAD_JANK = "MAIN_THREAD_JANK";
|
||||
constexpr const char* const EVENT_APP_START = "APP_START";
|
||||
}
|
||||
class EventPublish : public OHOS::DelayedRefSingleton<EventPublish> {
|
||||
public:
|
||||
EventPublish() {};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-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
|
||||
@ -28,7 +28,7 @@ const char KEY_PAGE_SIZE[] = "PageSize";
|
||||
const char KEY_MAX_SIZE[] = "MaxSize";
|
||||
const char KEY_MAX_FILE_NUM[] = "MaxFileNum";
|
||||
const char KEY_MAX_FILE_SIZE[] = "MaxFileSize";
|
||||
const std::unordered_map<std::string, int> EVENT_TYPE_MAP = {
|
||||
const std::map<std::string, int> EVENT_TYPE_MAP = {
|
||||
{"FAULT", 1}, {"STATISTIC", 2}, {"SECURITY", 3}, {"BEHAVIOR", 4}
|
||||
};
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
#include "doc_query.h"
|
||||
|
||||
#include <unordered_set>
|
||||
#include <set>
|
||||
|
||||
#include "decoded/decoded_event.h"
|
||||
#include "hiview_logger.h"
|
||||
@ -40,7 +40,7 @@ void DocQuery::And(const Cond& cond)
|
||||
|
||||
bool DocQuery::IsInnerCond(const Cond& cond) const
|
||||
{
|
||||
const std::unordered_set<std::string> innerFields = {
|
||||
const std::set<std::string> innerFields = {
|
||||
EventCol::SEQ, EventCol::TS, EventCol::TZ,
|
||||
EventCol::PID, EventCol::TID, EventCol::UID,
|
||||
};
|
||||
|
@ -16,13 +16,13 @@
|
||||
#include "focused_event_util.h"
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
namespace FocusedEventUtil {
|
||||
namespace {
|
||||
const std::unordered_map<std::string, std::list<std::string>> FOCUSED_EVENT_MAP {
|
||||
const std::map<std::string, std::list<std::string>> FOCUSED_EVENT_MAP {
|
||||
{"HMOS_SVC_BROKER", {"CONTAINER_LIFECYCLE_EVENT"}},
|
||||
};
|
||||
}
|
||||
|
@ -21,12 +21,13 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
const std::string CONFIG_TYPE = "HIVIEWPARA";
|
||||
const std::string CONFIG_UPDATED_ACTION = "usual.event.DUE_SA_CFG_UPDATED";
|
||||
const std::string CFG_PATH = "/data/service/el1/public/update/param_service/install/system/etc/HIVIEWPARA/DEFAULT/";
|
||||
const std::string PUBKEY_PATH = "/system/etc/hiview/hwkey_param_upgrade_hiviewdfx_v1.pem";
|
||||
const std::string LOCAL_CFG_PATH = "/system/etc/hiview/";
|
||||
const std::string CLOUD_CFG_PATH = "/data/system/hiview/";
|
||||
constexpr const char* const CONFIG_TYPE = "HIVIEWPARA";
|
||||
constexpr const char* const CONFIG_UPDATED_ACTION = "usual.event.DUE_SA_CFG_UPDATED";
|
||||
constexpr const char* const CFG_PATH =
|
||||
"/data/service/el1/public/update/param_service/install/system/etc/HIVIEWPARA/DEFAULT/";
|
||||
constexpr const char* const PUBKEY_PATH = "/system/etc/hiview/hwkey_param_upgrade_hiviewdfx_v1.pem";
|
||||
constexpr const char* const LOCAL_CFG_PATH = "/system/etc/hiview/";
|
||||
constexpr const char* const CLOUD_CFG_PATH = "/data/system/hiview/";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -74,7 +74,7 @@ bool ParamManager::CopyConfigFiles(const std::vector<std::string>& files)
|
||||
{
|
||||
for (const std::string& file : files) {
|
||||
std::string dstFile(file);
|
||||
dstFile.replace(0, CFG_PATH.length(), CLOUD_CFG_PATH);
|
||||
dstFile.replace(0, strlen(CFG_PATH), CLOUD_CFG_PATH);
|
||||
if (!CopyFile(file, dstFile)) {
|
||||
HIVIEW_LOGI("copy file failed: %{public}s", file.c_str());
|
||||
}
|
||||
@ -91,7 +91,7 @@ void ParamManager::GetValidFiles(std::vector<std::string>& validFiles)
|
||||
if (IsFileNeedIgnore(fileName)) {
|
||||
continue;
|
||||
}
|
||||
std::string relativedPath(file.substr(CFG_PATH.length()));
|
||||
std::string relativedPath(file.substr(strlen(CFG_PATH)));
|
||||
if (!ParamReader::VerifyParamFile(relativedPath)) {
|
||||
HIVIEW_LOGE("verify file failed: %{public}s", fileName.c_str());
|
||||
validFiles.clear();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-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
|
||||
@ -34,15 +34,15 @@ namespace {
|
||||
|
||||
bool ParamReader::VerifyCertFile()
|
||||
{
|
||||
std::string certFile = CFG_PATH + "CERT.ENC";
|
||||
std::string verifyFile = CFG_PATH + "CERT.SF";
|
||||
std::string certFile = std::string(CFG_PATH) + "CERT.ENC";
|
||||
std::string verifyFile = std::string(CFG_PATH) + "CERT.SF";
|
||||
if (!LogSignTools::VerifyFileSign(PUBKEY_PATH, certFile, verifyFile)) {
|
||||
HIVIEW_LOGE("verify failed %{public}s,%{public}s, %{public}s", PUBKEY_PATH.c_str(),
|
||||
HIVIEW_LOGE("verify failed %{public}s,%{public}s, %{public}s", PUBKEY_PATH,
|
||||
certFile.c_str(), verifyFile.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string manifestFile = CFG_PATH + "MANIFEST.MF";
|
||||
std::string manifestFile = std::string(CFG_PATH) + "MANIFEST.MF";
|
||||
std::ifstream file(verifyFile);
|
||||
if (!file.good()) {
|
||||
HIVIEW_LOGE("Verify is not good");
|
||||
@ -72,7 +72,7 @@ bool ParamReader::VerifyCertFile()
|
||||
|
||||
bool ParamReader::VerifyParamFile(const std::string &filePathStr)
|
||||
{
|
||||
std::string manifestFile = CFG_PATH + "MANIFEST.MF";
|
||||
std::string manifestFile = std::string(CFG_PATH) + "MANIFEST.MF";
|
||||
std::ifstream file(manifestFile);
|
||||
if (!file.good()) {
|
||||
HIVIEW_LOGE("manifestFile is not good");
|
||||
|
@ -30,6 +30,7 @@ DEFINE_LOG_TAG("UCollectUtil-CommonUtil");
|
||||
const std::string EXPORT_FILE_REGEX = "[0-9]{14}(.*)";
|
||||
const std::string UNDERLINE = "_";
|
||||
}
|
||||
|
||||
template <typename T> bool CommonUtil::StrToNum(const std::string &sString, T &tX)
|
||||
{
|
||||
std::istringstream iStream(sString);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-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
|
||||
@ -16,7 +16,6 @@
|
||||
#include "io_collector_impl.h"
|
||||
|
||||
#include <regex>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <securec.h>
|
||||
@ -501,9 +500,9 @@ void IoCollectorImpl::GetProcIoStats(std::vector<ProcessIoStats>& allProcIoStats
|
||||
|
||||
void IoCollectorImpl::CalculateAllProcIoStats(uint64_t period, bool isUpdate)
|
||||
{
|
||||
DIR *dir = opendir(PROC.c_str());
|
||||
DIR *dir = opendir(PROC);
|
||||
if (dir == nullptr) {
|
||||
HIVIEW_LOGE("open dir=%{public}s failed.", PROC.c_str());
|
||||
HIVIEW_LOGE("open dir=%{public}s failed.", PROC);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-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
|
||||
@ -18,7 +18,6 @@
|
||||
#include <csignal>
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <regex>
|
||||
@ -65,15 +64,15 @@ static std::string GetSavePath(const std::string& preFix, const std::string& ext
|
||||
std::lock_guard<std::mutex> lock(g_memMutex); // lock when get save path
|
||||
if ((!FileUtil::FileExists(MEMINFO_SAVE_DIR)) &&
|
||||
(!FileUtil::ForceCreateDirectory(MEMINFO_SAVE_DIR, FileUtil::FILE_PERM_755))) {
|
||||
HIVIEW_LOGE("create %{public}s dir failed.", MEMINFO_SAVE_DIR.c_str());
|
||||
HIVIEW_LOGE("create %{public}s dir failed.", MEMINFO_SAVE_DIR);
|
||||
return "";
|
||||
}
|
||||
std::string timeStamp = GetCurrTimestamp();
|
||||
std::string savePath = MEMINFO_SAVE_DIR + "/" + preFix + timeStamp + ext;
|
||||
std::string savePath = std::string(MEMINFO_SAVE_DIR) + "/" + preFix + timeStamp + ext;
|
||||
int suffix = 0;
|
||||
while (FileUtil::FileExists(savePath)) {
|
||||
std::stringstream ss;
|
||||
ss << MEMINFO_SAVE_DIR << "/" << preFix << timeStamp << "_" << suffix << ext;
|
||||
ss << std::string(MEMINFO_SAVE_DIR) << "/" << preFix << timeStamp << "_" << suffix << ext;
|
||||
suffix++;
|
||||
savePath = ss.str();
|
||||
}
|
||||
@ -88,22 +87,18 @@ static std::string GetSavePath(const std::string& preFix, const std::string& ext
|
||||
|
||||
static bool WriteProcessMemoryToFile(std::string& filePath, const std::vector<ProcessMemory>& processMems)
|
||||
{
|
||||
std::ofstream file;
|
||||
file.open(filePath.c_str(), std::ios::out | std::ios::trunc);
|
||||
if (!file.is_open()) {
|
||||
HIVIEW_LOGE("open %{public}s failed.", filePath.c_str());
|
||||
FILE* fp = fopen(filePath.c_str(), "w");
|
||||
if (fp == nullptr) {
|
||||
HIVIEW_LOGE("open %{public}s failed.", FileUtil::ExtractFileName(filePath).c_str());
|
||||
return false;
|
||||
}
|
||||
(void)fprintf(fp, "pid\tpname\trss(KB)\tpss(KB)\tswapPss(KB)\tadj\tprocState\n");
|
||||
|
||||
file << "pid" << '\t' << "pname" << '\t' << "rss(KB)" << '\t' <<
|
||||
"pss(KB)" << '\t' << "swapPss(KB)"<< '\t' << "adj" << '\t' <<
|
||||
"procState" << std::endl;
|
||||
for (auto& processMem : processMems) {
|
||||
file << processMem.pid << '\t' << processMem.name << '\t' << processMem.rss << '\t' <<
|
||||
processMem.pss << '\t' << processMem.swapPss << '\t' << processMem.adj << '\t' <<
|
||||
processMem.procState << std::endl;
|
||||
(void)fprintf(fp, "%d\t%s\t%d\t%d\t%d\t%d\t%d\n", processMem.pid, processMem.name.c_str(), processMem.rss,
|
||||
processMem.pss, processMem.swapPss, processMem.adj, processMem.procState);
|
||||
}
|
||||
file.close();
|
||||
(void)fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -244,7 +239,7 @@ static CollectResult<std::string> CollectRawInfo(const std::string& filePath, co
|
||||
|
||||
static void SetValueOfProcessMemory(ProcessMemory& processMemory, const std::string& attrName, int32_t value)
|
||||
{
|
||||
static std::unordered_map<std::string, std::function<void(ProcessMemory&, int32_t)>> assignFuncMap = {
|
||||
static std::map<std::string, std::function<void(ProcessMemory&, int32_t)>> assignFuncMap = {
|
||||
{"Rss", [] (ProcessMemory& memory, int32_t value) {
|
||||
memory.rss = value;
|
||||
}},
|
||||
@ -332,7 +327,7 @@ static bool InitProcessMemory(int32_t pid, ProcessMemory& memory)
|
||||
|
||||
static void SetValueOfSysMemory(SysMemory& sysMemory, const std::string& attrName, int32_t value)
|
||||
{
|
||||
static std::unordered_map<std::string, std::function<void(SysMemory&, int32_t)>> assignFuncMap = {
|
||||
static std::map<std::string, std::function<void(SysMemory&, int32_t)>> assignFuncMap = {
|
||||
{"MemTotal", [] (SysMemory& memory, int32_t value) {
|
||||
memory.memTotal = value;
|
||||
}},
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "process_collector_impl.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <fstream>
|
||||
|
||||
#include "common_util.h"
|
||||
#include "file_util.h"
|
||||
@ -115,17 +114,16 @@ CollectResult<std::string> ProcessCollectorImpl::ExportMemCgProcesses()
|
||||
filePath = CommonUtil::CreateExportFile(PROCESS_COLLECTOT_DIR, MAX_FILE_NUM, PREFIX, SUFFIX);
|
||||
}
|
||||
|
||||
std::ofstream file;
|
||||
file.open(filePath.c_str(), std::ios::out | std::ios::trunc);
|
||||
if (!file.is_open()) {
|
||||
FILE* fp = fopen(filePath.c_str(), "w");
|
||||
if (fp == nullptr) {
|
||||
HIVIEW_LOGW("open %{public}s failed.", FileUtil::ExtractFileName(filePath).c_str());
|
||||
result.retCode = UcError::WRITE_FAILED;
|
||||
return result;
|
||||
}
|
||||
for (const auto& proc : memCgProcsResult.data) {
|
||||
file << proc << std::endl;
|
||||
(void)fprintf(fp, "%d\n", proc);
|
||||
}
|
||||
file.close();
|
||||
(void)fclose(fp);
|
||||
|
||||
result.data = filePath;
|
||||
result.retCode = UcError::SUCCESS;
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "thermal_collector_impl.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
#include "common_util.h"
|
||||
#include "file_util.h"
|
||||
@ -55,7 +55,7 @@ int32_t GetThermalValue(const std::string& thermalZone)
|
||||
|
||||
std::string GetZoneTypeStr(ThermalZone thermalZone)
|
||||
{
|
||||
const std::unordered_map<ThermalZone, std::string> thermalZoneMap = {
|
||||
const std::map<ThermalZone, std::string> thermalZoneMap = {
|
||||
{SHELL_FRONT, "shell_front"},
|
||||
{SHELL_FRAME, "shell_frame"},
|
||||
{SHELL_BACK, "shell_back"},
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <cinttypes>
|
||||
#include <ctime>
|
||||
#include <sys/stat.h>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "app_caller_event.h"
|
||||
@ -50,7 +50,7 @@ int64_t GetActualReliabilitySize()
|
||||
return Parameter::IsLaboratoryMode() ? RELIABILITY_SIZE * 5 : RELIABILITY_SIZE; // 5 : laboratory largen 5 times
|
||||
}
|
||||
|
||||
const std::unordered_map<UCollect::TraceCaller, std::pair<std::string, int64_t>> TRACE_QUOTA = {
|
||||
const std::map<UCollect::TraceCaller, std::pair<std::string, int64_t>> TRACE_QUOTA = {
|
||||
{UCollect::TraceCaller::XPERF, {"xperf", XPERF_SIZE}},
|
||||
{UCollect::TraceCaller::XPOWER, {"xpower", XPOWER_SIZE}},
|
||||
{UCollect::TraceCaller::RELIABILITY, {"reliability", GetActualReliabilitySize()}},
|
||||
|
@ -109,7 +109,7 @@ int CpuDecorator::GetCollectPid()
|
||||
void CpuDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-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
|
||||
@ -13,13 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "decorator.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
namespace UCollectUtil {
|
||||
const std::string UC_STAT_LOG_PATH = "/data/log/hiview/unified_collection/ucollection_stat_detail.log";
|
||||
const std::string UC_SEPARATOR = "::";
|
||||
|
||||
void StatInfoWrapper::UpdateStatInfo(uint64_t startTime, uint64_t endTime, const std::string& funcName, bool isCallSucc)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
@ -59,20 +60,19 @@ void StatInfoWrapper::ResetStatInfo()
|
||||
statInfos_.clear();
|
||||
}
|
||||
|
||||
void UCDecorator::WriteLinesToFile(const std::vector<std::string>& stats, bool addBlankLine)
|
||||
void UCDecorator::WriteLinesToFile(const std::list<std::string>& stats, bool addBlankLine)
|
||||
{
|
||||
std::ofstream statFilesStream;
|
||||
statFilesStream.open(UC_STAT_LOG_PATH, std::ios::app);
|
||||
if (!statFilesStream.is_open()) {
|
||||
FILE* fp = fopen(UC_STAT_LOG_PATH.c_str(), "a");
|
||||
if (fp == nullptr) {
|
||||
return;
|
||||
}
|
||||
for (const auto& record : stats) {
|
||||
statFilesStream << record << std::endl;
|
||||
(void)fprintf(fp, "%s\n", record.c_str());
|
||||
}
|
||||
if (addBlankLine) {
|
||||
statFilesStream << std::endl; // write a blank line to separate content
|
||||
(void)fprintf(fp, "\n"); // write a blank line to separate content
|
||||
}
|
||||
statFilesStream.close();
|
||||
(void)fclose(fp);
|
||||
}
|
||||
} // namespace UCollectUtil
|
||||
} // namespace HiviewDFX
|
||||
|
@ -35,7 +35,7 @@ CollectResult<SysGpuLoad> GpuDecorator::CollectSysGpuLoad()
|
||||
void GpuDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ CollectResult<int32_t> GraphicMemoryDecorator::GetGraphicUsage(int32_t pid, Grap
|
||||
void GraphicMemoryDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ CollectResult<bool> HiebpfDecorator::StopHiebpf()
|
||||
void HiebpfDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ CollectResult<std::string> HilogDecorator::CollectLastLog(uint32_t pid, uint32_t
|
||||
void HilogDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-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
|
||||
@ -16,10 +16,10 @@
|
||||
#ifndef HIVIEW_FRAMEWORK_NATIVE_UNIFIED_COLLECTION_DECORATOR_H
|
||||
#define HIVIEW_FRAMEWORK_NATIVE_UNIFIED_COLLECTION_DECORATOR_H
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "collect_result.h"
|
||||
#include "time_util.h"
|
||||
@ -27,8 +27,8 @@
|
||||
namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
namespace UCollectUtil {
|
||||
const std::string UC_STAT_LOG_PATH = "/data/log/hiview/unified_collection/ucollection_stat_detail.log";
|
||||
const std::string UC_SEPARATOR = "::";
|
||||
extern const std::string UC_STAT_LOG_PATH;
|
||||
extern const std::string UC_SEPARATOR;
|
||||
|
||||
struct StatInfo {
|
||||
std::string name;
|
||||
@ -83,7 +83,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
static void WriteLinesToFile(const std::vector<std::string>& stats, bool addBlankLine);
|
||||
static void WriteLinesToFile(const std::list<std::string>& stats, bool addBlankLine);
|
||||
};
|
||||
} // namespace UCollectUtil
|
||||
} // namespace HiviewDFX
|
||||
|
@ -32,7 +32,7 @@ struct TraceStatItem {
|
||||
uint32_t latency = 0;
|
||||
};
|
||||
|
||||
const std::unordered_map<UCollect::TraceCaller, std::string> CallerMap {
|
||||
const std::map<UCollect::TraceCaller, std::string> CallerMap {
|
||||
{UCollect::RELIABILITY, "RELIABILITY"},
|
||||
{UCollect::XPERF, "XPERF"},
|
||||
{UCollect::XPOWER, "XPOWER"},
|
||||
|
@ -85,7 +85,7 @@ CollectResult<std::string> IoDecorator::ExportSysIoStats()
|
||||
void IoDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ int MemProfilerDecorator::Start(int fd, ProfilerType type, std::string processNa
|
||||
void MemProfilerDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ CollectResult<uint32_t> MemoryDecorator::CollectDdrFreq()
|
||||
void MemoryDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ CollectResult<NetworkRate> NetworkDecorator::CollectRate()
|
||||
void NetworkDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ void PerfDecorator::SetReport(bool enable)
|
||||
void PerfDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ CollectResult<std::string> ProcessDecorator::ExportMemCgProcesses()
|
||||
void ProcessDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ CollectResult<uint32_t> ThermalDecorator::CollectThermaLevel()
|
||||
void ThermalDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -63,17 +63,17 @@ void TraceDecorator::SaveStatSpecialInfo()
|
||||
{
|
||||
WriteLinesToFile({""}, false); // a blank line after common stat info
|
||||
std::map<std::string, TraceStatInfo> traceStatInfo = traceStatWrapper_.GetTraceStatInfo();
|
||||
std::vector<std::string> traceFormattedStatInfo = {UC_HITRACE_API_STAT_TITLE, UC_HITRACE_API_STAT_ITEM};
|
||||
std::list<std::string> traceFormattedStatInfo = {UC_HITRACE_API_STAT_TITLE, UC_HITRACE_API_STAT_ITEM};
|
||||
for (const auto& record : traceStatInfo) {
|
||||
traceFormattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
WriteLinesToFile(traceFormattedStatInfo, true);
|
||||
|
||||
std::vector<std::string> compressRatio = {UC_HITRACE_COMPRESS_RATIO, std::to_string(TRACE_COMPRESS_RATIO)};
|
||||
std::list<std::string> compressRatio = {UC_HITRACE_COMPRESS_RATIO, std::to_string(TRACE_COMPRESS_RATIO)};
|
||||
WriteLinesToFile(compressRatio, true);
|
||||
|
||||
std::map<std::string, std::vector<std::string>> traceTrafficInfo = traceStatWrapper_.GetTrafficStatInfo();
|
||||
std::vector<std::string> trafficFormattedInfo = {UC_HITRACE_TRAFFIC_STAT_TITLE, UC_HITRACE_TRAFFIC_STAT_ITEM};
|
||||
std::list<std::string> trafficFormattedInfo = {UC_HITRACE_TRAFFIC_STAT_TITLE, UC_HITRACE_TRAFFIC_STAT_ITEM};
|
||||
for (const auto& record : traceTrafficInfo) {
|
||||
trafficFormattedInfo.insert(trafficFormattedInfo.end(), record.second.begin(), record.second.end());
|
||||
}
|
||||
@ -83,7 +83,7 @@ void TraceDecorator::SaveStatSpecialInfo()
|
||||
void TraceDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
namespace UCollectUtil {
|
||||
DEFINE_LOG_TAG("UCollectUtil-UCStat");
|
||||
const std::string UC_STAT_DATE = "Date:";
|
||||
const std::string UC_API_STAT_TITLE = "API statistics:";
|
||||
const std::string UC_API_STAT_ITEM =
|
||||
constexpr const char* const UC_STAT_DATE = "Date:";
|
||||
constexpr const char* const UC_API_STAT_TITLE = "API statistics:";
|
||||
constexpr const char* const UC_API_STAT_ITEM =
|
||||
"API TotalCall FailCall AvgLatency(us) MaxLatency(us) TotalTimeSpent(us)";
|
||||
|
||||
namespace {
|
||||
|
@ -42,7 +42,7 @@ CollectResult<std::string> WmDecorator::ExportGpuMemory()
|
||||
void WmDecorator::SaveStatCommonInfo()
|
||||
{
|
||||
std::map<std::string, StatInfo> statInfo = statInfoWrapper_.GetStatInfo();
|
||||
std::vector<std::string> formattedStatInfo;
|
||||
std::list<std::string> formattedStatInfo;
|
||||
for (const auto& record : statInfo) {
|
||||
formattedStatInfo.push_back(record.second.ToString());
|
||||
}
|
||||
|
@ -14,8 +14,6 @@
|
||||
*/
|
||||
#include "process_status.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "common_utils.h"
|
||||
#include "file_util.h"
|
||||
#include "hiview_logger.h"
|
||||
|
@ -21,16 +21,16 @@
|
||||
namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
namespace UCollectUtil {
|
||||
const std::string PROC = "/proc/";
|
||||
const std::string IO = "/io";
|
||||
const std::string SMAPS_ROLLUP = "/smaps_rollup";
|
||||
const std::string STATM = "/statm";
|
||||
const std::string MEM_INFO = "/proc/meminfo";
|
||||
const std::string GPU_CUR_FREQ = "/sys/class/devfreq/gpufreq/cur_freq";
|
||||
const std::string GPU_MAX_FREQ = "/sys/class/devfreq/gpufreq/max_freq";
|
||||
const std::string GPU_MIN_FREQ = "/sys/class/devfreq/gpufreq/min_freq";
|
||||
const std::string GPU_LOAD = "/sys/class/devfreq/gpufreq/gpu_scene_aware/utilisation";
|
||||
const std::string MEMINFO_SAVE_DIR = "/data/log/hiview/unified_collection/memory";
|
||||
constexpr const char* const PROC = "/proc/";
|
||||
constexpr const char* const IO = "/io";
|
||||
constexpr const char* const SMAPS_ROLLUP = "/smaps_rollup";
|
||||
constexpr const char* const STATM = "/statm";
|
||||
constexpr const char* const MEM_INFO = "/proc/meminfo";
|
||||
constexpr const char* const GPU_CUR_FREQ = "/sys/class/devfreq/gpufreq/cur_freq";
|
||||
constexpr const char* const GPU_MAX_FREQ = "/sys/class/devfreq/gpufreq/max_freq";
|
||||
constexpr const char* const GPU_MIN_FREQ = "/sys/class/devfreq/gpufreq/min_freq";
|
||||
constexpr const char* const GPU_LOAD = "/sys/class/devfreq/gpufreq/gpu_scene_aware/utilisation";
|
||||
constexpr const char* const MEMINFO_SAVE_DIR = "/data/log/hiview/unified_collection/memory";
|
||||
const static int VSS_BIT = 4;
|
||||
|
||||
class CommonUtil {
|
||||
|
@ -64,7 +64,7 @@
|
||||
"OHOS::HiviewDFX::UCollectUtil::TraceDecorator::SaveStatCommonInfo()";
|
||||
"OHOS::HiviewDFX::UCollectUtil::WmDecorator::SaveStatCommonInfo()";
|
||||
"OHOS::HiviewDFX::UCollectUtil::TraceDecorator::SaveStatSpecialInfo()";
|
||||
"OHOS::HiviewDFX::UCollectUtil::UCDecorator::WriteLinesToFile(std::__h::vector<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, std::__h::allocator<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>> const&, bool)";
|
||||
"OHOS::HiviewDFX::UCollectUtil::UCDecorator::WriteLinesToFile(std::__h::list<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>, std::__h::allocator<std::__h::basic_string<char, std::__h::char_traits<char>, std::__h::allocator<char>>>> const&, bool)";
|
||||
};
|
||||
local:
|
||||
*;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-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
|
||||
@ -15,6 +15,8 @@
|
||||
|
||||
#include "hiview_napi_util.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "hiview_err_code.h"
|
||||
#include "hiview_logger.h"
|
||||
#include "ipc_skeleton.h"
|
||||
@ -73,7 +75,7 @@ void HiviewNapiUtil::CreateErrorByRet(napi_env env, const int32_t retCode, napi_
|
||||
std::pair<int32_t, std::string> HiviewNapiUtil::GetErrorDetailByRet(napi_env env, const int32_t retCode)
|
||||
{
|
||||
HIVIEW_LOGI("origin result code is %{public}d.", retCode);
|
||||
const std::unordered_map<int32_t, std::pair<int32_t, std::string>> errMap = {
|
||||
const std::map<int32_t, std::pair<int32_t, std::string>> errMap = {
|
||||
{HiviewNapiErrCode::ERR_PERMISSION_CHECK, {HiviewNapiErrCode::ERR_PERMISSION_CHECK,
|
||||
"Permission denied. The app does not have the necessary permissions."}},
|
||||
{HiviewNapiErrCode::ERR_INNER_INVALID_LOGTYPE,
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
#include "area_policy.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
#include "hiview_logger.h"
|
||||
#include "parameter_ex.h"
|
||||
@ -24,7 +24,7 @@ namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
DEFINE_LOG_TAG("AreaPolicy");
|
||||
namespace {
|
||||
const std::unordered_map<std::string, uint8_t> EVENT_LEVELS = {
|
||||
const std::map<std::string, uint8_t> EVENT_LEVELS = {
|
||||
{"DEBUG", 1}, {"INFO", 2}, {"MINOR", 3}, {"MAJOR", 4}, {"CRITICAL", 5}
|
||||
};
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ bool DailyConfig::ParseCommonThreshold(const cJSON* config)
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::unordered_map<std::string, int32_t> configMap = {
|
||||
const std::map<std::string, int32_t> configMap = {
|
||||
{"FAULT", TYPE_FAULT}, {"STATISTIC", TYPE_STATISTIC},
|
||||
{"SECURITY", TYPE_SECURITY}, {"BEHAVIOR", TYPE_BEHAVIOR}
|
||||
};
|
||||
|
@ -15,6 +15,7 @@
|
||||
#ifndef HIVIEW_PLUGINS_SYS_EVENT_SOURCE_CONTROL_CONFIG_INCLUDE_DAILY_CONFIG_H
|
||||
#define HIVIEW_PLUGINS_SYS_EVENT_SOURCE_CONTROL_CONFIG_INCLUDE_DAILY_CONFIG_H
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "cjson_util.h"
|
||||
@ -47,7 +48,7 @@ private:
|
||||
|
||||
bool isValid_ = false;
|
||||
/* <type, threshold> */
|
||||
std::unordered_map<int32_t, int32_t> commonThresholds_;
|
||||
std::map<int32_t, int32_t> commonThresholds_;
|
||||
/* <<domain, name>, threshold> */
|
||||
std::unordered_map<std::pair<std::string, std::string>, int32_t, EventPairHash> customThresholds_;
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ using namespace OHOS::HiviewDFX::UCollectUtil;
|
||||
|
||||
ProcessState GetProcessState(int32_t state)
|
||||
{
|
||||
const std::unordered_map<int32_t, ProcessState> renderStates = {
|
||||
const std::map<int32_t, ProcessState> renderStates = {
|
||||
{0, FOREGROUND},
|
||||
{1, BACKGROUND},
|
||||
};
|
||||
|
@ -71,21 +71,13 @@ namespace FoldEventId {
|
||||
namespace AppEventSpace {
|
||||
const std::string FOREGROUND_EVENT_NAME = "APP_FOREGROUND";
|
||||
const std::string BACKGROUND_EVENT_NAME = "APP_BACKGROUND";
|
||||
const std::string KEY_OF_PROCESS_NAME = "PROCESS_NAME";
|
||||
const std::string KEY_OF_VERSION_NAME = "VERSION_NAME";
|
||||
const std::string KEY_OF_CALLER_BUNDLENAME = "CALLER_BUNDLENAME";
|
||||
const std::string KEY_OF_BUNDLE_TYPE = "BUNDLE_TYPE";
|
||||
const std::string KEY_OF_VERSION_CODE = "VERSION_CODE";
|
||||
const std::string KEY_OF_BUNDLE_NAME = "BUNDLE_NAME";
|
||||
const std::string KEY_OF_APP_PID = "APP_PID";
|
||||
const std::string KEY_OF_PROCESS_TYPE = "PROCESS_TYPE";
|
||||
}
|
||||
|
||||
namespace FoldStateChangeEventSpace {
|
||||
const std::string EVENT_NAME = "NOTIFY_FOLD_STATE_CHANGE";
|
||||
const std::string KEY_OF_CURRENT_STATUS = "CURRENT_FOLD_STATUS";
|
||||
const std::string KEY_OF_NEXT_STATUS = "NEXT_FOLD_STATUS";
|
||||
const std::string KEY_OF_SENSOR_POSTURE = "SENSOR_POSTURE";
|
||||
}
|
||||
|
||||
namespace VhModeChangeEventSpace {
|
||||
|
Loading…
Reference in New Issue
Block a user