summaryrefslogtreecommitdiff
path: root/runtime/stack.h
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2018-11-16 16:40:45 +0000
committer Andreas Gampe <agampe@google.com> 2018-11-16 10:13:38 -0800
commit3d477f3a3eea757a49ca621cc579f711f22fccdd (patch)
treeb4b402d0181610c62062c8c597ef30ee2840b6b1 /runtime/stack.h
parent54c7da9c50ee85ade636605cd6ea18b4c2bc69fa (diff)
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
Diffstat (limited to 'runtime/stack.h')
-rw-r--r--runtime/stack.h30
1 files changed, 30 insertions, 0 deletions
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 <CountTransitions kCount = CountTransitions::kYes>
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 <CountTransitions kCountTransitions = CountTransitions::kYes,
+ typename T>
+ 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<kCountTransitions>(include_transitions);
+ }
+
Thread* GetThread() const {
return thread_;
}