告警清理

Signed-off-by:wenlong12 <wenlong12@huawei.com>

Signed-off-by: wenlong12 <wenlong12@huawei.com>
This commit is contained in:
wenlong12 2024-05-09 15:14:03 +08:00
parent 5f610d212d
commit 50c6778150
9 changed files with 151 additions and 152 deletions

View File

@ -42,46 +42,46 @@ using dw_encode_t = unsigned char; // 4 bits + 4 bits
// Table 10-5. DWARF Exception Header value format // Table 10-5. DWARF Exception Header value format
enum DW_EH_PE_VF { enum DW_EH_PE_VF {
DW_EH_PE_ABSPTR = 0x00, // a literal pointer whose size is determined by the architecture. DW_EH_PE_absptr = 0x00, // a literal pointer whose size is determined by the architecture.
DW_EH_PE_ULEB128 = 0x01, // Unsigned value is encoded using the Little Endian Base 128 (LEB128) DW_EH_PE_uleb128 = 0x01, // Unsigned value is encoded using the Little Endian Base 128 (LEB128)
DW_EH_PE_UDATA2 = 0x02, // A 2 bytes unsigned value. DW_EH_PE_udata2 = 0x02, // A 2 bytes unsigned value.
DW_EH_PE_UDATA4 = 0x03, // A 4 bytes unsigned value. DW_EH_PE_udata4 = 0x03, // A 4 bytes unsigned value.
DW_EH_PE_UDATA8 = 0x04, // An 8 bytes unsigned value. DW_EH_PE_udata8 = 0x04, // An 8 bytes unsigned value.
DW_EH_PE_SLEB128 = 0x09, // Signed value is encoded using the Little Endian Base 128(LEB128) DW_EH_PE_sleb128 = 0x09, // Signed value is encoded using the Little Endian Base 128(LEB128)
DW_EH_PE_SDATA2 = 0x0A, // A 2 bytes signed value. DW_EH_PE_sdata2 = 0x0A, // A 2 bytes signed value.
DW_EH_PE_SDATA4 = 0x0B, // A 4 bytes signed value. DW_EH_PE_sdata4 = 0x0B, // A 4 bytes signed value.
DW_EH_PE_SDATA8 = 0x0C, // An 8 bytes signed value. DW_EH_PE_sdata8 = 0x0C, // An 8 bytes signed value.
}; };
// Table 10-6. DWARF Exception Header application // Table 10-6. DWARF Exception Header application
enum DW_EH_PE_A { enum DW_EH_PE_A {
DW_EH_PE_NOTHING = 0x00, // nothing to do DW_EH_PE_nothing = 0x00, // nothing to do
DW_EH_PE_PCREL = 0x10, // relative to the current program counter. DW_EH_PE_pcrel = 0x10, // relative to the current program counter.
DW_EH_PE_TEXTREL = 0x20, // relative to the beginning of the .text section. DW_EH_PE_textrel = 0x20, // relative to the beginning of the .text section.
DW_EH_PE_DATAREL = 0x30, // relative to the beginning of the .got or .eh_frame_hdr section. DW_EH_PE_datarel = 0x30, // relative to the beginning of the .got or .eh_frame_hdr section.
DW_EH_PE_FUNCREL = 0x40, // relative to the beginning of the function. DW_EH_PE_funcrel = 0x40, // relative to the beginning of the function.
DW_EH_PE_ALIGNED = 0x50, // aligned to an address unit sized boundary. DW_EH_PE_aligned = 0x50, // aligned to an address unit sized boundary.
DW_EH_PE_OMIT = 0xff, // indicate that no value is present. DW_EH_PE_omit = 0xff, // indicate that no value is present.
}; };
const std::map<dw_encode_t, size_t> DWFormatSizeMap = { const std::map<dw_encode_t, size_t> DWFormatSizeMap = {
#ifdef ARM #ifdef ARM
{DW_EH_PE_ABSPTR, 4}, {DW_EH_PE_absptr, 4},
#else #else
{DW_EH_PE_ABSPTR, 8}, {DW_EH_PE_absptr, 8},
#endif #endif
#ifdef NOT_USE #ifdef NOT_USE
{DW_EH_PE_ULEB128, sizeof(char) * 128}, {DW_EH_PE_uleb128, sizeof(char) * 128},
#endif #endif
{DW_EH_PE_UDATA2, sizeof(char) * 2}, {DW_EH_PE_udata2, sizeof(char) * 2},
{DW_EH_PE_UDATA4, sizeof(char) * 4}, {DW_EH_PE_udata4, sizeof(char) * 4},
{DW_EH_PE_UDATA8, sizeof(char) * 8}, {DW_EH_PE_udata8, sizeof(char) * 8},
#ifdef NOT_USE #ifdef NOT_USE
{DW_EH_PE_SLEB128, sizeof(char) * 128}, {DW_EH_PE_sleb128, sizeof(char) * 128},
#endif #endif
{DW_EH_PE_SDATA2, sizeof(char) * 2}, {DW_EH_PE_sdata2, sizeof(char) * 2},
{DW_EH_PE_SDATA4, sizeof(char) * 4}, {DW_EH_PE_sdata4, sizeof(char) * 4},
{DW_EH_PE_SDATA8, sizeof(char) * 8}, {DW_EH_PE_sdata8, sizeof(char) * 8},
}; };
template<class T> template<class T>

