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