bugfix in attach

Signed-off-by: huangfeijie <huangfeijie@huawei.com>
This commit is contained in:
huangfeijie
2021-12-23 10:30:13 +08:00
parent 08b0f9e60a
commit 2782411111
5 changed files with 28 additions and 10 deletions
+10 -10
View File
@@ -105,6 +105,15 @@ void JSBackend::NotifyResume()
frontend_->SendNotification(ecmaVm_, std::make_unique<Resumed>());
}
void JSBackend::NotifyAllScriptParsed()
{
for (auto &script : scripts_) {
if (frontend_ != nullptr) {
frontend_->SendNotification(ecmaVm_, ScriptParsed::Create(script.second));
}
}
}
bool JSBackend::NotifyScriptParsed(int32_t scriptId, const CString &fileName)
{
auto scriptFunc = []([[maybe_unused]] PtScript *script) -> bool {
@@ -159,17 +168,8 @@ bool JSBackend::NotifyScriptParsed(int32_t scriptId, const CString &fileName)
// Notify script parsed event
std::unique_ptr<PtScript> script = std::make_unique<PtScript>(scriptId, fileName, url, source);
std::unique_ptr<ScriptParsed> scriptParsed = std::make_unique<ScriptParsed>();
scriptParsed->SetScriptId(script->GetScriptId())
.SetUrl(script->GetUrl())
.SetStartLine(0)
.SetStartColumn(0)
.SetEndLine(script->GetEndLine())
.SetEndColumn(0)
.SetExecutionContextId(0)
.SetHash(script->GetHash());
if (frontend_ != nullptr) {
frontend_->SendNotification(ecmaVm_, std::move(scriptParsed));
frontend_->SendNotification(ecmaVm_, ScriptParsed::Create(script));
}
// Store parsed script in map
+1
View File
@@ -36,6 +36,7 @@ public:
void WaitForDebugger();
void NotifyPaused(std::optional<PtLocation> location, PauseReason reason);
void NotifyResume();
void NotifyAllScriptParsed();
bool NotifyScriptParsed(int32_t scriptId, const CString &fileName);
bool StepComplete(const PtLocation &location);
@@ -80,6 +80,7 @@ void RuntimeImpl::DispatcherImpl::GetProperties(const DispatchRequest &request)
DispatchResponse RuntimeImpl::Enable()
{
Runtime::GetCurrent()->SetDebugMode(true);
backend_->NotifyAllScriptParsed();
return DispatchResponse::Ok();
}
+14
View File
@@ -449,6 +449,20 @@ Local<ObjectRef> ScriptFailedToParse::ToObject(const EcmaVM *ecmaVm)
return object;
}
std::unique_ptr<ScriptParsed> ScriptParsed::Create(const std::unique_ptr<PtScript> &script)
{
std::unique_ptr<ScriptParsed> scriptParsed = std::make_unique<ScriptParsed>();
scriptParsed->SetScriptId(script->GetScriptId())
.SetUrl(script->GetUrl())
.SetStartLine(0)
.SetStartColumn(0)
.SetEndLine(script->GetEndLine())
.SetEndColumn(0)
.SetExecutionContextId(0)
.SetHash(script->GetHash());
return scriptParsed;
}
std::unique_ptr<ScriptParsed> ScriptParsed::Create(const EcmaVM *ecmaVm, const Local<JSValueRef> &params)
{
if (params.IsEmpty()) {
+2
View File
@@ -20,6 +20,7 @@
#include <optional>
#include "libpandabase/macros.h"
#include "ecmascript/tooling/base/pt_script.h"
#include "ecmascript/tooling/base/pt_types.h"
#include "ecmascript/tooling/dispatcher.h"
#include "ecmascript/mem/c_containers.h"
@@ -474,6 +475,7 @@ class ScriptParsed final : public PtBaseEvents {
public:
ScriptParsed() = default;
~ScriptParsed() override = default;
static std::unique_ptr<ScriptParsed> Create(const std::unique_ptr<PtScript> &script);
static std::unique_ptr<ScriptParsed> Create(const EcmaVM *ecmaVm, const Local<JSValueRef> &params);
Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;