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 #ifndef PANDA_RUNTIME_INCLUDE_TOOLING_PT_LOCATION_H 16 #define PANDA_RUNTIME_INCLUDE_TOOLING_PT_LOCATION_H 17 18 #include <cstring> 19 20 #include "libpandafile/file_items.h" 21 #include "libpandabase/macros.h" 22 23 namespace ark::tooling { 24 class PtLocation { 25 public: 26 using EntityId = panda_file::File::EntityId; 27 PtLocation(const char * pandaFile,EntityId methodId,uint32_t bytecodeOffset)28 explicit PtLocation(const char *pandaFile, EntityId methodId, uint32_t bytecodeOffset) 29 : pandaFile_(pandaFile), methodId_(methodId), bytecodeOffset_(bytecodeOffset) 30 { 31 } 32 GetPandaFile()33 const char *GetPandaFile() const 34 { 35 return pandaFile_; 36 } 37 GetMethodId()38 EntityId GetMethodId() const 39 { 40 return methodId_; 41 } 42 GetBytecodeOffset()43 uint32_t GetBytecodeOffset() const 44 { 45 return bytecodeOffset_; 46 } 47 48 bool operator==(const PtLocation &location) const 49 { 50 return methodId_ == location.methodId_ && bytecodeOffset_ == location.bytecodeOffset_ && 51 ::strcmp(pandaFile_, location.pandaFile_) == 0; 52 } 53 54 ~PtLocation() = default; 55 56 DEFAULT_COPY_SEMANTIC(PtLocation); 57 DEFAULT_MOVE_SEMANTIC(PtLocation); 58 59 private: 60 const char *pandaFile_; 61 EntityId methodId_; 62 uint32_t bytecodeOffset_ {0}; 63 }; 64 } // namespace ark::tooling 65 66 #endif // PANDA_RUNTIME_INCLUDE_TOOLING_PT_LOCATION_H 67