1 /** 2 * Copyright (c) 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_GUARD_CONFIGS_GUARD_GRAPH_CONTEXT_H 17 #define PANDA_GUARD_CONFIGS_GUARD_GRAPH_CONTEXT_H 18 19 #include "libpandafile/file.h" 20 21 namespace panda::guard { 22 23 class GraphContext { 24 public: GraphContext(const panda_file::File & file)25 explicit GraphContext(const panda_file::File &file) : file_(file) {}; 26 27 void Init(); 28 29 static void Finalize(); 30 31 [[nodiscard]] const panda_file::File &GetAbcFile() const; 32 33 /** 34 * Get the MethodPtr corresponding to the function, 35 * which is the offset value of the function in the abc file 36 */ 37 [[nodiscard]] uint32_t FillMethodPtr(const std::string &recordName, const std::string &rawName) const; 38 39 private: 40 [[nodiscard]] std::string GetStringById(const panda_file::File::EntityId &entity_id) const; 41 42 const panda_file::File &file_; 43 44 std::map<std::string, uint32_t> recordNameMap_ {}; 45 }; 46 47 } // namespace panda::guard 48 49 #endif // PANDA_GUARD_CONFIGS_GUARD_GRAPH_CONTEXT_H 50