Files
ark_js_runtime/ecmascript/tooling/backend/js_pt_hooks.cpp
T
wengchangcheng 9ea13c48f9 Descriptor: debugger refactor [ part-1 ]
details:
1. delete unused method
2. modify file dir
3. add event channel for every domain
4. implement domain function in agent and delete js_backend
5. modify dispatchTable to static
6. modify debugger_api
7. modify js_debugger and add debugger_executor
issue: https://gitee.com/openharmony/ark_js_runtime/issues/I58LOO

Signed-off-by: wengchangcheng <wengchangcheng@huawei.com>
Change-Id: I7747bf3ad66e9a180d6179e45be5bcaf4161b29b
2022-06-01 23:00:13 +08:00

78 lines
2.3 KiB
C++

/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecmascript/tooling/agent/debugger_impl.h"
#include "ecmascript/tooling/backend/js_pt_hooks.h"
namespace panda::ecmascript::tooling {
void JSPtHooks::Breakpoint(const JSPtLocation &location)
{
LOG(DEBUG, DEBUGGER) << "JSPtHooks: Breakpoint => " << location.GetMethodId() << ": "
<< location.GetBytecodeOffset();
[[maybe_unused]] LocalScope scope(debugger_->vm_);
debugger_->NotifyPaused(location, INSTRUMENTATION);
}
void JSPtHooks::Exception([[maybe_unused]] const JSPtLocation &location)
{
LOG(DEBUG, DEBUGGER) << "JSPtHooks: Exception";
[[maybe_unused]] LocalScope scope(debugger_->vm_);
debugger_->NotifyPaused({}, EXCEPTION);
}
bool JSPtHooks::SingleStep(const JSPtLocation &location)
{
LOG(DEBUG, DEBUGGER) << "JSPtHooks: SingleStep => " << location.GetBytecodeOffset();
[[maybe_unused]] LocalScope scope(debugger_->vm_);
if (UNLIKELY(firstTime_)) {
firstTime_ = false;
debugger_->NotifyPaused({}, BREAK_ON_START);
return false;
}
// pause or step complete
if (debugger_->NotifySingleStep(location)) {
debugger_->NotifyPaused({}, OTHER);
return true;
}
return false;
}
void JSPtHooks::LoadModule(std::string_view pandaFileName)
{
LOG(INFO, DEBUGGER) << "JSPtHooks: LoadModule: " << pandaFileName;
[[maybe_unused]] LocalScope scope(debugger_->vm_);
static uint32_t scriptId = 0;
if (debugger_->NotifyScriptParsed(scriptId++, pandaFileName.data())) {
firstTime_ = true;
}
}
void JSPtHooks::PendingJobEntry()
{
LOG(DEBUG, DEBUGGER) << "JSPtHooks: PendingJobEntry";
[[maybe_unused]] LocalScope scope(debugger_->vm_);
debugger_->NotifyPendingJobEntry();
}
} // namespace panda::ecmascript::tooling