• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef HIPERF_VIRTUAL_RUNTIME_TEST_H
16 #define HIPERF_VIRTUAL_RUNTIME_TEST_H
17 
18 #include "callstack_test.h"
19 #include "debug_logger.h"
20 #include "utilities.h"
21 #include "virtual_runtime.h"
22 #include "virtual_thread.h"
23 
24 namespace OHOS {
25 namespace Developtools {
26 namespace HiPerf {
27 #ifdef __arm__
28 static const std::string TEST_DWARF_RECORD = "hiperf_643_644_sample_record_213_6754913387560.dump";
29 constexpr const pid_t TEST_DWARF_RECORD_PID = 643;
30 constexpr const pid_t TEST_DWARF_RECORD_TID = 644;
31 /*
32  SAMPLE: id= 72 size 8424 pid 643 tid 644 ip nr 0 reg nr 16, stacks 8192 time 6754913387560
33  (1/16)unwind symbol:  va: 0x0000000000003539::LoopFunction(int)
34  (2/16)unwind symbol:   va: 0x0000000000003645::CallStack10(int, int)
35  (3/16)unwind symbol:    va: 0x0000000000003671::CallStack9(int, int)
36  (4/16)unwind symbol:     va: 0x00000000000036b5::CallStack8(int, int)
37  (5/16)unwind symbol:      va: 0x00000000000036f9::CallStack7(int, int)
38  (6/16)unwind symbol:       va: 0x000000000000373d::CallStack6(int, int)
39  (7/16)unwind symbol:        va: 0x0000000000003781::CallStack5(int, int)
40  (8/16)unwind symbol:         va: 0x00000000000037c5::CallStack4(int, int)
41  (9/16)unwind symbol:          va: 0x0000000000003809::CallStack3(int, int)
42  (10/16)unwind symbol:           va: 0x000000000000384d::CallStack2(int, int)
43  (11/16)unwind symbol:            va: 0x0000000000003891::CallStack1(int, int)
44  (12/16)unwind symbol:             va: 0x00000000000038d5::CallStack0(int, int)
45  (13/16)unwind symbol:              va: 0x0000000000003919::ExampleThread(int, int)
46  (14/16)unwind symbol:               va: 0x0000000000003fe3::void*
47  std::__h::__thread_proxy<std::__h::tuple<std::__h::unique_ptr<std::__h::__thread_struct,
48  std::__h::default_delete<std::__h::__thread_struct> >, void (*)(int, int), int, int> >(void*)
49  (15/16)unwind symbol:                va: 0x000000000005506c::__aeabi_read_tp
50  (16/16)unwind symbol:                 va: 0x000000000005506c::__aeabi_read_tp
51 */
52 static const std::vector<std::pair<uint64_t, std::string>> TEST_RECORD_CALLSTACK_IP_FUNC = {
53     {0x0000000000003539, "LoopFunction(int)"}, // base ip sp
54     {0x0000000000003645, "CallStack10(int, int)"}, {0x0000000000003671, "CallStack9(int, int)"},
55     {0x00000000000036b5, "CallStack8(int, int)"},  {0x00000000000036f9, "CallStack7(int, int)"},
56     {0x000000000000373d, "CallStack6(int, int)"},  {0x0000000000003781, "CallStack5(int, int)"},
57     {0x00000000000037c5, "CallStack4(int, int)"},  {0x0000000000003809, "CallStack3(int, int)"},
58     {0x000000000000384d, "CallStack2(int, int)"},  {0x0000000000003891, "CallStack1(int, int)"},
59     {0x00000000000038d5, "CallStack0(int, int)"},  {0x0000000000003919, "ExampleThread(int, int)"},
60 };
61 /*
62   event_attr:
63     type 1, size 120, config 0
64     sample_freq 4000
65     sample_type (0x133e7)
66     read_format (0x7)
67     disabled 1, inherit 1, pinned 0, exclusive 0
68     exclude_user 0, exclude_kernel 0, exclude_hv 0, exclude_idle 0
69     mmap 1, mmap2 1, comm 1, comm_exec 0, freq 1
70     inherit_stat 0, enable_on_exec 0, task 0, use_clockid 0
71     watermark 0, precise_ip 0, mmap_data 0, clockid 0
72     sample_id_all 0, exclude_host 0, exclude_guest 0
73     branch_sample_type 0x0
74     exclude_callchain_kernel 0, exclude_callchain_user 1
75     sample_regs_user 0xffff
76     sample_stack_user 0x2000
77 */
78 constexpr const size_t TEST_DWARF_RECORD_REGS_USER = 0xffff;
79 constexpr const size_t TEST_DWARF_RECORD_STACK_SIZE = 8192u;
80 #else
81 static const std::string TEST_DWARF_RECORD = "hiperf_24925_24926_sample_record_118_539229856336150.dump";
82 constexpr const pid_t TEST_DWARF_RECORD_PID = 24925;
83 constexpr const pid_t TEST_DWARF_RECORD_TID = 24926;
84 /*
85  SAMPLE: id= 129404 size 2672 pid 24925 tid 24926 ips 0 regs 33, stacks 2272 time 539229856336150
86   va: 0x0000000000003558 : (anonymous namespace)::LoopFunction(std::__h::chrono::duration<long long,
87                             std::__h::ratio<1l, 1000l> >, (anonymous namespace)::Option const&)
88   va: 0x0000000000003884 : (anonymous namespace)::CallStack10(int, (anonymous namespace)::Option const&)
89   va: 0x0000000000003924 : (anonymous namespace)::CallStack9(int, (anonymous namespace)::Option const&)
90   va: 0x00000000000039e4 : (anonymous namespace)::CallStack8(int, (anonymous namespace)::Option const&)
91   va: 0x0000000000003aa4 : (anonymous namespace)::CallStack7(int, (anonymous namespace)::Option const&)
92   va: 0x0000000000003b64 : (anonymous namespace)::CallStack6(int, (anonymous namespace)::Option const&)
93   va: 0x0000000000003c24 : (anonymous namespace)::CallStack5(int, (anonymous namespace)::Option const&)
94   va: 0x0000000000003ce4 : (anonymous namespace)::CallStack4(int, (anonymous namespace)::Option const&)
95   va: 0x0000000000003da4 : (anonymous namespace)::CallStack3(int, (anonymous namespace)::Option const&)
96   va: 0x0000000000003e64 : (anonymous namespace)::CallStack2(int, (anonymous namespace)::Option const&)
97   va: 0x0000000000003f24 : (anonymous namespace)::CallStack1(int, (anonymous namespace)::Option const&)
98   va: 0x0000000000003fe4 : (anonymous namespace)::CallStack0(int, (anonymous namespace)::Option const&)
99   va: 0x00000000000040a4 : (anonymous namespace)::ExampleThread((anonymous namespace)::Option const&)
100 
101 */
102 static const std::vector<std::pair<uint64_t, std::string>> TEST_RECORD_CALLSTACK_IP_FUNC = {
103     {0x0000000000003558, "(anonymous namespace)::LoopFunction(std::__h::chrono::duration<long long,"
104                          " std::__h::ratio<1l, 1000l> >, (anonymous namespace)::Option const&)"},
105     {0x0000000000003884, "(anonymous namespace)::CallStack10(int, (anonymous namespace)::Option const&)"},
106     {0x0000000000003924, "(anonymous namespace)::CallStack9(int, (anonymous namespace)::Option const&)"},
107     {0x00000000000039e4, "(anonymous namespace)::CallStack8(int, (anonymous namespace)::Option const&)"},
108     {0x0000000000003aa4, "(anonymous namespace)::CallStack7(int, (anonymous namespace)::Option const&)"},
109     {0x0000000000003b64, "(anonymous namespace)::CallStack6(int, (anonymous namespace)::Option const&)"},
110     {0x0000000000003c24, "(anonymous namespace)::CallStack5(int, (anonymous namespace)::Option const&)"},
111     {0x0000000000003ce4, "(anonymous namespace)::CallStack4(int, (anonymous namespace)::Option const&)"},
112     {0x0000000000003da4, "(anonymous namespace)::CallStack3(int, (anonymous namespace)::Option const&)"},
113     {0x0000000000003e64, "(anonymous namespace)::CallStack2(int, (anonymous namespace)::Option const&)"},
114     {0x0000000000003f24, "(anonymous namespace)::CallStack1(int, (anonymous namespace)::Option const&)"},
115     {0x0000000000003fe4, "(anonymous namespace)::CallStack0(int, (anonymous namespace)::Option const&)"},
116     {0x00000000000040a4, "(anonymous namespace)::ExampleThread((anonymous namespace)::Option const&)"},
117 };
118 /*
119   event_attr:
120     type 1, size 120, config 0
121     sample_freq 4000
122     sample_type (0x133e7)
123     read_format (0x7)
124     disabled 1, inherit 1, pinned 0, exclusive 0
125     exclude_user 0, exclude_kernel 0, exclude_hv 0, exclude_idle 0
126     mmap 1, mmap2 1, comm 1, comm_exec 0, freq 1
127     inherit_stat 0, enable_on_exec 0, task 0, use_clockid 0
128     watermark 0, precise_ip 0, mmap_data 0, clockid 0
129     sample_id_all 0, exclude_host 0, exclude_guest 0
130     branch_sample_type 0x0
131     exclude_callchain_kernel 0, exclude_callchain_user 1
132     sample_regs_user 0x1ffffffff
133     sample_stack_user 0x2000
134 */
135 constexpr const size_t TEST_DWARF_RECORD_REGS_USER = 0x1ffffffff;
136 constexpr const size_t TEST_DWARF_RECORD_STACK_SIZE = 2304u;
137 #endif
138 constexpr const uint64_t TEST_RECORD_SAMPLE_TYPE = 0x133e7;
139 } // namespace HiPerf
140 } // namespace Developtools
141 } // namespace OHOS
142 #endif // HIPERF_VIRTUAL_RUNTIME_TEST_H
143