diff --git a/OAT.xml b/OAT.xml
index df93cf461d597230239294248542645d1d3754f5..544cf5953651f3960c6f48da5f52690616e1e657 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -98,6 +98,10 @@ Note:If the text contains special characters, please escape them according to th
+
+
+
+
diff --git a/src/elf_file.cpp b/src/elf_file.cpp
index a6a0913ee5795734f45bcae67c90b85a51a9ccd7..0e3edf58a5ecbdfc543e563eccbc8a89ff83019c 100644
--- a/src/elf_file.cpp
+++ b/src/elf_file.cpp
@@ -111,6 +111,7 @@ bool ElfFile::ParseElfHeader()
size_t readsize = ReadFile(ehdrBuf, ehdr64Size);
if (readsize < ehdr64Size) {
HLOGW("file size not enough, try read %zu, only have %zu", ehdr64Size, readsize);
+ return false;
}
HLOG_ASSERT(readsize > 0);
ehdr_ = ElfHeader::MakeUnique(ehdrBuf, readsize);
@@ -289,7 +290,9 @@ bool ElfFile::ParseSymNamesStr()
uint64_t secOffset = shdr->fileOffset_;
uint64_t secSize = shdr->secSize_;
int64_t ret = lseek(fd_, secOffset, SEEK_SET);
- HLOG_ASSERT(ret >= 0);
+ if (ret < 0) {
+ HLOGE("Error in ElfFile::ParsesymNamesStr(): lseek failed");
+ }
char *secBuf = new (std::nothrow) char[secSize];
if (secBuf == nullptr) {
HLOGE("Error in ElfFile::ParsesymNamesStr(): new failed");
diff --git a/src/perf_events.cpp b/src/perf_events.cpp
index 92ed0e5f9318356174bdf0dd5852bcbbd34761c1..e888d08c6be86c8cf5cbde2d22c8c659bb7e8ba4 100644
--- a/src/perf_events.cpp
+++ b/src/perf_events.cpp
@@ -314,7 +314,7 @@ bool PerfEvents::AddEvent(const std::string &eventString, bool followGroup)
}
if (isTracePointEvent) {
- if (PERF_TRACEPOINT_CONFIGS.empty()) {
+ if (traceConfigTable.empty()) {
LoadTracepointEventTypesFromSystem();
}
}
@@ -769,7 +769,7 @@ std::map<__u64, std::string> PerfEvents::GetSupportEvents(perf_type_id type)
void PerfEvents::LoadTracepointEventTypesFromSystem()
{
- if (PERF_TRACEPOINT_CONFIGS.empty()) {
+ if (traceConfigTable.empty()) {
std::string basePath {"/sys/kernel/tracing/events"};
if (access(basePath.c_str(), R_OK) != 0) {
basePath = "/sys/kernel/debug/tracing/events";
diff --git a/src/subcommand_dump.cpp b/src/subcommand_dump.cpp
index c41c02c79dca07beb29d7de7db0c9bfede3870c6..c436bcbb0ee62278a828ecbfc27a31fb90bd9687 100644
--- a/src/subcommand_dump.cpp
+++ b/src/subcommand_dump.cpp
@@ -416,16 +416,17 @@ void SubCommandDump::DumpDataPortion(int indent)
return false;
}
+ // for UT
+ if (exportSampleIndex_ > 0) {
+ ExprotUserData(record);
+ }
+
// tell process tree what happend for rebuild symbols
vr_.UpdateFromRecord(*record);
recordCount++;
record->Dump(indent);
- if (exportSampleIndex_ > 0) {
- ExprotUserData(record);
- }
-
if (record->GetType() == PERF_RECORD_SAMPLE) {
std::unique_ptr sample(
static_cast(record.release()));
diff --git a/src/subcommand_record.cpp b/src/subcommand_record.cpp
index 2a7fdb4a4eaa3a3feda0d0f9fa9f9bd3373b9dc8..c2a84f598b76acbffca087654b28ceb5489f6850 100644
--- a/src/subcommand_record.cpp
+++ b/src/subcommand_record.cpp
@@ -47,7 +47,8 @@ const std::string CONTROL_CMD_STOP = "stop";
const std::string CONTROL_FIFO_FILE_C2S = "/data/local/tmp/.hiperf_record_control_c2s";
const std::string CONTROL_FIFO_FILE_S2C = "/data/local/tmp/.hiperf_record_control_s2c";
-const std::chrono::milliseconds CONTROL_WAITREPY_TOMEOUT = 1000ms;
+// when there are many events, start record will take more time.
+const std::chrono::milliseconds CONTROL_WAITREPY_TOMEOUT = 2000ms;
constexpr uint64_t MASK_ALIGNED_8 = 7;
constexpr size_t MAX_DWARF_CALL_CHAIN = 2;
@@ -463,7 +464,7 @@ bool SubCommandRecord::CheckTargetPids()
for (auto pid : selectPids_) {
auto tids = GetSubthreadIDs(pid);
if (!tids.empty()) {
- selectPids_.insert(selectPids_.end(), tids.begin(), tids.end());
+ selectTids_.insert(selectTids_.end(), tids.begin(), tids.end());
}
}
}
diff --git a/src/subcommand_report.cpp b/src/subcommand_report.cpp
index 6cad7ba85eb8bf05654a75f3e896c579a0ea06e7..d3fe337eac24ea61de8b6779b54f828004a713a4 100644
--- a/src/subcommand_report.cpp
+++ b/src/subcommand_report.cpp
@@ -158,6 +158,10 @@ bool SubCommandReport::VerifyOption()
printf("head limit error. must in (0 <= limit < 100).\n");
return false;
}
+ if (recordFile_[FIRST].empty()) {
+ printf("input file name can't be empty\n");
+ return false;
+ }
if (!recordFile_[SECOND].empty()) {
if (protobufFormat_ or jsonFormat_ or showCallStack_) {
printf("diff don't support any export mode(like json , flame or proto)\n");
diff --git a/test/unittest/common/native/callstack_test.cpp b/test/unittest/common/native/callstack_test.cpp
index 03a382a93188327294ffd9c4b84235e6b7ba849c..ee7fdd7f9a915c5b79c3114c2268870e786a8ee3 100644
--- a/test/unittest/common/native/callstack_test.cpp
+++ b/test/unittest/common/native/callstack_test.cpp
@@ -638,8 +638,6 @@ HWTEST_F(CallStackTest, ExpendCallStackABABAB, TestSize.Level1)
ASSERT_EQ(callStack.ExpandCallStack(0, stack4), 5u);
}
-#if defined(__LP64__)
-#else
/**
* @tc.name: UnwindCallStack
* @tc.desc:
@@ -661,7 +659,8 @@ HWTEST_F(CallStackTest, UnwindCallStack, TestSize.Level1)
#endif
std::vector> symbolsFiles;
auto &symbolsFile = symbolsFiles.emplace_back(SymbolsFile::CreateSymbolsFile(
- SYMBOL_ELF_FILE, PATH_RESOURCE_TEST_DWARF_DATA + TEST_DWARF_ELF));
+ SYMBOL_ELF_FILE, TEST_DWARF_ELF));
+ ASSERT_EQ(symbolsFile->setSymbolsFilePath(PATH_RESOURCE_TEST_DWARF_DATA), true);
ASSERT_EQ(symbolsFile->LoadSymbols(), true);
// fix the name
symbolsFile->filePath_ = TEST_DWARF_MMAP.front().fileName;
@@ -681,7 +680,6 @@ HWTEST_F(CallStackTest, UnwindCallStack, TestSize.Level1)
}
}
}
-#endif
} // namespace HiPerf
} // namespace Developtools
} // namespace OHOS
diff --git a/test/unittest/common/native/hiperf_libreport_test.cpp b/test/unittest/common/native/hiperf_libreport_test.cpp
index 369a94b4a663df07ae5782c7977873a0cdbcc5e4..d285d8c843b4c29669ab97579a93b498797bb755 100644
--- a/test/unittest/common/native/hiperf_libreport_test.cpp
+++ b/test/unittest/common/native/hiperf_libreport_test.cpp
@@ -29,14 +29,19 @@ namespace Developtools {
namespace HiPerf {
constexpr const char *PERF_DATA_INPUT_PATH =
"/data/test/resource/testdata/report/perf.data.libreport";
+#ifdef __arm__
constexpr const char *PERF_DISABLE_UNWIND_DATA_INPUT_PATH =
"/data/test/resource/testdata/report/perf.disable.unwind.hiperf_example_cmd.data";
+#else
+constexpr const char *PERF_DISABLE_UNWIND_DATA_INPUT_PATH =
+ "/data/test/resource/testdata/report/perf.disable.unwind.hiperf_example_cmd_64.data";
+#endif
constexpr const char *PERF_DISABLE_UNWIND_SYMBOL_INPUT_PATH = "/data/test/resource/testdata/report";
constexpr const char *PERF_DATA_ERROR_FORMAT_INPUT_PATH =
"/data/test/resource/testdata/report/perf.data.error.format.libreport";
-constexpr const char *REPORT_OUTPUT_PATH = "/data/local/tmp/report.txt";
-constexpr const char *REPORT_JSON_OUTPUT_PATH = "/data/local/tmp/perf.json";
-constexpr const char *REPORT_PROTO_OUTPUT_PATH = "/data/local/tmp/perf.proto";
+constexpr const char *REPORT_OUTPUT_PATH = "./report.txt";
+constexpr const char *REPORT_JSON_OUTPUT_PATH = "./perf.json";
+constexpr const char *REPORT_PROTO_OUTPUT_PATH = "./perf.proto";
constexpr const char *ILLEGAL_PATH = "/proc/illegal";
constexpr const char *TEST_ELF32 = "/data/test/resource/testdata/report/buildid_test_elf_32";
@@ -126,9 +131,13 @@ void HiperfLibReportTest::UnwindJsonContentCheck(const std::string &content, boo
ASSERT_TRUE(content.size() >= 2);
ASSERT_EQ(content.front(), '{');
ASSERT_EQ(content.back(), '}');
- // CallStack10(int, Option const&) will count nothing in disable unwind
+#ifdef __arm__
ASSERT_EQ(content.find("{\"symbol\":8,\"counts\":[0,0,797933]}") != std::string::npos,
haveUnwind);
+#else
+ ASSERT_EQ(content.find("{\"symbol\":16,\"counts\":[24,9065269,16850264]}") != std::string::npos,
+ haveUnwind);
+#endif
}
void HiperfLibReportTest::DefaultReportContentCheck(const std::string &content) const
@@ -467,8 +476,6 @@ HWTEST_F(HiperfLibReportTest, Test_ReportGetBuildId_IllegalPath, TestSize.Level1
EXPECT_STREQ(result, "");
}
-#if defined(__LP64__)
-#else
HWTEST_F(HiperfLibReportTest, Test_ReportUnwindJson_Success, TestSize.Level1)
{
unlink(REPORT_JSON_OUTPUT_PATH);
@@ -482,7 +489,6 @@ HWTEST_F(HiperfLibReportTest, Test_ReportUnwindJson_Success, TestSize.Level1)
EXPECT_EQ(ReadFileToString(REPORT_JSON_OUTPUT_PATH, content), true);
UnwindJsonContentCheck(content, true);
}
-#endif
HWTEST_F(HiperfLibReportTest, Test_ReportUnwindJson_NoSymbols_Failed, TestSize.Level1)
{
diff --git a/test/unittest/common/native/include/callstack_test.h b/test/unittest/common/native/include/callstack_test.h
index 429a5c10a85cb35e1844e14e59384b16cc50c0e8..01414c380837465cf0675f5823398eadaffbf70c 100644
--- a/test/unittest/common/native/include/callstack_test.h
+++ b/test/unittest/common/native/include/callstack_test.h
@@ -32,21 +32,24 @@ namespace OHOS {
namespace Developtools {
namespace HiPerf {
static const std::string PATH_RESOURCE_TEST_DWARF_DATA = "resource/testdata/dwarf/";
-/*
- create from
- ./hiperf_example_cmd --thread 1 --time 60 --stack 10
- ./hiperf_host dump --userdata > dump.txt
-*/
-static const std::string TEST_DWARF_ELF = "hiperf_example_cmd";
-static const std::string TEST_DWARF_USER_REGS_0 = "user_regs.dump";
-static const std::string TEST_DWARF_USER_DATA_0 = "user_data.dump";
-
struct mmapDumpInfo {
std::string fileName;
uint64_t begin = 0;
uint64_t len = 0;
uint64_t pgoff = 0;
};
+
+struct frame {
+ uint64_t ip = 0;
+ uint64_t sp = 0;
+};
+/*
+ create from
+ ./hiperf_example_cmd --thread 1 --time 60 --stack 10
+ ./hiperf_host dump --userdata > dump.txt
+*/
+#ifdef __arm__
+static const std::string TEST_DWARF_ELF = "hiperf_example_cmd";
/*
record mmap2: type 10, misc 2, size 107
pid 643, tid 643, addr 0x454000, len 0x3000
@@ -69,13 +72,13 @@ record mmap2: type 10, misc 2, size 107
prot 3, flags 2, filename /data/local/tmp/hiperf_example_cmd
*/
static const std::vector TEST_DWARF_MMAP = {
- {"/data/local/tmp/hiperf_example_cmd", 0x454000, 0x3000, 0x0},
- {"/data/local/tmp/hiperf_example_cmd", 0x457000, 0x5000, 0x2000},
- {"/data/local/tmp/hiperf_example_cmd", 0x45c000, 0x1000, 0x6000},
- {"/data/local/tmp/hiperf_example_cmd", 0x45d000, 0x1000, 0x6000},
-
+ {"hiperf_example_cmd", 0x454000, 0x3000, 0x0},
+ {"hiperf_example_cmd", 0x457000, 0x5000, 0x2000},
+ {"hiperf_example_cmd", 0x45c000, 0x1000, 0x6000},
+ {"hiperf_example_cmd", 0x45d000, 0x1000, 0x6000},
};
-
+static const std::string TEST_DWARF_USER_REGS_0 = "user_regs.dump";
+static const std::string TEST_DWARF_USER_DATA_0 = "user_data.dump";
/*
UnwindStep:unwind:0: ip 0x45765e sp 0xb6ca1c68
UnwindStep:unwind:1: ip 0x45768a sp 0xb6ca1c78
@@ -92,10 +95,6 @@ UnwindStep:unwind:11: ip 0x45793c sp 0xb6ca1d18
UnwindStep:unwind:12: ip 0x457ffe sp 0xb6ca1d28
UnwindStep:unwind:13: ip 0xb6f01f73 sp 0xb6ca1d38
*/
-struct frame {
- uint64_t ip = 0;
- uint64_t sp = 0;
-};
static const std::vector TEST_DWARF_FRAMES = {
{0x4575BC, 0xB6CA1C18}, // base ip sp
{0x45765e, 0xb6ca1c68}, {0x45768a, 0xb6ca1c78}, {0x4576ce, 0xb6ca1c88},
@@ -104,6 +103,57 @@ static const std::vector TEST_DWARF_FRAMES = {
{0x4578aa, 0xb6ca1cf8}, {0x4578ee, 0xb6ca1d08}, {0x45793c, 0xb6ca1d18},
{0x457ffe, 0xb6ca1d28}, {0xb6f01f73, 0xb6ca1d38},
};
+#else
+static const std::string TEST_DWARF_ELF = "hiperf_example_cmd_64";
+/*
+record mmap2: type 10, misc 2, size 110
+ pid 24925, tid 24925, addr 0x5591ef4000, len 0x3000
+ pgoff 0x0, maj 179, min 11, ino 2495283, ino_generation 0
+ prot 1, flags 2, filename /data/local/tmp/hiperf_example_cmd_64
+
+record mmap2: type 10, misc 2, size 110
+ pid 24925, tid 24925, addr 0x5591ef7000, len 0x3000
+ pgoff 0x2000, maj 179, min 11, ino 2495283, ino_generation 0
+ prot 5, flags 2, filename /data/local/tmp/hiperf_example_cmd_64
+
+record mmap2: type 10, misc 2, size 110
+ pid 24925, tid 24925, addr 0x5591efa000, len 0x1000
+ pgoff 0x4000, maj 179, min 11, ino 2495283, ino_generation 0
+ prot 1, flags 2, filename /data/local/tmp/hiperf_example_cmd_64
+*/
+static const std::vector TEST_DWARF_MMAP = {
+ {"hiperf_example_cmd_64", 0x5591ef4000, 0x3000, 0x0},
+ {"hiperf_example_cmd_64", 0x5591ef7000, 0x3000, 0x2000},
+ {"hiperf_example_cmd_64", 0x5591efa000, 0x1000, 0x4000},
+};
+static const std::string TEST_DWARF_USER_REGS_0 = "user_regs_64.dump";
+static const std::string TEST_DWARF_USER_DATA_0 = "user_data_64.dump";
+/*
+UnwindStep:unwind:0: ip 0x5591ef772c sp 0x7f9aec76f0
+UnwindStep:unwind:1: ip 0x5591ef78cb sp 0x7f9aec77b0
+UnwindStep:unwind:2: ip 0x5591ef798f sp 0x7f9aec77e0
+UnwindStep:unwind:3: ip 0x5591ef7a4f sp 0x7f9aec7820
+UnwindStep:unwind:4: ip 0x5591ef7b0f sp 0x7f9aec7860
+UnwindStep:unwind:5: ip 0x5591ef7bcf sp 0x7f9aec78a0
+UnwindStep:unwind:6: ip 0x5591ef7c8f sp 0x7f9aec78e0
+UnwindStep:unwind:7: ip 0x5591ef7d4f sp 0x7f9aec7920
+UnwindStep:unwind:8: ip 0x5591ef7e0f sp 0x7f9aec7960
+UnwindStep:unwind:9: ip 0x5591ef7ecf sp 0x7f9aec79a0
+UnwindStep:unwind:10: ip 0x5591ef7f8f sp 0x7f9aec79e0
+UnwindStep:unwind:11: ip 0x5591ef804f sp 0x7f9aec7a20
+UnwindStep:unwind:12: ip 0x5591ef80e7 sp 0x7f9aec7a60
+UnwindStep:unwind:13: ip 0x5591ef95db sp 0x7f9aec7a80
+UnwindStep:unwind:14: ip 0x7f9b0fa59b sp 0x7f9aec7aa0
+*/
+static const std::vector TEST_DWARF_FRAMES = {
+ {0x5591ef772c, 0x7f9aec76f0}, // base ip sp
+ {0x5591ef78cb, 0x7f9aec77b0}, {0x5591ef798f, 0x7f9aec77e0}, {0x5591ef7a4f, 0x7f9aec7820},
+ {0x5591ef7b0f, 0x7f9aec7860}, {0x5591ef7bcf, 0x7f9aec78a0}, {0x5591ef7c8f, 0x7f9aec78e0},
+ {0x5591ef7d4f, 0x7f9aec7920}, {0x5591ef7e0f, 0x7f9aec7960}, {0x5591ef7ecf, 0x7f9aec79a0},
+ {0x5591ef7f8f, 0x7f9aec79e0}, {0x5591ef804f, 0x7f9aec7a20}, {0x5591ef80e7, 0x7f9aec7a60},
+ {0x5591ef95db, 0x7f9aec7a80}, {0x7f9b0fa59b, 0x7f9aec7aa0},
+};
+#endif
// data convert funcion
template
@@ -124,15 +174,12 @@ void LoadFromFile(const std::string &fileName, std::vector &data)
}
}
-#if defined(__LP64__)
-#else
static void MakeMaps(VirtualThread &thread)
{
for (const mmapDumpInfo &mmap : TEST_DWARF_MMAP) {
thread.CreateMapItem(mmap.fileName, mmap.begin, mmap.len, mmap.pgoff);
}
}
-#endif
} // namespace HiPerf
} // namespace Developtools
} // namespace OHOS
diff --git a/test/unittest/common/native/include/virtual_runtime_test.h b/test/unittest/common/native/include/virtual_runtime_test.h
index 4503870df58de0e111f348bce1fd83d078a10721..42e82a6e84ed8b673ea88a41137a01acf6472055 100644
--- a/test/unittest/common/native/include/virtual_runtime_test.h
+++ b/test/unittest/common/native/include/virtual_runtime_test.h
@@ -24,6 +24,7 @@
namespace OHOS {
namespace Developtools {
namespace HiPerf {
+#ifdef __arm__
static const std::string TEST_DWARF_RECORD = "hiperf_643_644_sample_record_213_6754913387560.dump";
constexpr const pid_t TEST_DWARF_RECORD_PID = 643;
constexpr const pid_t TEST_DWARF_RECORD_TID = 644;
@@ -48,7 +49,6 @@ constexpr const pid_t TEST_DWARF_RECORD_TID = 644;
(15/16)unwind symbol: va: 0x000000000005506c::__aeabi_read_tp
(16/16)unwind symbol: va: 0x000000000005506c::__aeabi_read_tp
*/
-constexpr const size_t TEST_DWARF_RECORD_STACK_SIZE = 8192u;
static const std::vector> TEST_RECORD_CALLSTACK_IP_FUNC = {
{0x0000000000003539, "LoopFunction(int)"}, // base ip sp
{0x0000000000003645, "CallStack10(int, int)"}, {0x0000000000003671, "CallStack9(int, int)"},
@@ -75,8 +75,67 @@ static const std::vector> TEST_RECORD_CALLSTACK
sample_regs_user 0xffff
sample_stack_user 0x2000
*/
-constexpr const uint64_t TEST_RECORD_SAMPLE_TYPE = 0x133e7;
constexpr const size_t TEST_DWARF_RECORD_REGS_USER = 0xffff;
+constexpr const size_t TEST_DWARF_RECORD_STACK_SIZE = 8192u;
+#else
+static const std::string TEST_DWARF_RECORD = "hiperf_24925_24926_sample_record_118_539229856336150.dump";
+constexpr const pid_t TEST_DWARF_RECORD_PID = 24925;
+constexpr const pid_t TEST_DWARF_RECORD_TID = 24926;
+/*
+ SAMPLE: id= 129404 size 2672 pid 24925 tid 24926 ips 0 regs 33, stacks 2272 time 539229856336150
+ va: 0x0000000000003558 : (anonymous namespace)::LoopFunction(std::__h::chrono::duration >, (anonymous namespace)::Option const&)
+ va: 0x0000000000003884 : (anonymous namespace)::CallStack10(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003924 : (anonymous namespace)::CallStack9(int, (anonymous namespace)::Option const&)
+ va: 0x00000000000039e4 : (anonymous namespace)::CallStack8(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003aa4 : (anonymous namespace)::CallStack7(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003b64 : (anonymous namespace)::CallStack6(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003c24 : (anonymous namespace)::CallStack5(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003ce4 : (anonymous namespace)::CallStack4(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003da4 : (anonymous namespace)::CallStack3(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003e64 : (anonymous namespace)::CallStack2(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003f24 : (anonymous namespace)::CallStack1(int, (anonymous namespace)::Option const&)
+ va: 0x0000000000003fe4 : (anonymous namespace)::CallStack0(int, (anonymous namespace)::Option const&)
+ va: 0x00000000000040a4 : (anonymous namespace)::ExampleThread((anonymous namespace)::Option const&)
+
+*/
+static const std::vector> TEST_RECORD_CALLSTACK_IP_FUNC = {
+ {0x0000000000003558, "(anonymous namespace)::LoopFunction(std::__h::chrono::duration >, (anonymous namespace)::Option const&)"},
+ {0x0000000000003884, "(anonymous namespace)::CallStack10(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003924, "(anonymous namespace)::CallStack9(int, (anonymous namespace)::Option const&)"},
+ {0x00000000000039e4, "(anonymous namespace)::CallStack8(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003aa4, "(anonymous namespace)::CallStack7(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003b64, "(anonymous namespace)::CallStack6(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003c24, "(anonymous namespace)::CallStack5(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003ce4, "(anonymous namespace)::CallStack4(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003da4, "(anonymous namespace)::CallStack3(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003e64, "(anonymous namespace)::CallStack2(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003f24, "(anonymous namespace)::CallStack1(int, (anonymous namespace)::Option const&)"},
+ {0x0000000000003fe4, "(anonymous namespace)::CallStack0(int, (anonymous namespace)::Option const&)"},
+ {0x00000000000040a4, "(anonymous namespace)::ExampleThread((anonymous namespace)::Option const&)"},
+};
+/*
+ event_attr:
+ type 1, size 120, config 0
+ sample_freq 4000
+ sample_type (0x133e7)
+ read_format (0x7)
+ disabled 1, inherit 1, pinned 0, exclusive 0
+ exclude_user 0, exclude_kernel 0, exclude_hv 0, exclude_idle 0
+ mmap 1, mmap2 1, comm 1, comm_exec 0, freq 1
+ inherit_stat 0, enable_on_exec 0, task 0, use_clockid 0
+ watermark 0, precise_ip 0, mmap_data 0, clockid 0
+ sample_id_all 0, exclude_host 0, exclude_guest 0
+ branch_sample_type 0x0
+ exclude_callchain_kernel 0, exclude_callchain_user 1
+ sample_regs_user 0x1ffffffff
+ sample_stack_user 0x2000
+*/
+constexpr const size_t TEST_DWARF_RECORD_REGS_USER = 0x1ffffffff;
+constexpr const size_t TEST_DWARF_RECORD_STACK_SIZE = 2304u;
+#endif
+constexpr const uint64_t TEST_RECORD_SAMPLE_TYPE = 0x133e7;
} // namespace HiPerf
} // namespace Developtools
} // namespace OHOS
diff --git a/test/unittest/common/native/symbols_file_test.cpp b/test/unittest/common/native/symbols_file_test.cpp
index 3ddec0bfe3cf3572c9375201570667935eb6bdd6..4e95137c08e0c537c40ed82300185dea83a43902 100644
--- a/test/unittest/common/native/symbols_file_test.cpp
+++ b/test/unittest/common/native/symbols_file_test.cpp
@@ -308,8 +308,6 @@ HWTEST_F(SymbolsFileTest, LoadKernelSymbols, TestSize.Level1)
EXPECT_EQ(TestLoadSymbols(SYMBOL_KERNEL_FILE, TEST_FILE_VMLINUX_STRIPPED_BROKEN), true);
}
-#if defined(__LP64__)
-#else
/**
* @tc.name: LoaderElfSymbols
* @tc.desc:
@@ -350,7 +348,6 @@ HWTEST_F(SymbolsFileTest, LoadElfSymbols, TestSize.Level1)
EXPECT_EQ(TestLoadSymbols(SYMBOL_ELF_FILE, TEST_FILE_ELF_STRIPPED_BROKEN), false);
}
-#endif
/**
* @tc.name: GetSymbolWithVaddr
@@ -717,8 +714,6 @@ struct sectionInfo {
uint64_t offset;
};
-#if defined(__LP64__)
-#else
/**
* @tc.name: GetSectionInfo
* @tc.desc:
@@ -729,6 +724,7 @@ HWTEST_F(SymbolsFileTest, GetSectionInfo, TestSize.Level1)
std::unique_ptr symbolsFile =
SymbolsFile::CreateSymbolsFile(SYMBOL_ELF_FILE, TEST_FILE_ELF_FULL_PATH);
ASSERT_EQ(symbolsFile->LoadDebugInfo(), true);
+ ASSERT_EQ(symbolsFile->LoadSymbols(), true);
/*
from readelf -e elf32_test
@@ -803,11 +799,8 @@ HWTEST_F(SymbolsFileTest, GetSectionInfo, TestSize.Level1)
}
}
}
-#endif
#ifndef __arm__
-#if defined(__LP64__)
-#else
/**
* @tc.name: GetHDRSectionInfo
* @tc.desc:
@@ -820,6 +813,7 @@ HWTEST_F(SymbolsFileTest, GetHDRSectionInfo, TestSize.Level1)
const constexpr unsigned int fdeTableItemSize = 8;
ASSERT_EQ(symbolsFile->LoadSymbols(), true);
+ ASSERT_EQ(symbolsFile->LoadDebugInfo(), true);
uint64_t ehFrameHdrElfOffset;
uint64_t fdeTableElfOffset;
@@ -843,7 +837,6 @@ HWTEST_F(SymbolsFileTest, GetHDRSectionInfo, TestSize.Level1)
EXPECT_EQ(ehFrameHdrElfOffset, 0x00003034u);
EXPECT_EQ(fdeTableSize, 22U * fdeTableItemSize);
}
-#endif
/**
* @tc.name: GetHDRSectionInfo
diff --git a/test/unittest/common/native/virtual_runtime_test.cpp b/test/unittest/common/native/virtual_runtime_test.cpp
index e22c0012552184369d6a09834fb1249320cb2abc..f4284f0e157127cdfdb1cb0b9757de7d0888c541 100644
--- a/test/unittest/common/native/virtual_runtime_test.cpp
+++ b/test/unittest/common/native/virtual_runtime_test.cpp
@@ -326,8 +326,6 @@ HWTEST_F(VirtualRuntimeTest, UpdateFromPerfData, TestSize.Level1)
ASSERT_EQ(runtime_->GetSymbolsFiles().front()->GetSymbols().size(), 2u);
}
-#if defined(__LP64__)
-#else
/**
* @tc.name: UnwindFromRecord
* @tc.desc:
@@ -337,9 +335,10 @@ HWTEST_F(VirtualRuntimeTest, UnwindFromRecord, TestSize.Level1)
{
// symbol
auto &symbolsFile = runtime_->symbolsFiles_.emplace_back(
- SymbolsFile::CreateSymbolsFile(SYMBOL_ELF_FILE, TEST_DWARF_MMAP.front().fileName));
- ASSERT_EQ(symbolsFile->LoadSymbols(PATH_RESOURCE_TEST_DWARF_DATA + TEST_DWARF_ELF), true);
- symbolsFile->filePath_ = TEST_DWARF_MMAP.front().fileName;
+ SymbolsFile::CreateSymbolsFile(SYMBOL_ELF_FILE, TEST_DWARF_ELF));
+ ASSERT_EQ(symbolsFile->setSymbolsFilePath(PATH_RESOURCE_TEST_DWARF_DATA), true);
+ ASSERT_EQ(symbolsFile->LoadSymbols(TEST_DWARF_ELF), true);
+ symbolsFile->filePath_ = TEST_DWARF_ELF;
// thread
VirtualThread &thread = runtime_->GetThread(TEST_DWARF_RECORD_PID, TEST_DWARF_RECORD_TID);
@@ -369,7 +368,6 @@ HWTEST_F(VirtualRuntimeTest, UnwindFromRecord, TestSize.Level1)
sample.callFrames_[i].symbolName_.data());
}
}
-#endif
} // namespace HiPerf
} // namespace Developtools
} // namespace OHOS
diff --git a/test/unittest/resource/ohos_test.xml b/test/unittest/resource/ohos_test.xml
index 217e1000b0287c0580bfd7c3c91edd8b2dd64c8a..2b2a5833d94a5df66fdfb34132a12ff1261f6eea 100644
--- a/test/unittest/resource/ohos_test.xml
+++ b/test/unittest/resource/ohos_test.xml
@@ -57,6 +57,10 @@
+
+
+
+
@@ -68,7 +72,9 @@
+
+
diff --git a/test/unittest/resource/testdata/dwarf/hiperf_24925_24926_sample_record_118_539229856336150.dump b/test/unittest/resource/testdata/dwarf/hiperf_24925_24926_sample_record_118_539229856336150.dump
new file mode 100755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/test/unittest/resource/testdata/dwarf/hiperf_example_cmd_64 b/test/unittest/resource/testdata/dwarf/hiperf_example_cmd_64
new file mode 100755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/test/unittest/resource/testdata/dwarf/user_data_64.dump b/test/unittest/resource/testdata/dwarf/user_data_64.dump
new file mode 100755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/test/unittest/resource/testdata/dwarf/user_regs_64.dump b/test/unittest/resource/testdata/dwarf/user_regs_64.dump
new file mode 100755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/test/unittest/resource/testdata/report/hiperf_example_cmd_64 b/test/unittest/resource/testdata/report/hiperf_example_cmd_64
new file mode 100755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/test/unittest/resource/testdata/report/perf.disable.unwind.hiperf_example_cmd_64.data b/test/unittest/resource/testdata/report/perf.disable.unwind.hiperf_example_cmd_64.data
new file mode 100755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391