View File

@ -66,7 +66,7 @@ public:
// clang-format on // clang-format on
{ {
} }
~SubCommandDump(); ~SubCommandDump() override;
bool OnSubCommand(std::vector<std::string> &args) override; bool OnSubCommand(std::vector<std::string> &args) override;
bool ParseOption(std::vector<std::string> &args) override; bool ParseOption(std::vector<std::string> &args) override;

View File

@ -29,44 +29,42 @@ namespace OHOS {
namespace Developtools { namespace Developtools {
namespace HiPerf { namespace HiPerf {
namespace HiperfClient { namespace HiperfClient {
static const std::string HiperfCommandName = "hiperf"; static const std::string HIPERF_COMMAND_NAME = "hiperf";
static const std::string SystemBinPath = "/system/bin/"; static const std::string SYSTEM_BIN_PATH = "/system/bin/";
static const std::string CurrentPath = "./"; static const std::string CURRENT_PATH = "./";
static const std::string PerfDataName = "perf.data"; static const std::string PERF_DATA_NAME = "perf.data";
static const std::string CommandRecord = "record"; static const std::string COMMAND_RECORD = "record";
static const std::string ArgOutputPath = "-o"; static const std::string ARG_OUTPUT_PATH = "-o";
static const std::string ArgDebug = "--verbose"; static const std::string ARG_DEBUG = "--verbose";
static const std::string ArgDebugMuch = "--much"; static const std::string ARG_DEBUG_MUCH = "--much";
static const std::string ArgHilog = "--hilog"; static const std::string ARG_HILOG = "--hilog";
static const std::string ArgPipeInput = "--pipe_input"; static const std::string ARG_PIPE_INPUT = "--pipe_input";
static const std::string ArgPipeOutput = "--pipe_output"; static const std::string ARG_PIPE_OUTPUT = "--pipe_output";
static const std::string ArgTargetSystemWide = "-a"; static const std::string ARG_TARGET_SYSTEM_WIDE = "-a";
static const std::string ArgCompressData = "-z"; static const std::string ARG_COMPRESS_DATA = "-z";
static const std::string ArgSelectCpus = "-c"; static const std::string ARG_SELECT_CPUS = "-c";
static const std::string ArgTimeStopSec = "-d"; static const std::string ARG_TIME_STOP_SEC = "-d";
static const std::string ArgFrequency = "-f"; static const std::string ARG_FREQUENCY = "-f";
static const std::string ArgPeriod = "--period"; static const std::string ARG_PERIOD = "--period";
static const std::string ArgSelectEvents = "-e"; static const std::string ARG_SELECT_EVENTS = "-e";
static const std::string ArgSelectGroups = "-g"; static const std::string ARG_SELECT_GROUPS = "-g";
static const std::string ArgNoInherit = "--no-inherit"; static const std::string ARG_NO_INHERIT = "--no-inherit";
static const std::string ArgSelectPids = "-p"; static const std::string ARG_SELECT_PIDS = "-p";
static const std::string ArgSelectTids = "-t"; static const std::string ARG_SELECT_TIDS = "-t";
static const std::string ArgExcludePerf = "--exclude-hiperf"; static const std::string ARG_EXCLUDE_PERF = "--exclude-hiperf";
static const std::string ArgCpuPercent = "--cpu-limit"; static const std::string ARG_CPU_PERCENT = "--cpu-limit";
static const std::string ArgOffCPU = "--offcpu"; static const std::string ARG_OFF_CPU = "--offcpu";
static const std::string ArgCallGraph = "--call-stack"; static const std::string ARG_CALL_GRAPH = "--call-stack";
static const std::string ArgDelayUnwind = "--delay-unwind"; static const std::string ARG_DELAY_UNWIND = "--delay-unwind";
static const std::string ArgDisableUnwind = "--disable-unwind"; static const std::string ARG_DISABLE_UNWIND = "--disable-unwind";
static const std::string ArgDisableCallstackMerge = "--disable-callstack-expand"; static const std::string ARG_DISABLE_CALLSTACK_MERGE = "--disable-callstack-expand";
static const std::string ArgSymbolDir = "--symbol-dir"; static const std::string ARG_SYMBOL_DIR = "--symbol-dir";
static const std::string ArgOutputFilename = "-o"; static const std::string ARG_DATA_LIMIT = "--data-limit";
static const std::string ArgDataLimit = "--data-limit"; static const std::string ARG_APP_PACKAGE = "--app";
static const std::string ArgAppPackage = "--app"; static const std::string ARG_CLOCK_ID = "--clockid";
static const std::string ArgClockId = "--clockid"; static const std::string ARG_VEC_BRANCH_SAMPLE_TYPES = "-j";
static const std::string ArgVecBranchSampleTypes = "-j"; static const std::string ARG_MMAP_PAGES = "-m";
static const std::string ArgMmapPages = "-m"; static const std::string ARG_REPORT = "--report";
static const std::string ArgDedupStack = "--dedup_stack";
static const std::string ArgReport = "--report";
static constexpr int DEFAULT_DURATION_TIME = 10; static constexpr int DEFAULT_DURATION_TIME = 10;
static constexpr int DEFAULT_FREQUENCY_TIME = 100; static constexpr int DEFAULT_FREQUENCY_TIME = 100;
@ -182,53 +180,53 @@ void RecordOption::SetOption(const std::string &name, const std::vector<std::str
void RecordOption::SetTargetSystemWide(bool enable) void RecordOption::SetTargetSystemWide(bool enable)
{ {
SetOption(ArgTargetSystemWide, enable); SetOption(ARG_TARGET_SYSTEM_WIDE, enable);
} }
void RecordOption::SetCompressData(bool enable) void RecordOption::SetCompressData(bool enable)
{ {
SetOption(ArgCompressData, enable); SetOption(ARG_COMPRESS_DATA, enable);
} }
void RecordOption::SetSelectCpus(const std::vector<int> &cpus) void RecordOption::SetSelectCpus(const std::vector<int> &cpus)
{ {
SetOption(ArgSelectCpus, cpus); SetOption(ARG_SELECT_CPUS, cpus);
} }
void RecordOption::SetTimeStopSec(int timeStopSec) void RecordOption::SetTimeStopSec(int timeStopSec)
{ {
this->timeSpec_ = true; this->timeSpec_ = true;
SetOption(ArgTimeStopSec, timeStopSec); SetOption(ARG_TIME_STOP_SEC, timeStopSec);
} }
void RecordOption::SetFrequency(int frequency) void RecordOption::SetFrequency(int frequency)
{ {
SetOption(ArgFrequency, frequency); SetOption(ARG_FREQUENCY, frequency);
} }
void RecordOption::SetPeriod(int period) void RecordOption::SetPeriod(int period)
{ {
SetOption(ArgPeriod, period); SetOption(ARG_PERIOD, period);
} }
void RecordOption::SetSelectEvents(const std::vector<std::string> &selectEvents) void RecordOption::SetSelectEvents(const std::vector<std::string> &selectEvents)
{ {
SetOption(ArgSelectEvents, selectEvents); SetOption(ARG_SELECT_EVENTS, selectEvents);
} }
void RecordOption::SetSelectGroups(const std::vector<std::string> &selectGroups) void RecordOption::SetSelectGroups(const std::vector<std::string> &selectGroups)
{ {
SetOption(ArgSelectGroups, selectGroups); SetOption(ARG_SELECT_GROUPS, selectGroups);
} }
void RecordOption::SetNoInherit(bool enable) void RecordOption::SetNoInherit(bool enable)
{ {
SetOption(ArgNoInherit, enable); SetOption(ARG_NO_INHERIT, enable);
} }
void RecordOption::SetSelectPids(const std::vector<pid_t> &selectPids) void RecordOption::SetSelectPids(const std::vector<pid_t> &selectPids)
{ {
SetOption(ArgSelectPids, selectPids); SetOption(ARG_SELECT_PIDS, selectPids);
} }
void RecordOption::SetCallStackSamplingConfigs(int duration) void RecordOption::SetCallStackSamplingConfigs(int duration)
@ -245,77 +243,77 @@ void RecordOption::SetCallStackSamplingConfigs(int duration)
void RecordOption::SetSelectTids(const std::vector<pid_t> &selectTids) void RecordOption::SetSelectTids(const std::vector<pid_t> &selectTids)
{ {
SetOption(ArgSelectTids, selectTids); SetOption(ARG_SELECT_TIDS, selectTids);
} }
void RecordOption::SetExcludePerf(bool excludePerf) void RecordOption::SetExcludePerf(bool excludePerf)
{ {
SetOption(ArgExcludePerf, excludePerf); SetOption(ARG_EXCLUDE_PERF, excludePerf);
} }
void RecordOption::SetCpuPercent(int cpuPercent) void RecordOption::SetCpuPercent(int cpuPercent)
{ {
SetOption(ArgCpuPercent, cpuPercent); SetOption(ARG_CPU_PERCENT, cpuPercent);
} }
void RecordOption::SetOffCPU(bool offCPU) void RecordOption::SetOffCPU(bool offCPU)
{ {
SetOption(ArgOffCPU, offCPU); SetOption(ARG_OFF_CPU, offCPU);
} }
void RecordOption::SetCallGraph(const std::string &callGraph) void RecordOption::SetCallGraph(const std::string &callGraph)
{ {
SetOption(ArgCallGraph, callGraph); SetOption(ARG_CALL_GRAPH, callGraph);
} }
void RecordOption::SetDelayUnwind(bool delayUnwind) void RecordOption::SetDelayUnwind(bool delayUnwind)
{ {
SetOption(ArgDelayUnwind, delayUnwind); SetOption(ARG_DELAY_UNWIND, delayUnwind);
} }
void RecordOption::SetDisableUnwind(bool disableUnwind) void RecordOption::SetDisableUnwind(bool disableUnwind)
{ {
SetOption(ArgDisableUnwind, disableUnwind); SetOption(ARG_DISABLE_UNWIND, disableUnwind);
} }
void RecordOption::SetDisableCallstackMerge(bool disableCallstackMerge) void RecordOption::SetDisableCallstackMerge(bool disableCallstackMerge)
{ {
SetOption(ArgDisableCallstackMerge, disableCallstackMerge); SetOption(ARG_DISABLE_CALLSTACK_MERGE, disableCallstackMerge);
} }
void RecordOption::SetSymbolDir(const std::string &symbolDir_) void RecordOption::SetSymbolDir(const std::string &symbolDir_)
{ {
SetOption(ArgSymbolDir, symbolDir_); SetOption(ARG_SYMBOL_DIR, symbolDir_);
} }
void RecordOption::SetDataLimit(const std::string &limit) void RecordOption::SetDataLimit(const std::string &limit)
{ {
SetOption(ArgDataLimit, limit); SetOption(ARG_DATA_LIMIT, limit);
} }
void RecordOption::SetAppPackage(const std::string &appPackage) void RecordOption::SetAppPackage(const std::string &appPackage)
{ {
SetOption(ArgAppPackage, appPackage); SetOption(ARG_APP_PACKAGE, appPackage);
} }
void RecordOption::SetClockId(const std::string &clockId) void RecordOption::SetClockId(const std::string &clockId)
{ {
SetOption(ArgClockId, clockId); SetOption(ARG_CLOCK_ID, clockId);
} }
void RecordOption::SetVecBranchSampleTypes(const std::vector<std::string> &vecBranchSampleTypes) void RecordOption::SetVecBranchSampleTypes(const std::vector<std::string> &vecBranchSampleTypes)
{ {
SetOption(ArgVecBranchSampleTypes, vecBranchSampleTypes); SetOption(ARG_VEC_BRANCH_SAMPLE_TYPES, vecBranchSampleTypes);
} }
void RecordOption::SetMmapPages(int mmapPages) void RecordOption::SetMmapPages(int mmapPages)
{ {
SetOption(ArgMmapPages, mmapPages); SetOption(ARG_MMAP_PAGES, mmapPages);
} }
void RecordOption::SetReport(bool report) void RecordOption::SetReport(bool report)
{ {
SetOption(ArgReport, report); SetOption(ARG_REPORT, report);
} }
Client::Client(const std::string &outputDir) Client::Client(const std::string &outputDir)
@ -327,9 +325,9 @@ Client::Client(const std::string &outputDir)
bool Client::Setup(std::string outputDir) bool Client::Setup(std::string outputDir)
{ {
std::string CurrentCommandPath = CurrentPath + HiperfCommandName; std::string CurrentCommandPath = CURRENT_PATH + HIPERF_COMMAND_NAME;
std::string SystemCommandPath = SystemBinPath + HiperfCommandName; std::string SystemCommandPath = SYSTEM_BIN_PATH + HIPERF_COMMAND_NAME;
std::string TempCommandPath = TempBinPath + HiperfCommandName; std::string TempCommandPath = TempBinPath + HIPERF_COMMAND_NAME;
if (!outputDir.empty() && outputDir.back() != '/') { if (!outputDir.empty() && outputDir.back() != '/') {
outputDir.push_back('/'); outputDir.push_back('/');
@ -352,13 +350,13 @@ bool Client::Setup(std::string outputDir)
// found command path // found command path
if (access(outputDir.c_str(), W_OK) == 0) { if (access(outputDir.c_str(), W_OK) == 0) {
outputDir_ = outputDir; outputDir_ = outputDir;
} else if (access(CurrentPath.c_str(), W_OK) == 0) { } else if (access(CURRENT_PATH.c_str(), W_OK) == 0) {
outputDir_ = CurrentPath; outputDir_ = CURRENT_PATH;
} else { } else {
HIPERF_HILOGI(MODULE_CPP_API, "no writeable output path found\n"); HIPERF_HILOGI(MODULE_CPP_API, "no writeable output path found\n");
return ready_; return ready_;
} }
outputFileName_ = PerfDataName; outputFileName_ = PERF_DATA_NAME;
myPid_ = getpid(); myPid_ = getpid();
@ -404,17 +402,17 @@ void Client::PrepareExecCmd(std::vector<std::string> &cmd)
cmd.emplace_back(executeCommandPath_); cmd.emplace_back(executeCommandPath_);
if (debug_) { if (debug_) {
cmd.emplace_back(ArgDebug); cmd.emplace_back(ARG_DEBUG);
} else if (debugMuch_) { } else if (debugMuch_) {
cmd.emplace_back(ArgDebugMuch); cmd.emplace_back(ARG_DEBUG_MUCH);
} }
if (hilog_) { if (hilog_) {
cmd.emplace_back(ArgHilog); cmd.emplace_back(ARG_HILOG);
} }
cmd.emplace_back(CommandRecord); cmd.emplace_back(COMMAND_RECORD);
cmd.emplace_back(ArgOutputPath); cmd.emplace_back(ARG_OUTPUT_PATH);
cmd.emplace_back(GetOutputPerfDataPath()); cmd.emplace_back(GetOutputPerfDataPath());
} }
@ -422,9 +420,9 @@ void Client::GetExecCmd(std::vector<std::string> &cmd, int pipeIn, int pipeOut,
const std::vector<std::string> &args) const std::vector<std::string> &args)
{ {
PrepareExecCmd(cmd); PrepareExecCmd(cmd);
cmd.emplace_back(ArgPipeInput); cmd.emplace_back(ARG_PIPE_INPUT);
cmd.emplace_back(std::to_string(pipeIn)); cmd.emplace_back(std::to_string(pipeIn));
cmd.emplace_back(ArgPipeOutput); cmd.emplace_back(ARG_PIPE_OUTPUT);
cmd.emplace_back(std::to_string(pipeOut)); cmd.emplace_back(std::to_string(pipeOut));
cmd.insert(cmd.end(), args.begin(), args.end()); cmd.insert(cmd.end(), args.begin(), args.end());

View File

@ -66,11 +66,11 @@ uint64_t DwarfEncoding::GetValue() const
uint64_t DwarfEncoding::GetAppliedValue() const uint64_t DwarfEncoding::GetAppliedValue() const
{ {
if ((Application() & DW_EH_PE_DATAREL) == DW_EH_PE_DATAREL) { if ((Application() & DW_EH_PE_datarel) == DW_EH_PE_datarel) {
return value_[0] + vaddrBase_; return value_[0] + vaddrBase_;
} else if ((Application() & DW_EH_PE_TEXTREL) == DW_EH_PE_TEXTREL) { } else if ((Application() & DW_EH_PE_textrel) == DW_EH_PE_textrel) {
return value_[0] + vaddrText_; return value_[0] + vaddrText_;
} else if ((Application() & DW_EH_PE_PCREL) == DW_EH_PE_PCREL) { } else if ((Application() & DW_EH_PE_pcrel) == DW_EH_PE_pcrel) {
return value_[0] + vaddrPC_; return value_[0] + vaddrPC_;
} }
HLOGM("Application is empty"); HLOGM("Application is empty");
@ -80,7 +80,7 @@ uint64_t DwarfEncoding::GetAppliedValue() const
bool DwarfEncoding::IsOmit() const bool DwarfEncoding::IsOmit() const
{ {
return (dw_ == DW_EH_PE_OMIT); return (dw_ == DW_EH_PE_omit);
} }
dw_encode_t DwarfEncoding::Format() const dw_encode_t DwarfEncoding::Format() const
@ -94,17 +94,17 @@ dw_encode_t DwarfEncoding::Application() const
uint64_t DwarfEncoding::ReadValue(const unsigned char *&data) const uint64_t DwarfEncoding::ReadValue(const unsigned char *&data) const
{ {
switch (Format()) { switch (Format()) {
case DW_EH_PE_UDATA2: case DW_EH_PE_udata2:
return dwReadAnyTypeData(data, uint16_t()); return dwReadAnyTypeData(data, uint16_t());
case DW_EH_PE_UDATA4: case DW_EH_PE_udata4:
return dwReadAnyTypeData(data, uint32_t()); return dwReadAnyTypeData(data, uint32_t());
case DW_EH_PE_UDATA8: case DW_EH_PE_udata8:
return dwReadAnyTypeData(data, uint64_t()); return dwReadAnyTypeData(data, uint64_t());
case DW_EH_PE_SDATA2: case DW_EH_PE_sdata2:
return dwReadAnyTypeData(data, int16_t()); return dwReadAnyTypeData(data, int16_t());
case DW_EH_PE_SDATA4: case DW_EH_PE_sdata4:
return dwReadAnyTypeData(data, int32_t()); return dwReadAnyTypeData(data, int32_t());
case DW_EH_PE_SDATA8: case DW_EH_PE_sdata8:
return dwReadAnyTypeData(data, int64_t()); return dwReadAnyTypeData(data, int64_t());
default: default:
return -1; return -1;
@ -113,25 +113,25 @@ uint64_t DwarfEncoding::ReadValue(const unsigned char *&data) const
const std::string DwarfEncoding::FormatName() const const std::string DwarfEncoding::FormatName() const
{ {
switch (Format()) { switch (Format()) {
case DW_EH_PE_ABSPTR: case DW_EH_PE_absptr:
return "DW_EH_PE_absptr"; return "DW_EH_PE_absptr";
case DW_EH_PE_ULEB128: case DW_EH_PE_uleb128:
return "DW_EH_PE_uleb128"; return "DW_EH_PE_uleb128";
case DW_EH_PE_UDATA2: case DW_EH_PE_udata2:
return "DW_EH_PE_udata2"; return "DW_EH_PE_udata2";
case DW_EH_PE_UDATA4: case DW_EH_PE_udata4:
return "DW_EH_PE_udata4"; return "DW_EH_PE_udata4";
case DW_EH_PE_UDATA8: case DW_EH_PE_udata8:
return "DW_EH_PE_udata8"; return "DW_EH_PE_udata8";
case DW_EH_PE_SLEB128: case DW_EH_PE_sleb128:
return "DW_EH_PE_sleb128"; return "DW_EH_PE_sleb128";
case DW_EH_PE_SDATA2: case DW_EH_PE_sdata2:
return "DW_EH_PE_sdata2"; return "DW_EH_PE_sdata2";
case DW_EH_PE_SDATA4: case DW_EH_PE_sdata4:
return "DW_EH_PE_sdata4"; return "DW_EH_PE_sdata4";
case DW_EH_PE_SDATA8: case DW_EH_PE_sdata8:
return "DW_EH_PE_sdata8"; return "DW_EH_PE_sdata8";
case DW_EH_PE_OMIT: case DW_EH_PE_omit:
return "DW_EH_PE_omit"; return "DW_EH_PE_omit";
default: default:
return "unknown format"; return "unknown format";
@ -140,19 +140,19 @@ const std::string DwarfEncoding::FormatName() const
const std::string DwarfEncoding::ApplicationName() const const std::string DwarfEncoding::ApplicationName() const
{ {
switch (Application()) { switch (Application()) {
case DW_EH_PE_PCREL: case DW_EH_PE_pcrel:
return "DW_EH_PE_pcrel"; return "DW_EH_PE_pcrel";
case DW_EH_PE_TEXTREL: case DW_EH_PE_textrel:
return "DW_EH_PE_textrel"; return "DW_EH_PE_textrel";
case DW_EH_PE_DATAREL: case DW_EH_PE_datarel:
return "DW_EH_PE_datarel"; return "DW_EH_PE_datarel";
case DW_EH_PE_FUNCREL: case DW_EH_PE_funcrel:
return "DW_EH_PE_funcrel"; return "DW_EH_PE_funcrel";
case DW_EH_PE_ALIGNED: case DW_EH_PE_aligned:
return "DW_EH_PE_aligned"; return "DW_EH_PE_aligned";
case DW_EH_PE_OMIT: case DW_EH_PE_omit:
return "DW_EH_PE_omit"; return "DW_EH_PE_omit";
case DW_EH_PE_NOTHING: case DW_EH_PE_nothing:
return "DW_EH_PE_empty"; return "DW_EH_PE_empty";
default: default:
return "unknown format"; return "unknown format";

View File

@ -19,7 +19,7 @@
namespace OHOS { namespace OHOS {
namespace Developtools { namespace Developtools {
namespace HiPerf { namespace HiPerf {
static const std::vector<std::string> extFeatureNames = { static const std::vector<std::string> EXT_FEATURE_NAMES = {
"hiperf_files_symbol", "hiperf_files_symbol",
"hiperf_workloader_cmd", "hiperf_workloader_cmd",
"hiperf_record_time", "hiperf_record_time",
@ -27,7 +27,7 @@ static const std::vector<std::string> extFeatureNames = {
"hiperf_hm_devhost", "hiperf_hm_devhost",
"hiperf_stack_table", "hiperf_stack_table",
}; };
static const std::vector<std::string> featureNames = { static const std::vector<std::string> FEATURE_NAMES = {
"unknown_feature", "tracing_data", "build_id", "hostname", "osrelease", "unknown_feature", "tracing_data", "build_id", "hostname", "osrelease",
"version", "arch", "nrcpus", "cpudesc", "cpuid", "version", "arch", "nrcpus", "cpudesc", "cpuid",
"total_mem", "cmdline", "event_desc", "cpu_topology", "numa_topology", "total_mem", "cmdline", "event_desc", "cpu_topology", "numa_topology",
@ -44,15 +44,15 @@ std::string PerfFileSection::GetFeatureName(FEATURE featureId)
unsigned int index = static_cast<unsigned int>(featureId); unsigned int index = static_cast<unsigned int>(featureId);
if (featureId >= FEATURE::HIPERF_FIRST_FEATURE) { if (featureId >= FEATURE::HIPERF_FIRST_FEATURE) {
index -= static_cast<unsigned int>(FEATURE::HIPERF_FIRST_FEATURE); index -= static_cast<unsigned int>(FEATURE::HIPERF_FIRST_FEATURE);
if (index >= extFeatureNames.size()) { if (index >= EXT_FEATURE_NAMES.size()) {
return featureNames[0]; return FEATURE_NAMES[0];
} }
return extFeatureNames[index]; return EXT_FEATURE_NAMES[index];
} else { } else {
if (index >= featureNames.size()) { if (index >= FEATURE_NAMES.size()) {
return featureNames[0]; return FEATURE_NAMES[0];
} }
return featureNames[index]; return FEATURE_NAMES[index];
} }
} }

View File

@ -586,7 +586,7 @@ bool SubCommandStat::FindPercoreRunningTime(PerfEvents::Summary &summary, double
} }
running_time_int_sec = summary.eventCount / 1e9; running_time_int_sec = summary.eventCount / 1e9;
if (summary.timeRunning < summary.timeEnabled && summary.timeRunning != 0) { if (summary.timeRunning < summary.timeEnabled && summary.timeRunning != 0) {
main_scale = static_cast<double>(summary.timeEnabled) /summary.timeRunning; main_scale = static_cast<double>(summary.timeEnabled) / summary.timeRunning;
} }
return true; return true;
} }

View File

@ -167,7 +167,7 @@ public:
{ {
} }
~ElfFileSymbols() virtual ~ElfFileSymbols()
{ {
} }

View File

@ -29,8 +29,9 @@
namespace OHOS { namespace OHOS {
namespace Developtools { namespace Developtools {
namespace HiPerf { namespace HiPerf {
constexpr const int MMAP_PROT_CHARS = 4;
constexpr const int MAP_PROT_EXEC_INDEX = 2; static constexpr int MMAP_PROT_CHARS = 4;
static constexpr int MAP_PROT_EXEC_INDEX = 2;
#ifdef DEBUG_TIME #ifdef DEBUG_TIME

View File

@ -79,19 +79,19 @@ std::vector<uint64_t> values {
1940830438011385600ULL, 1940830438011385600ULL,
}; };
std::vector<dw_encode_t> vfs { std::vector<dw_encode_t> vfs {
DW_EH_PE_ABSPTR, DW_EH_PE_absptr,
#ifdef NOT_USE #ifdef NOT_USE
DW_EH_PE_ULEB128, DW_EH_PE_uleb128,
#endif #endif
DW_EH_PE_UDATA2, DW_EH_PE_UDATA4, DW_EH_PE_UDATA8, DW_EH_PE_udata2, DW_EH_PE_udata4, DW_EH_PE_udata8,
#ifdef NOT_USE #ifdef NOT_USE
DW_EH_PE_SLEB128, DW_EH_PE_sleb128,
#endif #endif
DW_EH_PE_SDATA2, DW_EH_PE_SDATA4, DW_EH_PE_SDATA8, DW_EH_PE_sdata2, DW_EH_PE_sdata4, DW_EH_PE_sdata8,
}; };
vector<dw_encode_t> ehas { vector<dw_encode_t> ehas {
DW_EH_PE_NOTHING, DW_EH_PE_PCREL, DW_EH_PE_TEXTREL, DW_EH_PE_DATAREL, DW_EH_PE_nothing, DW_EH_PE_pcrel, DW_EH_PE_textrel, DW_EH_PE_datarel,
DW_EH_PE_FUNCREL, DW_EH_PE_ALIGNED, DW_EH_PE_OMIT, DW_EH_PE_funcrel, DW_EH_PE_aligned, DW_EH_PE_omit,
}; };
} // namespace } // namespace
@ -138,7 +138,7 @@ HWTEST_F(DwarfTest, GetEnd, TestSize.Level1)
dw_encode_t dwe = ehas[i] | vfs[j]; dw_encode_t dwe = ehas[i] | vfs[j];
DwarfEncoding dw {dwe, data[j]}; DwarfEncoding dw {dwe, data[j]};
if (!dw.IsOmit()) { if (!dw.IsOmit()) {
if (vfs[j] == DW_EH_PE_ABSPTR) { if (vfs[j] == DW_EH_PE_absptr) {
EXPECT_TRUE(data[j] == dw.GetEnd() - dw.GetSize()); EXPECT_TRUE(data[j] == dw.GetEnd() - dw.GetSize());
} else { } else {
EXPECT_TRUE(data[j] == dw.GetEnd()); EXPECT_TRUE(data[j] == dw.GetEnd());
@ -157,7 +157,7 @@ HWTEST_F(DwarfTest, GetData, TestSize.Level1)
dw_encode_t dwe = ehas[i] | vfs[j]; dw_encode_t dwe = ehas[i] | vfs[j];
DwarfEncoding dw {dwe, data[j]}; DwarfEncoding dw {dwe, data[j]};
if (!dw.IsOmit()) { if (!dw.IsOmit()) {
if (vfs[j] == DW_EH_PE_ABSPTR) { if (vfs[j] == DW_EH_PE_absptr) {
EXPECT_TRUE(data[j] == dw.GetData()); EXPECT_TRUE(data[j] == dw.GetData());
} else { } else {
EXPECT_TRUE(data[j] == dw.GetData() + dw.GetSize()); EXPECT_TRUE(data[j] == dw.GetData() + dw.GetSize());
@ -190,7 +190,7 @@ HWTEST_F(DwarfTest, IsOmit, TestSize.Level1)
{ {
dw_encode_t dwe = ehas[i] | vfs[j]; dw_encode_t dwe = ehas[i] | vfs[j];
DwarfEncoding dw {dwe, data[j]}; DwarfEncoding dw {dwe, data[j]};
if (ehas[i] == DW_EH_PE_OMIT) { if (ehas[i] == DW_EH_PE_omit) {
EXPECT_TRUE(dw.IsOmit()); EXPECT_TRUE(dw.IsOmit());
} else { } else {
EXPECT_FALSE(dw.IsOmit()); EXPECT_FALSE(dw.IsOmit());