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 16 #ifndef PANDA_RUNTIME_TESTS_TOOLING_API_TEST_H 17 #define PANDA_RUNTIME_TESTS_TOOLING_API_TEST_H 18 19 #include <utility> 20 #include "runtime/include/tooling/debug_interface.h" 21 22 namespace panda::tooling::test { 23 using BreakpointCallback = std::function<bool(PtThread, Method *, const PtLocation &)>; 24 using LoadModuleCallback = std::function<bool(std::string_view)>; 25 using PausedCallback = std::function<bool(PauseReason)>; 26 using ExceptionCallback = 27 std::function<bool(PtThread, Method *, const PtLocation &, ObjectHeader *, Method *, const PtLocation &)>; 28 using ExceptionCatchCallback = std::function<bool(PtThread, Method *, const PtLocation &, ObjectHeader *)>; 29 using PropertyAccessCallback = std::function<bool(PtThread, Method *, const PtLocation &, ObjectHeader *, PtProperty)>; 30 using PropertyModificationCallback = 31 std::function<bool(PtThread, Method *, const PtLocation &, ObjectHeader *, PtProperty, VRegValue)>; 32 using FramePopCallback = std::function<bool(PtThread, Method *, bool)>; 33 using GarbageCollectionStartCallback = std::function<bool()>; 34 using GarbageCollectionFinishCallback = std::function<bool()>; 35 using ObjectAllocCallback = std::function<bool(BaseClass *, ObjectHeader *, PtThread, size_t)>; 36 using MethodEntryCallback = std::function<bool(PtThread, Method *)>; 37 using MethodExitCallback = std::function<bool(PtThread, Method *, bool, VRegValue)>; 38 using SingleStepCallback = std::function<bool(PtThread, Method *, const PtLocation &)>; 39 using ThreadStartCallback = std::function<bool(PtThread)>; 40 using ThreadEndCallback = std::function<bool(PtThread)>; 41 using VmStartCallback = std::function<bool()>; 42 using VmInitializationCallback = std::function<bool(PtThread)>; 43 using VmDeathCallback = std::function<bool()>; 44 using ExceptionRevokedCallback = std::function<bool(ExceptionWrapper, ExceptionID)>; 45 using ExecutionContextCreatedCallback = std::function<bool(ExecutionContextWrapper)>; 46 using ExecutionContextDestroyedCallback = std::function<bool(ExecutionContextWrapper)>; 47 using ExecutionContextsClearedCallback = std::function<bool()>; 48 using InspectRequestedCallback = std::function<bool(PtObject, PtObject)>; 49 using ClassLoadCallback = std::function<bool(PtThread, BaseClass *)>; 50 using ClassPrepareCallback = std::function<bool(PtThread, BaseClass *)>; 51 using MonitorWaitCallback = std::function<bool(PtThread, ObjectHeader *, int64_t)>; 52 using MonitorWaitedCallback = std::function<bool(PtThread, ObjectHeader *, bool)>; 53 using MonitorContendedEnterCallback = std::function<bool(PtThread, ObjectHeader *)>; 54 using MonitorContendedEnteredCallback = std::function<bool(PtThread, ObjectHeader *)>; 55 56 using Scenario = std::function<bool()>; 57 58 enum class DebugEvent { 59 BREAKPOINT, 60 LOAD_MODULE, 61 PAUSED, 62 EXCEPTION, 63 EXCEPTION_CATCH, 64 FIELD_ACCESS, 65 FIELD_MODIFICATION, 66 FRAME_POP, 67 GARBAGE_COLLECTIION_START, 68 GARBAGE_COLLECTIION_FINISH, 69 METHOD_ENTRY, 70 METHOD_EXIT, 71 SINGLE_STEP, 72 THREAD_START, 73 THREAD_END, 74 VM_START, 75 VM_INITIALIZATION, 76 VM_DEATH, 77 EXCEPTION_REVOKED, 78 EXECUTION_CONTEXT_CREATED, 79 EXECUTION_CONTEXT_DESTROYED, 80 EXECUTION_CONTEXT_CLEARED, 81 INSPECT_REQUESTED, 82 CLASS_LOAD, 83 CLASS_PREPARE, 84 MONITOR_WAIT, 85 MONITOR_WAITED, 86 MONITOR_CONTENDED_ENTER, 87 MONITOR_CONTENDED_ENTERED, 88 UNINITIALIZED 89 }; 90 91 std::ostream &operator<<(std::ostream &out, DebugEvent value); 92 93 struct ApiTest { 94 NO_COPY_SEMANTIC(ApiTest); 95 NO_MOVE_SEMANTIC(ApiTest); 96 // NOLINTBEGIN(misc-non-private-member-variables-in-classes) 97 BreakpointCallback breakpoint; 98 LoadModuleCallback loadModule; 99 PausedCallback paused; 100 ExceptionCallback exception; 101 ExceptionCatchCallback exceptionCatch; 102 PropertyAccessCallback propertyAccess; 103 PropertyModificationCallback propertyModification; 104 FramePopCallback framePop; 105 GarbageCollectionStartCallback garbageCollectionStart; 106 GarbageCollectionFinishCallback garbageCollectionFinish; 107 ObjectAllocCallback objectAlloc; 108 MethodEntryCallback methodEntry; 109 MethodExitCallback methodExit; 110 SingleStepCallback singleStep; 111 ThreadStartCallback threadStart; 112 ThreadEndCallback threadEnd; 113 VmStartCallback vmStart; 114 VmInitializationCallback vmInit; 115 VmDeathCallback vmDeath; 116 ExceptionRevokedCallback exceptionRevoked; 117 ExecutionContextCreatedCallback executionContextCreated; 118 ExecutionContextDestroyedCallback executionContextDestroyed; 119 ExecutionContextsClearedCallback executionContextCleared; 120 InspectRequestedCallback inspectRequested; 121 ClassLoadCallback classLoad; 122 ClassPrepareCallback classPrepare; 123 MonitorWaitCallback monitorWait; 124 MonitorWaitedCallback monitorWaited; 125 MonitorContendedEnterCallback monitorContendedEnter; 126 MonitorContendedEnteredCallback monitorContendedEntered; 127 128 Scenario scenario; 129 DebugInterface *debugInterface {nullptr}; 130 // NOLINTEND(misc-non-private-member-variables-in-classes) 131 132 ApiTest(); 133 virtual ~ApiTest() = default; 134 135 virtual std::pair<const char *, const char *> GetEntryPoint() = 0; 136 }; 137 } // namespace panda::tooling::test 138 139 #endif // PANDA_RUNTIME_TESTS_TOOLING_API_TEST_H 140