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_RUNTIME_DEBUG_DEBUG_INF_H 16 #define PANDA_RUNTIME_DEBUG_DEBUG_INF_H 17 18 #include <atomic> 19 #include "include/thread.h" 20 #include "libpandafile/file.h" 21 #include "libpandabase/os/mutex.h" 22 #include "libpandabase/utils/time.h" 23 #include "libpandabase/utils/span.h" 24 25 namespace panda::tooling { 26 struct PCodeItem; 27 struct PCodeMetaInfo; 28 29 class DebugInf { 30 public: 31 DebugInf() = default; 32 ~DebugInf() = default; 33 34 // interface for runtime. 35 // when loading new panda file, add new entry to list 36 static void AddCodeMetaInfo(const panda_file::File *file); 37 // when unloading new panda file, remove entry to list 38 static void DelCodeMetaInfo(const panda_file::File *file); 39 40 private: 41 static void Lock(PCodeMetaInfo *mi); 42 static void UnLock(PCodeMetaInfo *mi); 43 static PCodeItem *AddCodeMetaInfoImpl(PCodeMetaInfo *metaInfo, Span<const uint8_t> inss); 44 static void DelCodeMetaInfoImpl(PCodeMetaInfo *metaInfo, const panda_file::File *file); 45 46 private: 47 static std::map<const std::string, PCodeItem *> aex_item_map; 48 static panda::os::memory::Mutex jit_item_lock; 49 static panda::os::memory::Mutex aex_item_lock; 50 51 NO_COPY_SEMANTIC(DebugInf); 52 NO_MOVE_SEMANTIC(DebugInf); 53 }; 54 } // namespace panda::tooling 55 56 #endif // PANDA_RUNTIME_DEBUG_DEBUG_INF_H 57