ART: Move trace options to a struct
Bundles the different options and moves them to a struct in the
implementation file. Will allow for easier change for streaming.
Change-Id: I486e0942614e714964eb233e2d6b4e3e12aa704f
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index b5d2e15..7998f16 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -130,6 +130,13 @@
static constexpr bool kEnableJavaStackTraceHandler = false;
Runtime* Runtime::instance_ = nullptr;
+struct TraceConfig {
+ Trace::TraceMode trace_mode;
+ Trace::TraceOutputMode trace_output_mode;
+ std::string trace_file;
+ size_t trace_file_size;
+};
+
Runtime::Runtime()
: instruction_set_(kNone),
compiler_callbacks_(nullptr),
@@ -163,8 +170,6 @@
stats_enabled_(false),
running_on_valgrind_(RUNNING_ON_VALGRIND > 0),
profiler_started_(false),
- method_trace_(false),
- method_trace_file_size_(0),
instrumentation_(),
main_thread_group_(nullptr),
system_thread_group_(nullptr),
@@ -980,9 +985,13 @@
verifier::MethodVerifier::Init();
- method_trace_ = runtime_options.Exists(Opt::MethodTrace);
- method_trace_file_ = runtime_options.ReleaseOrDefault(Opt::MethodTraceFile);
- method_trace_file_size_ = runtime_options.ReleaseOrDefault(Opt::MethodTraceFileSize);
+ if (runtime_options.Exists(Opt::MethodTrace)) {
+ trace_config_.reset(new TraceConfig());
+ trace_config_->trace_file = runtime_options.ReleaseOrDefault(Opt::MethodTraceFile);
+ trace_config_->trace_file_size = runtime_options.ReleaseOrDefault(Opt::MethodTraceFileSize);
+ trace_config_->trace_mode = Trace::TraceMode::kMethodTracing;
+ trace_config_->trace_output_mode = Trace::TraceOutputMode::kFile;
+ }
{
auto&& profiler_options = runtime_options.ReleaseOrDefault(Opt::ProfilerOpts);
@@ -1007,14 +1016,14 @@
// TODO: move this to just be an Trace::Start argument
Trace::SetDefaultClockSource(runtime_options.GetOrDefault(Opt::ProfileClock));
- if (method_trace_) {
+ if (trace_config_.get() != nullptr) {
ScopedThreadStateChange tsc(self, kWaitingForMethodTracingStart);
- Trace::Start(method_trace_file_.c_str(),
+ Trace::Start(trace_config_->trace_file.c_str(),
-1,
- static_cast<int>(method_trace_file_size_),
+ static_cast<int>(trace_config_->trace_file_size),
0,
- Trace::TraceOutputMode::kFile,
- Trace::TraceMode::kMethodTracing,
+ trace_config_->trace_output_mode,
+ trace_config_->trace_mode,
0);
}
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 64b7183..68458ae 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -81,6 +81,7 @@
class SuspensionHandler;
class ThreadList;
class Trace;
+struct TraceConfig;
class Transaction;
typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions;
@@ -675,9 +676,8 @@
ProfilerOptions profiler_options_;
bool profiler_started_;
- bool method_trace_;
- std::string method_trace_file_;
- size_t method_trace_file_size_;
+ std::unique_ptr<TraceConfig> trace_config_;
+
instrumentation::Instrumentation instrumentation_;
jobject main_thread_group_;