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 "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 STEP_COMPLETE, 37 EXCEPTION, 38 METHOD_ENTRY, 39 SINGLE_STEP, 40 VM_START, 41 VM_INITIALIZATION, 42 VM_DEATH, 43 UNINITIALIZED 44 }; 45 46 std::ostream &operator<<(std::ostream &out, DebugEvent value); 47 48 struct TestEvents { 49 BreakpointCallback breakpoint; 50 LoadModuleCallback loadModule; 51 ExceptionCallback exception; 52 SingleStepCallback singleStep; 53 VmStartCallback vmStart; 54 VmDeathCallback vmDeath; 55 56 Scenario scenario; 57 const EcmaVM *vm_ {nullptr}; 58 JSDebugger *debugInterface_ {nullptr}; 59 DebuggerImpl *debugger_ {nullptr}; 60 TestEvents(); 61 virtual ~TestEvents() = default; 62 63 virtual std::pair<std::string, std::string> GetEntryPoint() = 0; 64 }; 65 } // namespace panda::ecmascript::tooling::test 66 67 #endif // ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EVENTS_H 68