From 3d477f3a3eea757a49ca621cc579f711f22fccdd Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Fri, 16 Nov 2018 16:40:45 +0000 Subject: Revert^2 "ART: Add StackVisitor accepting a lambda" This reverts commit 8248490f24e8582ce2ead8cd878d8a2c38310a48. Reason for revert: Fixed instrumentation.cc Bug: 115837065 Test: m test-art-host Change-Id: I484833f4712c835fcaf3452dca4cae5b031d5a7d --- runtime/stack.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'runtime/stack.h') diff --git a/runtime/stack.h b/runtime/stack.h index 02578d25b7..9d30115bb1 100644 --- a/runtime/stack.h +++ b/runtime/stack.h @@ -143,6 +143,36 @@ class StackVisitor { template void WalkStack(bool include_transitions = false) REQUIRES_SHARED(Locks::mutator_lock_); + // Convenience helper function to walk the stack with a lambda as a visitor. + template + ALWAYS_INLINE static void WalkStack(const T& fn, + Thread* thread, + Context* context, + StackWalkKind walk_kind, + bool check_suspended = true, + bool include_transitions = false) + REQUIRES_SHARED(Locks::mutator_lock_) { + class LambdaStackVisitor : public StackVisitor { + public: + LambdaStackVisitor(const T& fn, + Thread* thread, + Context* context, + StackWalkKind walk_kind, + bool check_suspended = true) + : StackVisitor(thread, context, walk_kind, check_suspended), fn_(fn) {} + + bool VisitFrame() override REQUIRES_SHARED(Locks::mutator_lock_) { + return fn_(this); + } + + private: + T fn_; + }; + LambdaStackVisitor visitor(fn, thread, context, walk_kind, check_suspended); + visitor.template WalkStack(include_transitions); + } + Thread* GetThread() const { return thread_; } -- cgit v1.2.3-59-g8ed1b