• 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 ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H
17 #define ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H
18 
19 #include "tooling/dynamic/base/pt_events.h"
20 #include "tooling/dynamic/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;
VmStart()41     void VmStart() override {}
VmDeath()42     void VmDeath() override {}
43     void SendableMethodEntry(JSHandle<Method> method) override;
44     void DisableFirstTimeFlag() override;
45     void GenerateAsyncFrames(std::shared_ptr<AsyncStack> asyncStack, bool skipTopFrame) override;
46     void HitSymbolicBreakpoint() override;
47     const std::unordered_set<std::string> &GetAllRecordNames() const override;
48 private:
49     NO_COPY_SEMANTIC(JSPtHooks);
50     NO_MOVE_SEMANTIC(JSPtHooks);
51 
52     DebuggerImpl *debugger_ {nullptr};
53     bool firstTime_ {true};
54     bool breakOnSymbol_ {false};
55 };
56 }  // namespace panda::ecmascript::tooling
57 #endif  // ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H