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_BACKEND_JS_PT_HOOKS_H
17 #define ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H
18 
19 #include "tooling/base/pt_events.h"
20 #include "tooling/base/pt_script.h"
21 
22 #include "ecmascript/debugger/js_debugger_interface.h"
23 #include "libpandabase/macros.h"
24 
25 namespace panda::ecmascript::tooling {
26 class DebuggerImpl;
27 
28 class JSPtHooks : public PtHooks {
29 public:
JSPtHooks(DebuggerImpl *debugger)30     explicit JSPtHooks(DebuggerImpl *debugger) : debugger_(debugger) {}
31     ~JSPtHooks() override = default;
32 
33     void DebuggerStmt(const JSPtLocation &location) override;
34     void Breakpoint(const JSPtLocation &location) override;
35     void LoadModule(std::string_view pandaFileName, std::string_view entryPoint) override;
36     void Exception(const JSPtLocation &location) override;
37     bool SingleStep(const JSPtLocation &location) override;
38     bool NativeOut() override;
39     void NativeCalling(const void *nativeAddress) override;
40     void NativeReturn(const void *nativeAddress) override;
41     void VmStart() override {}
42     void VmDeath() override {}
43     void SendableMethodEntry(JSHandle<Method> method) override;
44 
45 private:
46     NO_COPY_SEMANTIC(JSPtHooks);
47     NO_MOVE_SEMANTIC(JSPtHooks);
48 
49     DebuggerImpl *debugger_ {nullptr};
50     bool firstTime_ {true};
51 };
52 }  // namespace panda::ecmascript::tooling
53 #endif  // ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H