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