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 ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EVENTS_H 17 #define ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EVENTS_H 18 19 #include <utility> 20 21 #include "ecmascript/tooling/backend/js_pt_hooks.h" 22 23 namespace panda::ecmascript::tooling::test { 24 using BreakpointCallback = std::function<bool(const JSPtLocation &)>; 25 using LoadModuleCallback = std::function<bool(std::string_view)>; 26 using ExceptionCallback = std::function<bool(const JSPtLocation &)>; 27 using SingleStepCallback = std::function<bool(const JSPtLocation &)>; 28 using VmStartCallback = std::function<bool()>; 29 using VmDeathCallback = std::function<bool()>; 30 using Scenario = std::function<bool()>; 31 32 enum class DebugEvent { 33 BREAKPOINT, 34 LOAD_MODULE, 35 PAUSED, 36 EXCEPTION, 37 METHOD_ENTRY, 38 SINGLE_STEP, 39 VM_START, 40 VM_INITIALIZATION, 41 VM_DEATH, 42 UNINITIALIZED 43 }; 44 45 std::ostream &operator<<(std::ostream &out, DebugEvent value); 46 47 struct TestEvents { 48 BreakpointCallback breakpoint; 49 LoadModuleCallback loadModule; 50 ExceptionCallback exception; 51 SingleStepCallback singleStep; 52 VmStartCallback vmStart; 53 VmDeathCallback vmDeath; 54 55 Scenario scenario; 56 const EcmaVM *vm_ {nullptr}; 57 JSDebugger *debugInterface_ {nullptr}; 58 DebuggerImpl *debugger_ {nullptr}; 59 TestEvents(); 60 virtual ~TestEvents() = default; 61 62 virtual std::pair<std::string, std::string> GetEntryPoint() = 0; 63 }; 64 } // namespace panda::ecmascript::tooling::test 65 66 #endif // ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EVENTS_H 67