1 /**
2 * Copyright (c) 2021-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 #include "context.h"
17
18 #include "runtime/include/mem/allocator.h"
19
20 #include <unordered_map>
21 #include <unordered_set>
22 #include <vector>
23
24 namespace ark::verifier::debug {
25
AddMethod(const Method & method,bool isDebug)26 void DebugContext::AddMethod(const Method &method, bool isDebug)
27 {
28 if (config->whitelistNotEmpty || isDebug) {
29 auto id = method.GetUniqId();
30 // this is calculated repeatedly for each class, but caching was tried and didn't improve performance
31 auto name {ClassHelper::GetName<PandaString>(method.GetClassName().data)};
32 if (config->whitelistNotEmpty) {
33 InsertIntoWhitelist(name, true, id);
34 }
35 name += "::";
36 name += utf::Mutf8AsCString(method.GetName().data);
37 if (config->whitelistNotEmpty) {
38 InsertIntoWhitelist(name, false, id);
39 }
40 if (isDebug) {
41 InsertBreakpoints(name, id);
42 }
43 }
44 }
45
46 } // namespace ark::verifier::debug
47