spe宏隔离

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

Signed-off-by: wenlong12 <wenlong12@huawei.com>
This commit is contained in:
wenlong12 2024-08-08 10:26:21 +08:00
parent c19b7cd590
commit 76f055737b
8 changed files with 107 additions and 37 deletions

View File

@ -119,7 +119,6 @@ Note:If the text contains special characters, please escape them according to th
<filteritem type="filepath" name="test/unittest/resource/testdata/dwarf.uncompress.data" desc="the binary file for test, the file is self-developed"/> <filteritem type="filepath" name="test/unittest/resource/testdata/dwarf.uncompress.data" desc="the binary file for test, the file is self-developed"/>
<filteritem type="filepath" name="test/unittest/resource/testdata/fp.compress.data" desc="the binary file for test, the file is self-developed"/> <filteritem type="filepath" name="test/unittest/resource/testdata/fp.compress.data" desc="the binary file for test, the file is self-developed"/>
<filteritem type="filepath" name="test/unittest/resource/testdata/fp.uncompress.data" desc="the binary file for test, the file is self-developed"/> <filteritem type="filepath" name="test/unittest/resource/testdata/fp.uncompress.data" desc="the binary file for test, the file is self-developed"/>
<filteritem type="filepath" name="test/unittest/resource/testdata/spe_perf.data" desc="the binary file for test, the file is self-developed"/>
<filteritem type="filepath" name="demo/js/entry/src/main/resources/base/media/icon.png" desc="the binary file, the file is self-picture"/> <filteritem type="filepath" name="demo/js/entry/src/main/resources/base/media/icon.png" desc="the binary file, the file is self-picture"/>
<filteritem type="filepath" name="figures/hiperf_architecture.png" desc="the binary file, the file is self-picture"/> <filteritem type="filepath" name="figures/hiperf_architecture.png" desc="the binary file, the file is self-picture"/>
<filteritem type="filepath" name="figures/hiperf_architecture_zh.png" desc="the binary file, the file is self-picture"/> <filteritem type="filepath" name="figures/hiperf_architecture_zh.png" desc="the binary file, the file is self-picture"/>

View File

@ -542,7 +542,6 @@ private:
void PrepareConsole(); void PrepareConsole();
void OutputStdStatistics(ReportEventConfigItem &config); void OutputStdStatistics(ReportEventConfigItem &config);
bool OutputStdStatistics(ReportEventConfigItem &config, ReportEventConfigItem &otherConfig);
void OutputStdHead(ReportEventConfigItem &config, bool diffMode = false); void OutputStdHead(ReportEventConfigItem &config, bool diffMode = false);

View File

@ -84,7 +84,6 @@ public:
uint64_t len, uint64_t offset, uint32_t prot = 0); uint64_t len, uint64_t offset, uint32_t prot = 0);
std::shared_ptr<DfxMap> FindMapByAddr(uint64_t addr) const; std::shared_ptr<DfxMap> FindMapByAddr(uint64_t addr) const;
std::shared_ptr<DfxMap> FindMapByFileInfo(const std::string name, uint64_t offset) const; std::shared_ptr<DfxMap> FindMapByFileInfo(const std::string name, uint64_t offset) const;
std::shared_ptr<DfxMap> FindFirstMapByFileInfo(const std::string name) const;
int64_t FindMapIndexByAddr(uint64_t addr) const; int64_t FindMapIndexByAddr(uint64_t addr) const;
SymbolsFile *FindSymbolsFileByMap(std::shared_ptr<DfxMap> map) const; SymbolsFile *FindSymbolsFileByMap(std::shared_ptr<DfxMap> map) const;
bool ReadRoMemory(uint64_t vaddr, uint8_t *data, size_t size) const; bool ReadRoMemory(uint64_t vaddr, uint8_t *data, size_t size) const;

View File

