diff --git a/runtime/include/tooling/debug_interface.h b/runtime/include/tooling/debug_interface.h index 59cecef5c637de44e9556491dedd3c94710ff93f..810e07ce4d697c46d550584dac2e53363a882ee7 100644 --- a/runtime/include/tooling/debug_interface.h +++ b/runtime/include/tooling/debug_interface.h @@ -398,7 +398,8 @@ public: * @param location Breakpoint location * @return Error if any errors occur */ - virtual std::optional SetBreakpoint(const PtLocation &location) = 0; + virtual std::optional SetBreakpoint(const PtLocation &location, + const std::optional &condition) = 0; /** * \brief Remove breakpoint from \param location diff --git a/runtime/tooling/debugger.cpp b/runtime/tooling/debugger.cpp index 2a49d29620eccec9c296eb89954e2338e46f7be4..0a0d9836a652624f93f8a316d8258f09d641ce08 100644 --- a/runtime/tooling/debugger.cpp +++ b/runtime/tooling/debugger.cpp @@ -64,7 +64,7 @@ std::optional Debugger::SetNotification(PtThread thread, bool enable, PtH return {}; } -std::optional Debugger::SetBreakpoint(const PtLocation &location) +std::optional Debugger::SetBreakpoint(const PtLocation &location, const std::optional &condition) { Method *method = runtime_->GetClassLinker()->GetMethod(location.GetPandaFile(), location.GetMethodId()); if (method == nullptr) { @@ -80,7 +80,7 @@ std::optional Debugger::SetBreakpoint(const PtLocation &location) std::to_string(method->GetCodeSize()) + ")"); } - if (!breakpoints_.emplace(method, location.GetBytecodeOffset()).second) { + if (!breakpoints_.emplace(method, location.GetBytecodeOffset(), condition).second) { return Error(Error::Type::BREAKPOINT_ALREADY_EXISTS, std::string("Breakpoint already exists: bytecode offset ") + std::to_string(location.GetBytecodeOffset())); diff --git a/runtime/tooling/debugger.h b/runtime/tooling/debugger.h index b12d9e551f044c2457b8cb529e22ef99c48f23e7..7cd0deaf69fd44477adf9e22d6e701f4b503b931 100644 --- a/runtime/tooling/debugger.h +++ b/runtime/tooling/debugger.h @@ -41,7 +41,8 @@ namespace panda::tooling { class Breakpoint { public: // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) - Breakpoint(Method *method, uint32_t bcOffset) : method_(method), bc_offset_(bcOffset) {} + Breakpoint(Method *method, uint32_t bcOffset, const std::optional &condition = {}) + : method_(method), bc_offset_(bcOffset), condition_(condition) {} ~Breakpoint() = default; Method *GetMethod() const @@ -49,6 +50,16 @@ public: return method_; } + const std::string &GetCondition() const + { + return condition_.value(); + } + + bool HasCondition() const + { + return condition_.has_value(); + } + uint32_t GetBytecodeOffset() const { return bc_offset_; @@ -65,6 +76,7 @@ public: private: Method *method_; uint32_t bc_offset_; + std::optional condition_; }; class HashBreakpoint { @@ -160,7 +172,7 @@ public: } std::optional SetNotification(PtThread thread, bool enable, PtHookType hookType) override; - std::optional SetBreakpoint(const PtLocation &location) override; + std::optional SetBreakpoint(const PtLocation &location, const std::optional &condition) override; std::optional RemoveBreakpoint(const PtLocation &location) override;