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 LIBABCKIT_SRC_WRAPPERS_ABCFILE_WRAPPER_H 17 #define LIBABCKIT_SRC_WRAPPERS_ABCFILE_WRAPPER_H 18 19 #include <cstdint> 20 #include <cstddef> 21 #include <string> 22 #include <vector> 23 #include <functional> 24 25 namespace libabckit { 26 27 // NOTE: Fix after discussion with author 28 // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) 29 class FileWrapper { 30 public: FileWrapper(void * abcFile)31 explicit FileWrapper(void *abcFile) : abcFile_(abcFile) {} FileWrapper(const void * abcFile)32 explicit FileWrapper(const void *abcFile) : abcFile_(abcFile) {} 33 ~FileWrapper(); 34 35 size_t GetMethodTotalArgumentsCount(void *method) const; 36 size_t GetMethodArgumentsCount([[maybe_unused]] void *caller, uint32_t id) const; 37 size_t GetMethodRegistersCount(void *method) const; 38 const uint8_t *GetMethodCode(void *method) const; 39 size_t GetMethodCodeSize(void *method) const; 40 uint8_t GetMethodSourceLanguage(void *method) const; 41 size_t GetClassIdForMethod(void *method) const; 42 std::string GetClassNameFromMethod(void *method) const; 43 std::string GetMethodName(void *method) const; 44 uint32_t ResolveOffsetByIndex(void *method, uint16_t index) const; 45 void EnumerateTryBlocks(void *method, const std::function<void(void *)> &cb) const; 46 void EnumerateCatchBlocksForTryBlock(void *tryBlock, const std::function<void(void *)> &cb) const; 47 std::pair<int, int> GetTryBlockBoundaries(void *tryBlock) const; 48 uint32_t GetCatchBlockHandlerPc(void *catchBlock) const; 49 50 private: 51 const void *abcFile_; 52 }; 53 54 } // namespace libabckit 55 56 #endif // LIBABCKIT_SRC_WRAPPERS_ABCFILE_WRAPPER_H 57