@ -350,25 +350,6 @@ void Report::OutputStdStatistics(ReportEventConfigItem &config)
fprintf(output_, "%" PRIu64 "\n", config.eventCount_); fprintf(output_, "%" PRIu64 "\n", config.eventCount_);
} }
bool Report::OutputStdStatistics(ReportEventConfigItem &config, ReportEventConfigItem &otherConfig)
{
if (config != otherConfig) {
fprintf(output_, "diff config unable compare\n");
return false;
}
fprintf(output_, "Event: %s (type %" PRIu32 " id %" PRIu64 ")", config.eventName_.c_str(),
config.type_, config.config_);
fprintf(output_, "Samples Count: %" PRIu64 " vs %" PRIu64 "\n", config.sampleCount_,
otherConfig.sampleCount_);
if (config.coutMode_) {
fprintf(output_, "Time in ns: ");
} else {
fprintf(output_, "Event Count: ");
}
fprintf(output_, "%" PRIu64 " vs %" PRIu64 "\n", config.eventCount_, otherConfig.eventCount_);
return true;
}
void Report::OutputStdHead(ReportEventConfigItem &config, bool diffMode) void Report::OutputStdHead(ReportEventConfigItem &config, bool diffMode)
{ {
// head print // head print

View File

@ -32,6 +32,7 @@ constexpr const int UN_PRMT = -1;
const char *SpePktName(enum SpePktType type) const char *SpePktName(enum SpePktType type)
{ {
#ifndef UNITTEST
const char* spePacketName; const char* spePacketName;
switch (type) { switch (type) {
case PERF_SPE_PAD: spePacketName = "PAD"; break; case PERF_SPE_PAD: spePacketName = "PAD"; break;
@ -46,6 +47,9 @@ const char *SpePktName(enum SpePktType type)
default: spePacketName = "INVALID"; break; default: spePacketName = "INVALID"; break;
} }
return spePacketName; return spePacketName;
#else
return "INVALID";
#endif
} }
static unsigned int SpePayloadLen(unsigned char hdr) static unsigned int SpePayloadLen(unsigned char hdr)
@ -56,6 +60,7 @@ static unsigned int SpePayloadLen(unsigned char hdr)
static int SpeGetPayload(const unsigned char *buf, size_t len, static int SpeGetPayload(const unsigned char *buf, size_t len,
unsigned char extHdr, struct SpePkt *packet) unsigned char extHdr, struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -76,22 +81,28 @@ static int SpeGetPayload(const unsigned char *buf, size_t len,
} }
return 1 + extHdr + payloadLen; return 1 + extHdr + payloadLen;
#else
return 0;
#endif
} }
static int SpeGetPad(struct SpePkt *packet) static int SpeGetPad(struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (packet == nullptr) { if (packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
return -1; return -1;
} }
packet->type = PERF_SPE_PAD; packet->type = PERF_SPE_PAD;
#endif
return 1; return 1;
} }
static int SpeGetAlignment(const unsigned char *buf, size_t len, static int SpeGetAlignment(const unsigned char *buf, size_t len,
struct SpePkt *packet) struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -104,22 +115,28 @@ static int SpeGetAlignment(const unsigned char *buf, size_t len,
packet->type = PERF_SPE_PAD; packet->type = PERF_SPE_PAD;
return alignment - (((uintptr_t)buf) & (alignment - 1)); return alignment - (((uintptr_t)buf) & (alignment - 1));
#else
return 0;
#endif
} }
static int SpeGetEnd(struct SpePkt *packet) static int SpeGetEnd(struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (packet == nullptr) { if (packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
return -1; return -1;
} }
packet->type = PERF_SPE_END; packet->type = PERF_SPE_END;
#endif
return 1; return 1;
} }
static int SpeGetTimestamp(const unsigned char *buf, size_t len, static int SpeGetTimestamp(const unsigned char *buf, size_t len,
struct SpePkt *packet) struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -127,11 +144,15 @@ static int SpeGetTimestamp(const unsigned char *buf, size_t len,
} }
packet->type = PERF_SPE_TIMESTAMP; packet->type = PERF_SPE_TIMESTAMP;
return SpeGetPayload(buf, len, 0, packet); return SpeGetPayload(buf, len, 0, packet);
#else
return 0;
#endif
} }
static int SpeGetEvents(const unsigned char *buf, size_t len, static int SpeGetEvents(const unsigned char *buf, size_t len,
struct SpePkt *packet) struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -140,11 +161,15 @@ static int SpeGetEvents(const unsigned char *buf, size_t len,
packet->type = PERF_SPE_EVENTS; packet->type = PERF_SPE_EVENTS;
packet->index = SpePayloadLen(buf[0]); packet->index = SpePayloadLen(buf[0]);
return SpeGetPayload(buf, len, 0, packet); return SpeGetPayload(buf, len, 0, packet);
#else
return 0;
#endif
} }
static int SpeGetDataSource(const unsigned char *buf, size_t len, static int SpeGetDataSource(const unsigned char *buf, size_t len,
struct SpePkt *packet) struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -152,11 +177,15 @@ static int SpeGetDataSource(const unsigned char *buf, size_t len,
} }
packet->type = PERF_SPE_DATA_SOURCE; packet->type = PERF_SPE_DATA_SOURCE;
return SpeGetPayload(buf, len, 0, packet); return SpeGetPayload(buf, len, 0, packet);
#else
return 0;
#endif
} }
static int SpeGetContext(const unsigned char *buf, size_t len, static int SpeGetContext(const unsigned char *buf, size_t len,
struct SpePkt *packet) struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -165,11 +194,15 @@ static int SpeGetContext(const unsigned char *buf, size_t len,
packet->type = PERF_SPE_CONTEXT; packet->type = PERF_SPE_CONTEXT;
packet->index = PERF_SPE_CTX_PKT_HDR_INDEX(buf[0]); packet->index = PERF_SPE_CTX_PKT_HDR_INDEX(buf[0]);
return SpeGetPayload(buf, len, 0, packet); return SpeGetPayload(buf, len, 0, packet);
#else
return 0;
#endif
} }
static int SpeGetOpType(const unsigned char *buf, size_t len, static int SpeGetOpType(const unsigned char *buf, size_t len,
struct SpePkt *packet) struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -178,11 +211,15 @@ static int SpeGetOpType(const unsigned char *buf, size_t len,
packet->type = PERF_SPE_OP_TYPE; packet->type = PERF_SPE_OP_TYPE;
packet->index = PERF_SPE_OP_PKT_HDR_CLASS(buf[0]); packet->index = PERF_SPE_OP_PKT_HDR_CLASS(buf[0]);
return SpeGetPayload(buf, len, 0, packet); return SpeGetPayload(buf, len, 0, packet);
#else
return 0;
#endif
} }
static int SpeGetCounter(const unsigned char *buf, size_t len, static int SpeGetCounter(const unsigned char *buf, size_t len,
const unsigned char extHdr, struct SpePkt *packet) const unsigned char extHdr, struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -196,11 +233,15 @@ static int SpeGetCounter(const unsigned char *buf, size_t len,
} }
return SpeGetPayload(buf, len, extHdr, packet); return SpeGetPayload(buf, len, extHdr, packet);
#else
return 0;
#endif
} }
static int SpeGetAddr(const unsigned char *buf, size_t len, static int SpeGetAddr(const unsigned char *buf, size_t len,
const unsigned char extHdr, struct SpePkt *packet) const unsigned char extHdr, struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -214,11 +255,15 @@ static int SpeGetAddr(const unsigned char *buf, size_t len,
} }
return SpeGetPayload(buf, len, extHdr, packet); return SpeGetPayload(buf, len, extHdr, packet);
#else
return 0;
#endif
} }
static int SpeDoGetPacket(const unsigned char *buf, size_t len, static int SpeDoGetPacket(const unsigned char *buf, size_t len,
struct SpePkt *packet) struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -276,13 +321,14 @@ static int SpeDoGetPacket(const unsigned char *buf, size_t len,
if ((hdr & PERF_SPE_HEADER0_MASK3) == PERF_SPE_HEADER0_COUNTER) { if ((hdr & PERF_SPE_HEADER0_MASK3) == PERF_SPE_HEADER0_COUNTER) {
return SpeGetCounter(buf, len, extHdr, packet); return SpeGetCounter(buf, len, extHdr, packet);
} }
#endif
return PERF_SPE_BAD_PACKET; return PERF_SPE_BAD_PACKET;
} }
int SpeGetPacket(const unsigned char *buf, size_t len, int SpeGetPacket(const unsigned char *buf, size_t len,
struct SpePkt *packet) struct SpePkt *packet)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -298,11 +344,15 @@ int SpeGetPacket(const unsigned char *buf, size_t len,
} }
} }
return ret; return ret;
#else
return 0;
#endif
} }
static int SpePktOutString(int *err, char **bufPtr, size_t *bufLen, static int SpePktOutString(int *err, char **bufPtr, size_t *bufLen,
const char *fmt, ...) const char *fmt, ...)
{ {
#ifndef UNITTEST
if (*bufPtr == nullptr || bufLen == nullptr || fmt == nullptr) { if (*bufPtr == nullptr || bufLen == nullptr || fmt == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -345,11 +395,15 @@ static int SpePktOutString(int *err, char **bufPtr, size_t *bufLen,
} }
return ret; return ret;
#else
return 0;
#endif
} }
static int SpePktDescEvent(const struct SpePkt *packet, static int SpePktDescEvent(const struct SpePkt *packet,
char *buf, size_t bufLen) char *buf, size_t bufLen)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -403,11 +457,15 @@ static int SpePktDescEvent(const struct SpePkt *packet,
} }
return err; return err;
#else
return 0;
#endif
} }
static int SpePktDescOpType(const struct SpePkt *packet, static int SpePktDescOpType(const struct SpePkt *packet,
char *buf, size_t bufLen) char *buf, size_t bufLen)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -503,11 +561,15 @@ static int SpePktDescOpType(const struct SpePkt *packet,
} }
return err; return err;
#else
return 0;
#endif
} }
static int SpePktDescAddr(const struct SpePkt *packet, static int SpePktDescAddr(const struct SpePkt *packet,
char *buf, size_t bufLen) char *buf, size_t bufLen)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -553,11 +615,15 @@ static int SpePktDescAddr(const struct SpePkt *packet,
} }
return err; return err;
#else
return 0;
#endif
} }
static int SpePktDesCont(const struct SpePkt *packet, static int SpePktDesCont(const struct SpePkt *packet,
char *buf, size_t bufLen) char *buf, size_t bufLen)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -585,11 +651,15 @@ static int SpePktDesCont(const struct SpePkt *packet,
} }
return err; return err;
#else
return 0;
#endif
} }
int SpePktDesc(const struct SpePkt *packet, char *buf, int SpePktDesc(const struct SpePkt *packet, char *buf,
size_t bufLen) size_t bufLen)
{ {
#ifndef UNITTEST
if (buf == nullptr || packet == nullptr) { if (buf == nullptr || packet == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -642,10 +712,14 @@ int SpePktDesc(const struct SpePkt *packet, char *buf,
} }
return err; return err;
#else
return 0;
#endif
} }
static u64 SpeCalcIp(int index, u64 payload) static u64 SpeCalcIp(int index, u64 payload)
{ {
#ifndef UNITTEST
u64 ns; u64 ns;
u64 el; u64 el;
u64 val; u64 val;
@ -701,10 +775,14 @@ static u64 SpeCalcIp(int index, u64 payload)
} }
return payload; return payload;
#else
return 0;
#endif
} }
struct SpeDecoder *SpeDecoderNew(struct SpeParams *params) struct SpeDecoder *SpeDecoderNew(struct SpeParams *params)
{ {
#ifndef UNITTEST
if (params == nullptr) { if (params == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -720,20 +798,26 @@ struct SpeDecoder *SpeDecoderNew(struct SpeParams *params)
decoder->data = params->data; decoder->data = params->data;
return decoder; return decoder;
#else
return nullptr;
#endif
} }
void SpeDecoderFree(struct SpeDecoder *decoder) void SpeDecoderFree(struct SpeDecoder *decoder)
{ {
#ifndef UNITTEST
if (decoder == nullptr) { if (decoder == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
return; return;
} }
free(decoder); free(decoder);
#endif
} }
static int SpeGetNextPacket(struct SpeDecoder *decoder) static int SpeGetNextPacket(struct SpeDecoder *decoder)
{ {
#ifndef UNITTEST
if (decoder == nullptr) { if (decoder == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -761,11 +845,13 @@ static int SpeGetNextPacket(struct SpeDecoder *decoder)
decoder->buf += ret; decoder->buf += ret;
decoder->len -= static_cast<size_t>(ret); decoder->len -= static_cast<size_t>(ret);
} while (decoder->packet.type == PERF_SPE_PAD); } while (decoder->packet.type == PERF_SPE_PAD);
#endif
return 1; return 1;
} }
static int SpeReadRecord(struct SpeDecoder *decoder) static int SpeReadRecord(struct SpeDecoder *decoder)
{ {
#ifndef UNITTEST
u64 payload; u64 payload;
u64 ip; u64 ip;
if (decoder == nullptr) { if (decoder == nullptr) {
@ -889,21 +975,27 @@ static int SpeReadRecord(struct SpeDecoder *decoder)
return -1; return -1;
} }
} }
#endif
return 0; return 0;
} }
int SpeDecode(struct SpeDecoder *decoder) int SpeDecode(struct SpeDecoder *decoder)
{ {
#ifndef UNITTEST
if (decoder == nullptr) { if (decoder == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
return -1; return -1;
} }
return SpeReadRecord(decoder); return SpeReadRecord(decoder);
#else
return 0;
#endif
} }
struct SpeDecoder *SpeDecoderDataNew(const unsigned char *speBuf, size_t speLen) struct SpeDecoder *SpeDecoderDataNew(const unsigned char *speBuf, size_t speLen)
{ {
#ifndef UNITTEST
if (speBuf == nullptr) { if (speBuf == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -921,10 +1013,14 @@ struct SpeDecoder *SpeDecoderDataNew(const unsigned char *speBuf, size_t speLen)
decoder->len = speLen; decoder->len = speLen;
return decoder; return decoder;
#else
return nullptr;
#endif
} }
void SpeDumpRawData(unsigned char *buf, size_t len, int indent, FILE *outputDump) void SpeDumpRawData(unsigned char *buf, size_t len, int indent, FILE *outputDump)
{ {
#ifndef UNITTEST
if (buf == nullptr) { if (buf == nullptr) {
printf("Invalid pointer!\n"); printf("Invalid pointer!\n");
HLOGV("Invalid pointer!"); HLOGV("Invalid pointer!");
@ -972,6 +1068,7 @@ void SpeDumpRawData(unsigned char *buf, size_t len, int indent, FILE *outputDump
break; break;
} }
} }
#endif
} }
std::map<u32, std::map<u64, ReportItemAuxRawData>> AuxRawDataMap_; std::map<u32, std::map<u64, ReportItemAuxRawData>> AuxRawDataMap_;
@ -998,6 +1095,7 @@ constexpr const int SPE_PERCENTAGE_OFFSET_LEN = 20;
void AddReportItems(const std::vector<ReportItemAuxRawData>& auxRawData) void AddReportItems(const std::vector<ReportItemAuxRawData>& auxRawData)
{ {
#ifndef UNITTEST
for (const auto& data : auxRawData) { for (const auto& data : auxRawData) {
for (auto type : DEFAULT_SPE_EVENT_TYPE) { for (auto type : DEFAULT_SPE_EVENT_TYPE) {
if (data.type & type) { if (data.type & type) {
@ -1020,10 +1118,12 @@ void AddReportItems(const std::vector<ReportItemAuxRawData>& auxRawData)
} }
} }
} }
#endif
} }
void UpdateHeating() void UpdateHeating()
{ {
#ifndef UNITTEST
for (auto it = AuxRawDataMap_.begin(); it != AuxRawDataMap_.end(); it++) { for (auto it = AuxRawDataMap_.begin(); it != AuxRawDataMap_.end(); it++) {
u64 cc = typeCount[it->first]; u64 cc = typeCount[it->first];
for (auto& it2 : it->second) { for (auto& it2 : it->second) {
@ -1032,6 +1132,7 @@ void UpdateHeating()
it2.second.heating = heating; it2.second.heating = heating;
} }
} }
#endif
} }
void GetSpeEventNameByType(uint32_t type, std::string& eventName) void GetSpeEventNameByType(uint32_t type, std::string& eventName)
@ -1075,6 +1176,7 @@ void GetSpeEventNameByType(uint32_t type, std::string& eventName)
void DumpSpeReportHead(int indent, uint32_t type, uint64_t count) void DumpSpeReportHead(int indent, uint32_t type, uint64_t count)
{ {
#ifndef UNITTEST
std::string eventName = ""; std::string eventName = "";
GetSpeEventNameByType(type, eventName); GetSpeEventNameByType(type, eventName);
PRINT_INDENT(indent, "\nEvent :%s\n", eventName.c_str()); PRINT_INDENT(indent, "\nEvent :%s\n", eventName.c_str());
@ -1095,11 +1197,13 @@ void DumpSpeReportHead(int indent, uint32_t type, uint64_t count)
PRINT_INDENT(indent, "%-*s", SPE_PERCENTAGE_FUNC_LEN, func.c_str()); PRINT_INDENT(indent, "%-*s", SPE_PERCENTAGE_FUNC_LEN, func.c_str());
const std::string offset = " offset"; const std::string offset = " offset";
PRINT_INDENT(indent, "%-*s\n", SPE_PERCENTAGE_OFFSET_LEN, offset.c_str()); PRINT_INDENT(indent, "%-*s\n", SPE_PERCENTAGE_OFFSET_LEN, offset.c_str());
#endif
return; return;
} }
void DumpSpeReportData(int indent, FILE *outputDump) void DumpSpeReportData(int indent, FILE *outputDump)
{ {
#ifndef UNITTEST
if (outputDump != nullptr) { if (outputDump != nullptr) {
g_outputDump = outputDump; g_outputDump = outputDump;
} }
@ -1120,6 +1224,7 @@ void DumpSpeReportData(int indent, FILE *outputDump)
PRINT_INDENT(indent + 1, "0x%llx\n", it2.second.offset); PRINT_INDENT(indent + 1, "0x%llx\n", it2.second.offset);
} }
} }
#endif
} }
} // namespace HiPerf } // namespace HiPerf
} // namespace Developtools } // namespace Developtools

