diff options
| author | 2017-12-08 02:58:59 +0000 | |
|---|---|---|
| committer | 2017-12-08 02:58:59 +0000 | |
| commit | f223f76bdd360664a1e8068eeac6ce35f7392bc6 (patch) | |
| tree | d3d0a8f6cb7841b0052301d22963e1978ff0563f | |
| parent | d5153627778e71ef68b510ce03c77467fa4d85bd (diff) | |
| parent | dfebbac8e30172169dbdaaf7e6a0be51433d57f1 (diff) | |
Merge "ART: Add ScopedTrace constructor with lambda"
| -rw-r--r-- | runtime/base/systrace.h | 13 | ||||
| -rw-r--r-- | runtime/verifier/method_verifier.cc | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/runtime/base/systrace.h b/runtime/base/systrace.h index 06db48a576..c6b6ff1d43 100644 --- a/runtime/base/systrace.h +++ b/runtime/base/systrace.h @@ -23,6 +23,8 @@ #include <string> +#include "android-base/stringprintf.h" + namespace art { class ScopedTrace { @@ -30,6 +32,12 @@ class ScopedTrace { explicit ScopedTrace(const char* name) { ATRACE_BEGIN(name); } + template <typename Fn> + explicit ScopedTrace(Fn fn) { + if (ATRACE_ENABLED()) { + ATRACE_BEGIN(fn().c_str()); + } + } explicit ScopedTrace(const std::string& name) : ScopedTrace(name.c_str()) {} @@ -38,6 +46,11 @@ class ScopedTrace { } }; +#define SCOPED_TRACE(fmtstr, ...) \ + ::art::ScopedTrace trace ## __LINE__([&]() { \ + return ::android::base::StringPrintf((fmtstr), __VA_ARGS__); \ + }) + } // namespace art #endif // ART_RUNTIME_BASE_SYSTRACE_H_ diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index f1af2529bd..cd428272e7 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -282,7 +282,7 @@ FailureKind MethodVerifier::VerifyClass(Thread* self, bool allow_soft_failures, HardFailLogMode log_level, std::string* error) { - ScopedTrace trace(__FUNCTION__); + SCOPED_TRACE("VerifyClass %s", PrettyDescriptor(dex_file->GetClassDescriptor(class_def)).c_str()); // A class must not be abstract and final. if ((class_def.access_flags_ & (kAccAbstract | kAccFinal)) == (kAccAbstract | kAccFinal)) { |