1 /**
2 * Copyright (c) 2022-2024 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
16 #ifndef PANDA_PROFILING_INL_H
17 #define PANDA_PROFILING_INL_H
18
19 #include "profiling.h"
20 #include "runtime/profiling/generated/profiling_includes_disasm.h"
21 #include "runtime/include/profiling_gen.h"
22
23 namespace ark::profiling {
24
ReadProfile(std::istream & stm,ark::panda_file::SourceLang lang)25 inline Expected<ProfileContainer, const char *> ReadProfile([[maybe_unused]] std::istream &stm,
26 [[maybe_unused]] ark::panda_file::SourceLang lang)
27 {
28 // CC-OFFNXT(G.CTL.08) autogenerated code
29 // NOLINTNEXTLINE(hicpp-multiway-paths-covered)
30 switch (lang) {
31 #include "runtime/profiling/generated/read_profile.h"
32 default:
33 break;
34 }
35 return Unexpected("ReadProfile: No plugin found for the given language");
36 }
37
DestroyProfile(ProfileContainer profile,ark::panda_file::SourceLang lang)38 inline void DestroyProfile([[maybe_unused]] ProfileContainer profile, [[maybe_unused]] ark::panda_file::SourceLang lang)
39 {
40 // CC-OFFNXT(G.CTL.08) autogenerated code
41 // NOLINTNEXTLINE(hicpp-multiway-paths-covered)
42 switch (lang) {
43 #include "runtime/profiling/generated/destroy_profile.h"
44 default:
45 break;
46 }
47 }
48
FindMethodInProfile(ProfileContainer profile,ark::panda_file::SourceLang lang,const std::string & methodName)49 inline ProfileType FindMethodInProfile([[maybe_unused]] ProfileContainer profile,
50 [[maybe_unused]] ark::panda_file::SourceLang lang,
51 [[maybe_unused]] const std::string &methodName)
52 {
53 // CC-OFFNXT(G.CTL.08) autogenerated code
54 // NOLINTNEXTLINE(hicpp-multiway-paths-covered)
55 switch (lang) {
56 #include "runtime/profiling/generated/find_method_in_profile.h"
57 default:
58 LOG(FATAL, COMMON) << "FindMethodInProfile: No plugin found for the given language";
59 }
60 return INVALID_PROFILE;
61 }
62
DumpProfile(ProfileType profile,ark::panda_file::SourceLang lang,BytecodeInstruction * inst,std::ostream & stm)63 inline void DumpProfile([[maybe_unused]] ProfileType profile, [[maybe_unused]] ark::panda_file::SourceLang lang,
64 [[maybe_unused]] BytecodeInstruction *inst, [[maybe_unused]] std::ostream &stm)
65 {
66 // CC-OFFNXT(G.CTL.08) autogenerated code
67 // NOLINTNEXTLINE(hicpp-multiway-paths-covered)
68 switch (lang) {
69 #include "runtime/profiling/generated/dump_profile.h"
70 default:
71 break;
72 }
73 }
74 } // namespace ark::profiling
75
76 #endif // PANDA_PROFILING_INL_H