View File

@ -144,18 +144,6 @@ std::shared_ptr<DfxMap> VirtualThread::FindMapByFileInfo(const std::string name,
return nullptr; return nullptr;
} }
std::shared_ptr<DfxMap> VirtualThread::FindFirstMapByFileInfo(const std::string name) const
{
for (const auto &map : memMaps_) {
if (map == nullptr || name != map->name) {
continue;
}
return map;
}
HLOGM("not found map for %s ", name.c_str());
return nullptr;
}
SymbolsFile *VirtualThread::FindSymbolsFileByMap(std::shared_ptr<DfxMap> map) const SymbolsFile *VirtualThread::FindSymbolsFileByMap(std::shared_ptr<DfxMap> map) const
{ {
if (map == nullptr) { if (map == nullptr) {

View File

@ -102,7 +102,7 @@ ohos_unittest("hiperf_unittest") {
cflags = [ cflags = [
"-Dprivate=public", #allow test code access private members "-Dprivate=public", #allow test code access private members
] ]
cflags += [ "-DUNITTEST" ]
sources = sources_interface sources = sources_interface
sources += sources_base sources += sources_base
if (is_linux) { if (is_linux) {

View File

@ -95,7 +95,6 @@
<option name="push" value="testdata/dwarf.uncompress.data -> /data/test/resource/testdata/" src="res"/> <option name="push" value="testdata/dwarf.uncompress.data -> /data/test/resource/testdata/" src="res"/>
<option name="push" value="testdata/fp.compress.data -> /data/test/resource/testdata/" src="res"/> <option name="push" value="testdata/fp.compress.data -> /data/test/resource/testdata/" src="res"/>
<option name="push" value="testdata/fp.uncompress.data -> /data/test/resource/testdata/" src="res"/> <option name="push" value="testdata/fp.uncompress.data -> /data/test/resource/testdata/" src="res"/>
<option name="push" value="testdata/spe_perf.data -> /data/test/resource/testdata/" src="res"/>
</preparer> </preparer>
</target> </target>
</configuration> </configuration>