• 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_VERIFICATION_DEBUG_CONTEXT_CONTEXT_H_
17 #define PANDA_VERIFICATION_DEBUG_CONTEXT_CONTEXT_H_
18 
19 #include "verification/debug/breakpoint/breakpoint_private.h"
20 #include "verification/debug/allowlist/allowlist_private.h"
21 #include "verification/debug/config/config.h"
22 #include "verification/debug/config/config.h"
23 #include "verification/util/callable.h"
24 #include "verification/util/synchronized.h"
25 
26 #include "runtime/include/mem/panda_string.h"
27 #include "runtime/include/mem/panda_containers.h"
28 
29 #include <cstdint>
30 #include <unordered_map>
31 #include <unordered_set>
32 #include <vector>
33 #include <array>
34 
35 namespace panda::verifier::debug {
36 struct DebugContext {
37     struct {
38         PandaUnorderedMap<PandaString, panda::verifier::callable<bool(const config::Section &)>> SectionHandlers;
39     } Config;
40 
41     struct {
42         std::array<Synchronized<PandaUnorderedMap<uint64_t, PandaUnorderedSet<uint32_t>>>,
43                    static_cast<size_t>(Component::__LAST__)>
44             Breakpoint;
45         Synchronized<PandaUnorderedMap<uint32_t, PandaVector<DebugManagedBrkCfg>>> Config;
46     } ManagedBreakpoints;
47 
48     struct {
49         std::array<Synchronized<PandaUnorderedSet<uint32_t>>, static_cast<size_t>(AllowlistKind::__LAST__)> NameHash;
50         std::array<Synchronized<PandaUnorderedSet<uint64_t>>, static_cast<size_t>(AllowlistKind::__LAST__)> Id;
51     } Allowlist;
52 
53     static DebugContext &GetCurrent();
54     static void Destroy();
55 
56     static DebugContext *instance;
57 };
58 }  // namespace panda::verifier::debug
59 
60 #endif  // PANDA_VERIFICATION_DEBUG_CONTEXT_CONTEXT_H_
61