From bb88af5c761f1e5910336de85a753ea710bccc9a Mon Sep 17 00:00:00 2001 From: zhao-baiyi Date: Tue, 10 Oct 2023 11:00:28 +0800 Subject: [PATCH] Add protocol functionality to store location --- tooling/agent/debugger_impl.cpp | 60 +++--- tooling/agent/debugger_impl.h | 5 +- tooling/backend/js_single_stepper.cpp | 8 + tooling/backend/js_single_stepper.h | 3 +- tooling/base/pt_params.cpp | 283 ++++++++++++++------------ tooling/base/pt_params.h | 33 ++- 6 files changed, 220 insertions(+), 172 deletions(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 80e2064e..d35e3843 100644 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -259,26 +259,21 @@ void DebuggerImpl::NotifyPaused(std::optional location, PauseReaso void DebuggerImpl::NotifyNativeCalling(const void *nativeAddress) { - if (mixStackEnabled_) { - tooling::MixedStack mixedStack; - nativePointer_ = DebuggerApi::GetNativePointer(vm_); - mixedStack.SetNativePointers(nativePointer_); - std::vector> callFrames; - if (GenerateCallFrames(&callFrames)) { - mixedStack.SetCallFrames(std::move(callFrames)); - } - frontend_.MixedStack(vm_, mixedStack); - } - - // native calling only after step into should be reported + tooling::NativeCalling nativeCalling; if (singleStepper_ != nullptr && singleStepper_->GetStepperType() == StepperType::STEP_INTO) { - tooling::NativeCalling nativeCalling; - nativeCalling.SetIntoStatus(true); nativeCalling.SetNativeAddress(nativeAddress); - frontend_.NativeCalling(vm_, nativeCalling); - frontend_.WaitForDebugger(vm_); + nativeCalling.SetIntoStatus(true); + } + + nativePointer_ = DebuggerApi::GetNativePointer(vm_); + nativeCalling.SetNativePointer(nativePointer_); + std::vector> callFrames; + if (GenerateCallFrames(&callFrames)) { + nativeCalling.SetCallFrames(std::move(callFrames)); } + frontend_.NativeCalling(vm_, nativeCalling); + frontend_.WaitForDebugger(vm_); } // only use for test case @@ -296,6 +291,8 @@ void DebuggerImpl::NotifyHandleProtocolCommand() void DebuggerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) { static std::unordered_map dispatcherTable { + + { "continuetolocation", &DebuggerImpl::DispatcherImpl::ContinueToLocation }, { "enable", &DebuggerImpl::DispatcherImpl::Enable }, { "disable", &DebuggerImpl::DispatcherImpl::Disable }, { "evaluateOnCallFrame", &DebuggerImpl::DispatcherImpl::EvaluateOnCallFrame }, @@ -329,6 +326,17 @@ void DebuggerImpl::DispatcherImpl::Dispatch(const DispatchRequest &request) } } +void DebuggerImpl::DispatcherImpl::ContinueToLocation(const DispatchRequest &request) +{ + std::unique_ptr params = ContinueToLocationParams::Create(request.GetParams()); + if (params == nullptr) { + SendResponse(request, DispatchResponse::Fail("wrong params")); + return; + } + DispatchResponse response = debugger_->ContinueToLocation(*params); + SendResponse(request, response); +} + void DebuggerImpl::DispatcherImpl::Enable(const DispatchRequest &request) { std::unique_ptr params = EnableParams::Create(request.GetParams()); @@ -594,15 +602,6 @@ void DebuggerImpl::Frontend::NativeCalling(const EcmaVM *vm, const tooling::Nati channel_->SendNotification(nativeCalling); } -void DebuggerImpl::Frontend::MixedStack(const EcmaVM *vm, const tooling::MixedStack &mixedStack) -{ - if (!AllowNotify(vm)) { - return; - } - - channel_->SendNotification(mixedStack); -} - void DebuggerImpl::Frontend::Resumed(const EcmaVM *vm) { if (!AllowNotify(vm)) { @@ -763,9 +762,6 @@ DispatchResponse DebuggerImpl::GetScriptSource(const GetScriptSourceParams ¶ DispatchResponse DebuggerImpl::Pause() { - if (debuggerState_ == DebuggerState::PAUSED) { - return DispatchResponse::Fail("Can only perform operation while running"); - } pauseOnNextByteCode_ = true; return DispatchResponse::Ok(); } @@ -891,6 +887,11 @@ DispatchResponse DebuggerImpl::SetBreakpointsActive(const SetBreakpointsActivePa breakpointsState_ = params.GetBreakpointsState(); return DispatchResponse::Ok(); } +DispatchResponse DebuggerImpl::ContinueToLocation([[maybe_unused]] const ContinueToLocationParams ¶ms) +{ + currentStepper_ = SingleStepper::GetStepNowStepper(vm_); + return DispatchResponse::Ok(); +} DispatchResponse DebuggerImpl::GetPossibleAndSetBreakpointByUrl(const GetPossibleAndSetBreakpointParams ¶ms, std::vector> &outLocations) @@ -1040,7 +1041,6 @@ DispatchResponse DebuggerImpl::SetBlackboxPatterns() DispatchResponse DebuggerImpl::SetMixedDebugEnabled([[maybe_unused]] const SetMixedDebugParams ¶ms) { vm_->GetJsDebuggerManager()->SetMixedDebugEnabled(params.GetEnabled()); - mixStackEnabled_ = params.GetMixedStackEnabled(); return DispatchResponse::Ok(); } @@ -1238,7 +1238,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, for (auto &scope : closureScopeChains) { scopeChain.emplace_back(std::move(scope)); } - if (jsPandaFile != nullptr && !jsPandaFile->IsBundlePack() && jsPandaFile->IsNewVersion()) { + if (jsPandaFile != nullptr && jsPandaFile->IsMergedPF() && jsPandaFile->IsNewVersion()) { JSHandle currentModule(thread, DebuggerApi::GetCurrentModule(vm_)); if (currentModule->IsSourceTextModule()) { // CJS module is string scopeChain.emplace_back(GetModuleScopeChain()); diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index aeafa1b6..46e570d1 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -46,6 +46,7 @@ public: void NotifyNativeCalling(const void *nativeAddress); void SetDebuggerState(DebuggerState debuggerState); + DispatchResponse ContinueToLocation(const ContinueToLocationParams ¶ms); DispatchResponse Enable(const EnableParams ¶ms, UniqueDebuggerId *id); DispatchResponse Disable(); DispatchResponse EvaluateOnCallFrame(const EvaluateOnCallFrameParams ¶ms, @@ -113,6 +114,7 @@ public: : DispatcherBase(channel), debugger_(std::move(debugger)) {} ~DispatcherImpl() override = default; + void ContinueToLocation(const DispatchRequest &request); void Dispatch(const DispatchRequest &request) override; void Enable(const DispatchRequest &request); void Disable(const DispatchRequest &request); @@ -195,7 +197,6 @@ private: void Paused(const EcmaVM *vm, const tooling::Paused &paused); void Resumed(const EcmaVM *vm); void NativeCalling(const EcmaVM *vm, const tooling::NativeCalling &nativeCalling); - void MixedStack(const EcmaVM *vm, const tooling::MixedStack &mixedStack); void ScriptFailedToParse(const EcmaVM *vm); void ScriptParsed(const EcmaVM *vm, const PtScript &script); void WaitForDebugger(const EcmaVM *vm); @@ -221,8 +222,8 @@ private: bool pauseOnNextByteCode_ {false}; bool breakpointsState_ {true}; bool skipAllPausess_ {false}; - bool mixStackEnabled_ {false}; std::unique_ptr singleStepper_ {nullptr}; + std::unique_ptr currentStepper_ {nullptr}; std::vector nativePointer_; std::unordered_map scopeObjects_ {}; diff --git a/tooling/backend/js_single_stepper.cpp b/tooling/backend/js_single_stepper.cpp index 3e5555b9..fd87d4a0 100644 --- a/tooling/backend/js_single_stepper.cpp +++ b/tooling/backend/js_single_stepper.cpp @@ -64,6 +64,9 @@ bool SingleStepper::StepComplete(uint32_t bcOffset) const } break; } + case Type::STEP_NOW: { + break; + } default: { return false; } @@ -72,6 +75,11 @@ bool SingleStepper::StepComplete(uint32_t bcOffset) const return true; } +std::unique_ptr SingleStepper::GetStepNowStepper(const EcmaVM *ecmaVm) +{ + return GetStepper(ecmaVm, SingleStepper::Type::STEP_NOW); +} + std::unique_ptr SingleStepper::GetStepIntoStepper(const EcmaVM *ecmaVm) { return GetStepper(ecmaVm, SingleStepper::Type::STEP_INTO); diff --git a/tooling/backend/js_single_stepper.h b/tooling/backend/js_single_stepper.h index d098a265..5b9affa9 100644 --- a/tooling/backend/js_single_stepper.h +++ b/tooling/backend/js_single_stepper.h @@ -26,7 +26,7 @@ namespace panda::ecmascript::tooling { class SingleStepper { public: - enum class Type { STEP_INTO, STEP_OVER, STEP_OUT }; + enum class Type { STEP_INTO, STEP_OVER, STEP_OUT, STEP_NOW }; SingleStepper(const EcmaVM *ecmaVm, std::unique_ptr ptMethod, std::list stepRanges, Type type) : ecmaVm_(ecmaVm), @@ -45,6 +45,7 @@ public: return type_; } + static std::unique_ptr GetStepNowStepper(const EcmaVM *ecmaVm); static std::unique_ptr GetStepIntoStepper(const EcmaVM *ecmaVm); static std::unique_ptr GetStepOverStepper(const EcmaVM *ecmaVm); static std::unique_ptr GetStepOutStepper(const EcmaVM *ecmaVm); diff --git a/tooling/base/pt_params.cpp b/tooling/base/pt_params.cpp index 6eaf6f02..5a9afdc3 100644 --- a/tooling/base/pt_params.cpp +++ b/tooling/base/pt_params.cpp @@ -26,8 +26,8 @@ std::unique_ptr EnableParams::Create(const PtJson ¶ms) ret = params.GetDouble("maxScriptsCacheSize", &maxScriptsCacheSize); if (ret == Result::SUCCESS) { paramsObject->maxScriptsCacheSize_ = maxScriptsCacheSize; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'maxScriptsCacheSize';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'maxScriptsCacheSize';"; } if (!error.empty()) { @@ -49,56 +49,56 @@ std::unique_ptr EvaluateOnCallFrameParams::Create(con if (ret == Result::SUCCESS) { paramsObject->callFrameId_ = std::stoi(callFrameId); } else { - error += "Unknown or wrong type of 'callFrameId';"; + error += "Unknown 'callFrameId';"; } std::string expression; ret = params.GetString("expression", &expression); if (ret == Result::SUCCESS) { paramsObject->expression_ = std::move(expression); } else { - error += "Unknown or wrong type of 'expression';"; + error += "Unknown 'expression';"; } std::string objectGroup; ret = params.GetString("objectGroup", &objectGroup); if (ret == Result::SUCCESS) { paramsObject->objectGroup_ = std::move(objectGroup); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'objectGroup';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'objectGroup';"; } bool includeCommandLineAPI = false; ret = params.GetBool("includeCommandLineAPI", &includeCommandLineAPI); if (ret == Result::SUCCESS) { paramsObject->includeCommandLineAPI_ = includeCommandLineAPI; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'includeCommandLineAPI';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'includeCommandLineAPI';"; } bool silent = false; ret = params.GetBool("silent", &silent); if (ret == Result::SUCCESS) { paramsObject->silent_ = silent; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'silent';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'silent';"; } bool returnByValue = false; ret = params.GetBool("returnByValue", &returnByValue); if (ret == Result::SUCCESS) { paramsObject->returnByValue_ = returnByValue; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'returnByValue';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'returnByValue';"; } bool generatePreview = false; ret = params.GetBool("generatePreview", &generatePreview); if (ret == Result::SUCCESS) { paramsObject->generatePreview_ = generatePreview; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'generatePreview';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'generatePreview';"; } bool throwOnSideEffect = false; ret = params.GetBool("throwOnSideEffect", &throwOnSideEffect); if (ret == Result::SUCCESS) { paramsObject->throwOnSideEffect_ = throwOnSideEffect; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'throwOnSideEffect';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'throwOnSideEffect';"; } if (!error.empty()) { @@ -107,6 +107,35 @@ std::unique_ptr EvaluateOnCallFrameParams::Create(con } return paramsObject; } +std::unique_ptr ContinueToLocationParams::Create(const PtJson ¶ms) +{ + auto paramsObject = std::make_unique(); + std::string error; + Result ret; + + std::unique_ptr location; + ret = params.GetObject("location", &location); + if (ret == Result::SUCCESS) { + std::unique_ptr locations = Location::Create(*location); + if (locations == nullptr) { + error += "Unknown 'location';"; + } else { + paramsObject->location_ = std::move(locations); + } + } else { + error += "Unknown 'location';"; + } + + std::string targetCallFrames; + ret = params.GetString("targetCallFrames", &targetCallFrames); + if (ret == Result::SUCCESS) { + paramsObject->targetCallFrames_ = std::move(targetCallFrames); + } else { + error += "Unknown 'targetCallFrames';"; + } + + return paramsObject; +} std::unique_ptr GetPossibleBreakpointsParams::Create(const PtJson ¶ms) { @@ -119,31 +148,31 @@ std::unique_ptr GetPossibleBreakpointsParams::Crea if (ret == Result::SUCCESS) { std::unique_ptr location = Location::Create(*start); if (location == nullptr) { - error += "'start' is invalid;"; + error += "Unknown 'start';"; } else { paramsObject->start_ = std::move(location); } } else { - error += "Unknown or wrong type of 'start';"; + error += "Unknown 'start';"; } std::unique_ptr end; ret = params.GetObject("end", &end); if (ret == Result::SUCCESS) { std::unique_ptr location = Location::Create(*end); if (location == nullptr) { - error += "'end' is invalid;"; + error += "Unknown 'end';"; } else { paramsObject->end_ = std::move(location); } - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'end';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'end';"; } bool restrictToFunction = false; ret = params.GetBool("restrictToFunction", &restrictToFunction); if (ret == Result::SUCCESS) { paramsObject->restrictToFunction_ = restrictToFunction; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'restrictToFunction';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'restrictToFunction';"; } if (!error.empty()) { @@ -165,7 +194,7 @@ std::unique_ptr GetScriptSourceParams::Create(const PtJso if (ret == Result::SUCCESS) { paramsObject->scriptId_ = std::stoi(scriptId); } else { - error += "Unknown or wrong type of'scriptId';"; + error += "Unknown 'scriptId';"; } if (!error.empty()) { @@ -187,7 +216,7 @@ std::unique_ptr RemoveBreakpointParams::Create(const PtJ if (ret == Result::SUCCESS) { paramsObject->breakpointId_ = std::move(breakpointId); } else { - error += "Unknown or wrong type of 'breakpointId';"; + error += "Unknown 'breakpointId';"; } if (!error.empty()) { @@ -208,8 +237,8 @@ std::unique_ptr ResumeParams::Create(const PtJson ¶ms) ret = params.GetBool("terminateOnResume", &terminateOnResume); if (ret == Result::SUCCESS) { paramsObject->terminateOnResume_ = terminateOnResume; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'terminateOnResume';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'terminateOnResume';"; } if (!error.empty()) { @@ -231,7 +260,7 @@ std::unique_ptr SetAsyncCallStackDepthParams::Crea if (ret == Result::SUCCESS) { paramsObject->maxDepth_ = maxDepth; } else { - error += "Unknown or wrong type of 'maxDepth';"; + error += "Unknown 'maxDepth';"; } if (!error.empty()) { @@ -261,7 +290,7 @@ std::unique_ptr SetBlackboxPatternsParams::Create(con } } } else { - error += "Unknown or wrong type of 'patterns';"; + error += "Unknown 'patterns';"; } if (!error.empty()) { @@ -283,42 +312,42 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const if (ret == Result::SUCCESS) { paramsObject->lineNumber_ = lineNumber; } else { - error += "Unknown or wrong type of 'lineNumber';"; + error += "Unknown 'lineNumber';"; } std::string url; ret = params.GetString("url", &url); if (ret == Result::SUCCESS) { paramsObject->url_ = std::move(url); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'url';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'url';"; } std::string urlRegex; ret = params.GetString("urlRegex", &urlRegex); if (ret == Result::SUCCESS) { paramsObject->urlRegex_ = std::move(urlRegex); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'urlRegex';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'urlRegex';"; } std::string scriptHash; ret = params.GetString("scriptHash", &scriptHash); if (ret == Result::SUCCESS) { paramsObject->scriptHash_ = std::move(scriptHash); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'scriptHash';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'scriptHash';"; } int32_t columnNumber; ret = params.GetInt("columnNumber", &columnNumber); if (ret == Result::SUCCESS) { paramsObject->columnNumber_ = columnNumber; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'columnNumber';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'columnNumber';"; } std::string condition; ret = params.GetString("condition", &condition); if (ret == Result::SUCCESS) { paramsObject->condition_ = std::move(condition); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'condition';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'condition';"; } if (!error.empty()) { LOG_DEBUGGER(ERROR) << "SetBreakpointByUrlParams::Create " << error; @@ -338,8 +367,8 @@ std::unique_ptr SetBreakpointsActiveParams::Create(c ret = params.GetBool("active", &breakpointsState); if (ret == Result::SUCCESS) { paramsObject->breakpointsState_ = std::move(breakpointsState); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'active';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'active';"; } if (!error.empty()) { LOG_DEBUGGER(ERROR) << "SetBreakpointsActiveParams::Create " << error; @@ -359,8 +388,8 @@ std::unique_ptr SetSkipAllPausesParams::Create(const PtJ ret = params.GetBool("skip", &skipAllPausesState); if (ret == Result::SUCCESS) { paramsObject->skipAllPausesState_ = std::move(skipAllPausesState); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'skip';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'skip';"; } if (!error.empty()) { LOG_DEBUGGER(ERROR) << "SetSkipAllPausesParams::Create " << error; @@ -394,7 +423,7 @@ std::unique_ptr GetPossibleAndSetBreakpointPa paramsObject->breakpointsList_ = std::move(breakpointList); } } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'breakpoints';"; + error += "Unknown 'breakpoints';"; } if (!error.empty()) { @@ -416,7 +445,7 @@ std::unique_ptr SetPauseOnExceptionsParams::Create(c if (ret == Result::SUCCESS) { paramsObject->StoreState(state); } else { - error += "Unknown or wrong type of'state';"; + error += "Unknown 'state';"; } if (!error.empty()) { @@ -437,8 +466,8 @@ std::unique_ptr StepIntoParams::Create(const PtJson ¶ms) ret = params.GetBool("breakOnAsyncCall", &breakOnAsyncCall); if (ret == Result::SUCCESS) { paramsObject->breakOnAsyncCall_ = breakOnAsyncCall; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'breakOnAsyncCall';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'breakOnAsyncCall';"; } std::unique_ptr skipList; ret = params.GetArray("skipList", &skipList); @@ -457,8 +486,8 @@ std::unique_ptr StepIntoParams::Create(const PtJson ¶ms) if (listLocation.size()) { paramsObject->skipList_ = std::move(listLocation); } - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'skipList';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'skipList';"; } if (!error.empty()) { @@ -492,8 +521,8 @@ std::unique_ptr StepOverParams::Create(const PtJson ¶ms) if (listLocation.size()) { paramsObject->skipList_ = std::move(listLocation); } - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'skipList';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'skipList';"; } if (!error.empty()) { @@ -514,8 +543,8 @@ std::unique_ptr DropFrameParams::Create(const PtJson ¶ms) ret = params.GetUInt("droppedDepth", &droppedDepth); if (ret == Result::SUCCESS) { paramsObject->droppedDepth_ = droppedDepth; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'droppedDepth';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'droppedDepth';"; } if (!error.empty()) { @@ -536,16 +565,8 @@ std::unique_ptr SetMixedDebugParams::Create(const PtJson &p ret = params.GetBool("enabled", &enabled); if (ret == Result::SUCCESS) { paramsObject->enabled_ = enabled; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'enabled';"; - } - - bool mixedStackEnabled = false; - ret = params.GetBool("mixedStackEnabled", &mixedStackEnabled); - if (ret == Result::SUCCESS) { - paramsObject->mixedStackEnabled_ = mixedStackEnabled; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'enabled';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'enabled';"; } if (!error.empty()) { @@ -566,8 +587,8 @@ std::unique_ptr ReplyNativeCallingParams::Create(const ret = params.GetBool("userCode", &userCode); if (ret == Result::SUCCESS) { paramsObject->userCode_ = userCode; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'userCode';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'userCode';"; } if (!error.empty()) { @@ -589,28 +610,28 @@ std::unique_ptr GetPropertiesParams::Create(const PtJson &p if (ret == Result::SUCCESS) { paramsObject->objectId_ = std::stoi(objectId); } else { - error += "Unknown or wrong type of 'objectId';"; + error += "Unknown 'objectId';"; } bool ownProperties = false; ret = params.GetBool("ownProperties", &ownProperties); if (ret == Result::SUCCESS) { paramsObject->ownProperties_ = ownProperties; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'ownProperties';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'ownProperties';"; } bool accessorPropertiesOnly = false; ret = params.GetBool("accessorPropertiesOnly", &accessorPropertiesOnly); if (ret == Result::SUCCESS) { paramsObject->accessorPropertiesOnly_ = accessorPropertiesOnly; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'accessorPropertiesOnly';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'accessorPropertiesOnly';"; } bool generatePreview = false; ret = params.GetBool("generatePreview", &generatePreview); if (ret == Result::SUCCESS) { paramsObject->generatePreview_ = generatePreview; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'generatePreview';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'generatePreview';"; } if (!error.empty()) { LOG_DEBUGGER(ERROR) << "GetPropertiesParams::Create " << error; @@ -632,15 +653,15 @@ std::unique_ptr CallFunctionOnParams::Create(const PtJson if (ret == Result::SUCCESS) { paramsObject->functionDeclaration_ = std::move(functionDeclaration); } else { - error += "Unknown or wrong type of 'functionDeclaration';"; + error += "Unknown 'functionDeclaration';"; } // paramsObject->objectId_ std::string objectId; ret = params.GetString("objectId", &objectId); if (ret == Result::SUCCESS) { paramsObject->objectId_ = std::stoi(objectId); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'objectId';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'objectId';"; } // paramsObject->arguments_ std::unique_ptr arguments; @@ -660,72 +681,72 @@ std::unique_ptr CallFunctionOnParams::Create(const PtJson if (callArgument.size()) { paramsObject->arguments_ = std::move(callArgument); } - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'arguments';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'arguments';"; } // paramsObject->silent_ bool silent = false; ret = params.GetBool("silent", &silent); if (ret == Result::SUCCESS) { paramsObject->silent_ = silent; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'silent';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'silent';"; } // paramsObject->returnByValue_ bool returnByValue = false; ret = params.GetBool("returnByValue", &returnByValue); if (ret == Result::SUCCESS) { paramsObject->returnByValue_ = returnByValue; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'returnByValue';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'returnByValue';"; } // paramsObject->generatePreview_ bool generatePreview = false; ret = params.GetBool("generatePreview", &generatePreview); if (ret == Result::SUCCESS) { paramsObject->generatePreview_ = generatePreview; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'generatePreview';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'generatePreview';"; } // paramsObject->userGesture_ bool userGesture = false; ret = params.GetBool("userGesture", &userGesture); if (ret == Result::SUCCESS) { paramsObject->userGesture_ = userGesture; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'userGesture';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'userGesture';"; } // paramsObject->awaitPromise_ bool awaitPromise = false; ret = params.GetBool("awaitPromise", &awaitPromise); if (ret == Result::SUCCESS) { paramsObject->awaitPromise_ = awaitPromise; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'awaitPromise';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'awaitPromise';"; } // paramsObject->executionContextId_ int32_t executionContextId; ret = params.GetInt("executionContextId", &executionContextId); if (ret == Result::SUCCESS) { paramsObject->executionContextId_ = executionContextId; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'executionContextId';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'executionContextId';"; } // paramsObject->objectGroup_ std::string objectGroup; ret = params.GetString("objectGroup", &objectGroup); if (ret == Result::SUCCESS) { paramsObject->objectGroup_ = std::move(objectGroup); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'objectGroup';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'objectGroup';"; } // paramsObject->throwOnSideEffect_ bool throwOnSideEffect = false; ret = params.GetBool("throwOnSideEffect", &throwOnSideEffect); if (ret == Result::SUCCESS) { paramsObject->throwOnSideEffect_ = throwOnSideEffect; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'throwOnSideEffect';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'throwOnSideEffect';"; } // Check whether the error is empty. @@ -751,8 +772,8 @@ std::unique_ptr StartSamplingParams::Create(const PtJson &p } else { paramsObject->samplingInterval_ = samplingInterval; } - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'samplingInterval';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'samplingInterval';"; } if (!error.empty()) { @@ -772,8 +793,8 @@ std::unique_ptr StartTrackingHeapObjectsParams:: ret = params.GetBool("trackAllocations", &trackAllocations); if (ret == Result::SUCCESS) { paramsObject->trackAllocations_ = trackAllocations; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'trackAllocations';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'trackAllocations';"; } if (!error.empty()) { @@ -793,24 +814,24 @@ std::unique_ptr StopTrackingHeapObjectsParams::Cr ret = params.GetBool("reportProgress", &reportProgress); if (ret == Result::SUCCESS) { paramsObject->reportProgress_ = reportProgress; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'reportProgress';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'reportProgress';"; } bool treatGlobalObjectsAsRoots = false; ret = params.GetBool("treatGlobalObjectsAsRoots", &treatGlobalObjectsAsRoots); if (ret == Result::SUCCESS) { paramsObject->treatGlobalObjectsAsRoots_ = treatGlobalObjectsAsRoots; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'treatGlobalObjectsAsRoots';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'treatGlobalObjectsAsRoots';"; } bool captureNumericValue = false; ret = params.GetBool("captureNumericValue", &captureNumericValue); if (ret == Result::SUCCESS) { paramsObject->captureNumericValue_ = captureNumericValue; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'captureNumericValue';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'captureNumericValue';"; } if (!error.empty()) { @@ -831,7 +852,7 @@ std::unique_ptr AddInspectedHeapObjectParams::Crea if (ret == Result::SUCCESS) { paramsObject->heapObjectId_ = std::stoi(heapObjectId); } else { - error += "Unknown or wrong type of 'heapObjectId';"; + error += "Unknown 'heapObjectId';"; } if (!error.empty()) { @@ -851,8 +872,8 @@ std::unique_ptr GetHeapObjectIdParams::Create(const PtJso ret = params.GetString("objectId", &objectId); if (ret == Result::SUCCESS) { paramsObject->objectId_ = std::stoi(objectId); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'objectId';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'objectId';"; } if (!error.empty()) { @@ -872,16 +893,16 @@ std::unique_ptr GetObjectByHeapObjectIdParams::Cr ret = params.GetString("objectId", &objectId); if (ret == Result::SUCCESS) { paramsObject->objectId_ = std::stoi(objectId); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'objectId';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'objectId';"; } std::string objectGroup; ret = params.GetString("objectGroup", &objectGroup); if (ret == Result::SUCCESS) { paramsObject->objectGroup_ = std::move(objectGroup); - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'objectGroup';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'objectGroup';"; } if (!error.empty()) { @@ -901,24 +922,24 @@ std::unique_ptr StartPreciseCoverageParams::Create(c ret = params.GetBool("callCount", &callCount); if (ret == Result::SUCCESS) { paramsObject->callCount_ = callCount; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'callCount';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'callCount';"; } bool detailed = false; ret = params.GetBool("detailed", &detailed); if (ret == Result::SUCCESS) { paramsObject->detailed_ = detailed; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'detailed';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'detailed';"; } bool allowTriggeredUpdates = false; ret = params.GetBool("allowTriggeredUpdates", &allowTriggeredUpdates); if (ret == Result::SUCCESS) { paramsObject->allowTriggeredUpdates_ = allowTriggeredUpdates; - } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'allowTriggeredUpdates';"; + } else if (ret == Result::TYPE_ERROR) { // optional value + error += "Unknown 'allowTriggeredUpdates';"; } if (!error.empty()) { @@ -939,7 +960,7 @@ std::unique_ptr SetSamplingIntervalParams::Create(con if (ret == Result::SUCCESS) { paramsObject->interval_ = interval; } else { - error += "Unknown or wrong type of 'interval';"; + error += "Unknown 'interval';"; } if (!error.empty()) { @@ -960,7 +981,7 @@ std::unique_ptr RecordClockSyncMarkerParams::Create if (ret == Result::SUCCESS) { recordClockSyncMarkerParams->syncId_ = syncId; } else { - error += "Unknown or wrong type of 'syncId';"; + error += "Unknown 'syncId';"; } if (!error.empty()) { @@ -982,7 +1003,7 @@ std::unique_ptr RequestMemoryDumpParams::Create(const P if (ret == Result::SUCCESS) { requestMemoryDumpParams->deterministic_ = deterministic; } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'deterministic';"; + error += "Unknown 'deterministic';"; } std::string levelOfDetail; @@ -994,7 +1015,7 @@ std::unique_ptr RequestMemoryDumpParams::Create(const P error += "'levelOfDetail' is invalid;"; } } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'levelOfDetail';"; + error += "Unknown 'levelOfDetail';"; } if (!error.empty()) { @@ -1016,7 +1037,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) if (ret == Result::SUCCESS) { startParams->categories_ = std::move(categories); } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'categories';"; + error += "Unknown 'categories';"; } std::string options; @@ -1024,7 +1045,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) if (ret == Result::SUCCESS) { startParams->options_ = std::move(options); } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'options';"; + error += "Unknown 'options';"; } int32_t bufferUsageReportingInterval = 0; @@ -1032,7 +1053,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) if (ret == Result::SUCCESS) { startParams->bufferUsageReportingInterval_ = bufferUsageReportingInterval; } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'bufferUsageReportingInterval';"; + error += "Unknown 'bufferUsageReportingInterval';"; } std::string transferMode; @@ -1044,7 +1065,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) error += "'transferMode' is invalid;"; } } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'transferMode';"; + error += "Unknown 'transferMode';"; } std::string streamFormat; @@ -1056,7 +1077,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) error += "'streamFormat' is invalid;"; } } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'streamFormat';"; + error += "Unknown 'streamFormat';"; } std::string streamCompression; @@ -1068,7 +1089,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) error += "'streamCompression' is invalid;"; } } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'streamCompression';"; + error += "Unknown 'streamCompression';"; } std::unique_ptr traceConfig; @@ -1076,12 +1097,12 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) if (ret == Result::SUCCESS) { std::unique_ptr pTraceConfig = TraceConfig::Create(*traceConfig); if (pTraceConfig == nullptr) { - error += "'traceConfig' format is invalid;"; + error += "'traceConfig' format invalid;"; } else { startParams->traceConfig_ = std::move(pTraceConfig); } } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'traceConfig';"; + error += "Unknown 'traceConfig';"; } std::string perfettoConfig; @@ -1089,7 +1110,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) if (ret == Result::SUCCESS) { startParams->perfettoConfig_ = std::move(perfettoConfig); } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'perfettoConfig';"; + error += "Unknown 'perfettoConfig';"; } std::string tracingBackend; @@ -1101,7 +1122,7 @@ std::unique_ptr StartParams::Create(const PtJson ¶ms) error += "'tracingBackend' is invalid;"; } } else if (ret == Result::TYPE_ERROR) { - error += "Wrong type of 'tracingBackend';"; + error += "Unknown 'tracingBackend';"; } if (!error.empty()) { diff --git a/tooling/base/pt_params.h b/tooling/base/pt_params.h index 01fac0af..14f60ca7 100644 --- a/tooling/base/pt_params.h +++ b/tooling/base/pt_params.h @@ -33,6 +33,29 @@ private: NO_MOVE_SEMANTIC(PtBaseParams); }; +class ContinueToLocationParams : public PtBaseParams { +public: + ContinueToLocationParams() = default; + ~ContinueToLocationParams() override = default; + + static std::unique_ptr Create(const PtJson ¶ms); + Location *GetLocation() const + { + return location_.get(); + } + const std::string &GetTargetCallFrames() const + { + return targetCallFrames_; + } + + private: + NO_COPY_SEMANTIC(ContinueToLocationParams); + NO_MOVE_SEMANTIC(ContinueToLocationParams); + + std::unique_ptr location_ {nullptr}; + std::string targetCallFrames_ {}; +}; + class EnableParams : public PtBaseParams { public: EnableParams() = default; @@ -508,17 +531,11 @@ public: return enabled_; } - bool GetMixedStackEnabled() const - { - return mixedStackEnabled_; - } - private: NO_COPY_SEMANTIC(SetMixedDebugParams); NO_MOVE_SEMANTIC(SetMixedDebugParams); - bool enabled_ {false}; - bool mixedStackEnabled_ {false}; + bool enabled_ { false }; }; class ReplyNativeCallingParams : public PtBaseParams { @@ -536,7 +553,7 @@ private: NO_COPY_SEMANTIC(ReplyNativeCallingParams); NO_MOVE_SEMANTIC(ReplyNativeCallingParams); - bool userCode_ {false}; + bool userCode_ { false }; }; class GetPropertiesParams : public PtBaseParams { -- Gitee