summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/native/dalvik_system_ZygoteHooks.cc28
-rw-r--r--runtime/os.h4
-rw-r--r--runtime/os_linux.cc12
-rw-r--r--runtime/runtime_options.def2
-rw-r--r--runtime/trace.cc2
5 files changed, 27 insertions, 21 deletions
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc
index 1d067063a4..a27c9ce5bc 100644
--- a/runtime/native/dalvik_system_ZygoteHooks.cc
+++ b/runtime/native/dalvik_system_ZygoteHooks.cc
@@ -171,23 +171,17 @@ static void ZygoteHooks_nativePostForkChild(JNIEnv* env, jclass, jlong token, ji
proc_name = StringPrintf("%u", static_cast<uint32_t>(pid));
}
- std::string profiles_dir(GetDalvikCache("profiles", false /* create_if_absent */));
- if (!profiles_dir.empty()) {
- std::string trace_file = StringPrintf("%s/%s.trace.bin", profiles_dir.c_str(),
- proc_name.c_str());
- Trace::Start(trace_file.c_str(),
- -1,
- buffer_size,
- 0, // TODO: Expose flags.
- output_mode,
- trace_mode,
- 0); // TODO: Expose interval.
- if (thread->IsExceptionPending()) {
- ScopedObjectAccess soa(env);
- thread->ClearException();
- }
- } else {
- LOG(ERROR) << "Profiles dir is empty?!?!";
+ std::string trace_file = StringPrintf("/data/misc/trace/%s.trace.bin", proc_name.c_str());
+ Trace::Start(trace_file.c_str(),
+ -1,
+ buffer_size,
+ 0, // TODO: Expose flags.
+ output_mode,
+ trace_mode,
+ 0); // TODO: Expose interval.
+ if (thread->IsExceptionPending()) {
+ ScopedObjectAccess soa(env);
+ thread->ClearException();
}
}
}
diff --git a/runtime/os.h b/runtime/os.h
index befe2e808a..46d89fb8a5 100644
--- a/runtime/os.h
+++ b/runtime/os.h
@@ -39,6 +39,10 @@ class OS {
// already exists, it is *not* overwritten, but unlinked, and a new inode will be used.
static File* CreateEmptyFile(const char* name);
+ // Create an empty file with write access. This is a *new* file, that is, if the file
+ // already exists, it is *not* overwritten, but unlinked, and a new inode will be used.
+ static File* CreateEmptyFileWriteOnly(const char* name);
+
// Open a file with the specified open(2) flags.
static File* OpenFileWithFlags(const char* name, int flags);
diff --git a/runtime/os_linux.cc b/runtime/os_linux.cc
index 675699daea..f45e9f6030 100644
--- a/runtime/os_linux.cc
+++ b/runtime/os_linux.cc
@@ -35,12 +35,20 @@ File* OS::OpenFileReadWrite(const char* name) {
return OpenFileWithFlags(name, O_RDWR);
}
-File* OS::CreateEmptyFile(const char* name) {
+static File* CreateEmptyFile(const char* name, int extra_flags) {
// In case the file exists, unlink it so we get a new file. This is necessary as the previous
// file may be in use and must not be changed.
unlink(name);
- return OpenFileWithFlags(name, O_RDWR | O_CREAT | O_TRUNC);
+ return OS::OpenFileWithFlags(name, O_CREAT | extra_flags);
+}
+
+File* OS::CreateEmptyFile(const char* name) {
+ return art::CreateEmptyFile(name, O_RDWR | O_TRUNC);
+}
+
+File* OS::CreateEmptyFileWriteOnly(const char* name) {
+ return art::CreateEmptyFile(name, O_WRONLY | O_TRUNC | O_NOFOLLOW | O_CLOEXEC);
}
File* OS::OpenFileWithFlags(const char* name, int flags) {
diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def
index 7b5bc1ad9a..c96ff03b1b 100644
--- a/runtime/runtime_options.def
+++ b/runtime/runtime_options.def
@@ -97,7 +97,7 @@ RUNTIME_OPTIONS_KEY (LogVerbosity, Verbose)
RUNTIME_OPTIONS_KEY (unsigned int, LockProfThreshold)
RUNTIME_OPTIONS_KEY (std::string, StackTraceFile)
RUNTIME_OPTIONS_KEY (Unit, MethodTrace)
-RUNTIME_OPTIONS_KEY (std::string, MethodTraceFile, "/data/method-trace-file.bin")
+RUNTIME_OPTIONS_KEY (std::string, MethodTraceFile, "/data/misc/trace/method-trace-file.bin")
RUNTIME_OPTIONS_KEY (unsigned int, MethodTraceFileSize, 10 * MB)
RUNTIME_OPTIONS_KEY (Unit, MethodTraceStreaming)
RUNTIME_OPTIONS_KEY (TraceClockSource, ProfileClock, kDefaultTraceClockSource) // -Xprofile:
diff --git a/runtime/trace.cc b/runtime/trace.cc
index ab342aa882..5815f7a97c 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -331,7 +331,7 @@ void Trace::Start(const char* trace_filename, int trace_fd, size_t buffer_size,
std::unique_ptr<File> trace_file;
if (output_mode != TraceOutputMode::kDDMS) {
if (trace_fd < 0) {
- trace_file.reset(OS::CreateEmptyFile(trace_filename));
+ trace_file.reset(OS::CreateEmptyFileWriteOnly(trace_filename));
} else {
trace_file.reset(new File(trace_fd, "tracefile"));
trace_file->DisableAutoClose();