mirror of
https://gitee.com/openharmony/arkcompiler_toolchain
synced 2024-11-23 15:40:03 +00:00
Fix router exception while debugger
Issue;#I7MVMA Signed-off-by: yang-19970325 <yangyang585@huawei.com> Change-Id: Ida7e9ad23428d2669256ceecf59f847032236c24
This commit is contained in:
parent
d2c92f9c30
commit
efb05b0d60
@ -20,6 +20,5 @@ group("fuzztest") {
|
||||
"backendexception_fuzzer:fuzztest",
|
||||
"backendloadmodule_fuzzer:fuzztest",
|
||||
"backendnativecalling_fuzzer:fuzztest",
|
||||
"backendpendingjobentry_fuzzer:fuzztest",
|
||||
]
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
# Copyright (c) 2022 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/toolchain/test/test_helper.gni")
|
||||
import("//arkcompiler/toolchain/toolchain.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("BackendPendingJobEntryFuzzTest") {
|
||||
module_out_path = "arkcompiler/toolchain"
|
||||
|
||||
fuzz_config_file =
|
||||
"$toolchain_root/test/fuzztest/backend/backendpendingjobentry_fuzzer"
|
||||
|
||||
resource_config_file = "$toolchain_root/test/resource/tooling/ohos_test.xml"
|
||||
|
||||
sources = [ "backendpendingjobentry_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "//arkcompiler/toolchain:toolchain_test_config" ]
|
||||
|
||||
deps = [
|
||||
"//arkcompiler/ets_runtime:libark_jsruntime_test",
|
||||
"//arkcompiler/toolchain/tooling:libark_ecma_debugger_set",
|
||||
"//third_party/libuv:uv",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":BackendPendingJobEntryFuzzTest" ]
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "backendpendingjobentry_fuzzer.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "agent/debugger_impl.h"
|
||||
#include "tooling/backend/js_pt_hooks.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
using namespace panda::ecmascript::tooling;
|
||||
|
||||
#define MAXBYTELEN sizeof(int32_t)
|
||||
|
||||
namespace OHOS {
|
||||
void BackendPendingJobEntryFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (size <= 0) {
|
||||
return;
|
||||
}
|
||||
if (size > MAXBYTELEN) {
|
||||
size = MAXBYTELEN;
|
||||
}
|
||||
int32_t input = 0;
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
auto vm = JSNApi::CreateJSVM(option);
|
||||
{
|
||||
if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) {
|
||||
std::cout << "memcpy_s failed!";
|
||||
UNREACHABLE();
|
||||
}
|
||||
const int32_t MaxMemory = 1073741824;
|
||||
if (input > MaxMemory) {
|
||||
input = MaxMemory;
|
||||
}
|
||||
using JSPtLocation = tooling::JSPtLocation;
|
||||
EntityId methodId(input);
|
||||
uint32_t bytecodeOffset = 0;
|
||||
auto debugger = std::make_unique<DebuggerImpl>(vm, nullptr, nullptr);
|
||||
std::unique_ptr<JSPtHooks> jspthooks = std::make_unique<JSPtHooks>(debugger.get());
|
||||
JSPtLocation ptLocation1(nullptr, methodId, bytecodeOffset);
|
||||
jspthooks->PendingJobEntry();
|
||||
}
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::BackendPendingJobEntryFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#ifndef BACKENDPENDINGJOBENTRY_FUZZER_H
|
||||
#define BACKENDPENDINGJOBENTRY_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "backendpendingjobentry_fuzzer"
|
||||
|
||||
#endif
|
@ -1,14 +0,0 @@
|
||||
# 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.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 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.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -61,11 +61,6 @@
|
||||
<option name="push" value="test/test/libark_jsruntime_test.so -> /data/test" src="out"/>
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="BackendPendingJobEntryFuzzTest">
|
||||
<preparer>
|
||||
<option name="push" value="test/test/libark_jsruntime_test.so -> /data/test" src="out"/>
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="BackendSingleStepFuzzTest">
|
||||
<preparer>
|
||||
<option name="push" value="test/test/libark_jsruntime_test.so -> /data/test" src="out"/>
|
||||
|
@ -236,6 +236,9 @@ void DebuggerImpl::NotifyPaused(std::optional<JSPtLocation> location, PauseReaso
|
||||
paused.SetData(std::move(tmpException));
|
||||
}
|
||||
frontend_.Paused(vm_, paused);
|
||||
if (reason != BREAK_ON_START) {
|
||||
singleStepper_.reset();
|
||||
}
|
||||
debuggerState_ = DebuggerState::PAUSED;
|
||||
frontend_.WaitForDebugger(vm_);
|
||||
DebuggerApi::SetException(vm_, exception);
|
||||
@ -266,14 +269,6 @@ void DebuggerImpl::SetDebuggerState(DebuggerState debuggerState)
|
||||
debuggerState_ = debuggerState;
|
||||
}
|
||||
|
||||
void DebuggerImpl::NotifyPendingJobEntry()
|
||||
{
|
||||
if (singleStepper_ != nullptr) {
|
||||
singleStepper_.reset();
|
||||
pauseOnNextByteCode_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerImpl::NotifyHandleProtocolCommand()
|
||||
{
|
||||
auto *handler = vm_->GetJsDebuggerManager()->GetDebuggerHandler();
|
||||
@ -734,7 +729,6 @@ DispatchResponse DebuggerImpl::Resume([[maybe_unused]] const ResumeParams ¶m
|
||||
return DispatchResponse::Fail("Can only perform operation while paused");
|
||||
}
|
||||
frontend_.Resumed(vm_);
|
||||
singleStepper_.reset();
|
||||
debuggerState_ = DebuggerState::ENABLED;
|
||||
return DispatchResponse::Ok();
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ public:
|
||||
std::string_view entryPoint = "func_main_0");
|
||||
bool NotifySingleStep(const JSPtLocation &location);
|
||||
void NotifyPaused(std::optional<JSPtLocation> location, PauseReason reason);
|
||||
void NotifyPendingJobEntry();
|
||||
void NotifyHandleProtocolCommand();
|
||||
void NotifyNativeCalling(const void *nativeAddress);
|
||||
void SetDebuggerState(DebuggerState debuggerState);
|
||||
|
@ -79,15 +79,6 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName, std::string_view entr
|
||||
}
|
||||
}
|
||||
|
||||
void JSPtHooks::PendingJobEntry()
|
||||
{
|
||||
LOG_DEBUGGER(VERBOSE) << "JSPtHooks: PendingJobEntry";
|
||||
|
||||
[[maybe_unused]] LocalScope scope(debugger_->vm_);
|
||||
|
||||
debugger_->NotifyPendingJobEntry();
|
||||
}
|
||||
|
||||
void JSPtHooks::NativeCalling(const void *nativeAddress)
|
||||
{
|
||||
LOG_DEBUGGER(INFO) << "JSPtHooks: NativeCalling, addr = " << nativeAddress;
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
void Exception(const JSPtLocation &location) override;
|
||||
bool SingleStep(const JSPtLocation &location) override;
|
||||
void NativeCalling(const void *nativeAddress) override;
|
||||
void PendingJobEntry() override;
|
||||
void VmStart() override {}
|
||||
void VmDeath() override {}
|
||||
|
||||
|
@ -114,14 +114,6 @@ HWTEST_F_L0(JSPtHooksTest, VmDeathTest)
|
||||
ASSERT_NE(jspthooks, nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSPtHooksTest, PendingJobEntryTest)
|
||||
{
|
||||
auto debugger = std::make_unique<DebuggerImpl>(ecmaVm, nullptr, nullptr);
|
||||
std::unique_ptr<JSPtHooks> jspthooks = std::make_unique<JSPtHooks>(debugger.get());
|
||||
jspthooks->PendingJobEntry();
|
||||
ASSERT_NE(jspthooks, nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F_L0(JSPtHooksTest, NativeCallingTest)
|
||||
{
|
||||
auto debugger = std::make_unique<DebuggerImpl>(ecmaVm, nullptr, nullptr);
|
||||
|
@ -103,8 +103,6 @@ public:
|
||||
TestUtil::Event(DebugEvent::VM_START);
|
||||
}
|
||||
|
||||
void PendingJobEntry() override {}
|
||||
|
||||
void NativeCalling([[maybe_unused]] const void *nativeAddress) override {}
|
||||
|
||||
void TerminateTest()
|
||||
|
Loading…
Reference in New Issue
Block a user