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