Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2698)

Unified Diff: base/process_util_posix.cc

Issue 10411047: Type profiler by intercepting 'new' and 'delete' expressions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload again Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/process_util_posix.cc
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index a6e816af4484eeeb545cded16f9e4dd25533a62b..37c64aeca22c2dfd803302ca3b387cd296eaa8b0 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -33,6 +33,13 @@
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
+// TODO(dmikurube): Consider always calling {Suspend|Resume}AllocatedType...,
+// and make them empty functions when !USE_ALLOCATED_TYPE.
+// This is a temporary comment which should be removed when landing.
+#ifdef USE_ALLOCATED_TYPE
+#include "base/allocator/allocated_type_tcmalloc.h"
+#endif
+
#if defined(OS_CHROMEOS)
#include <sys/ioctl.h>
#endif
@@ -641,6 +648,9 @@ bool LaunchProcess(const std::vector<std::string>& argv,
}
if (options.maximize_rlimits) {
+#ifdef USE_ALLOCATED_TYPE
+ SuspendAllocatedTypeIntercept();
+#endif
// Some resource limits need to be maximal in this child.
std::set<int>::const_iterator resource;
for (resource = options.maximize_rlimits->begin();
@@ -656,6 +666,9 @@ bool LaunchProcess(const std::vector<std::string>& argv,
}
}
}
+#ifdef USE_ALLOCATED_TYPE
+ ResumeAllocatedTypeIntercept();
+#endif
}
#if defined(OS_MACOSX)
@@ -698,32 +711,54 @@ bool LaunchProcess(const std::vector<std::string>& argv,
#endif // defined(OS_CHROMEOS)
if (options.fds_to_remap) {
+#ifdef USE_ALLOCATED_TYPE
+ SuspendAllocatedTypeIntercept();
+#endif
for (FileHandleMappingVector::const_iterator
it = options.fds_to_remap->begin();
it != options.fds_to_remap->end(); ++it) {
fd_shuffle1.push_back(InjectionArc(it->first, it->second, false));
fd_shuffle2.push_back(InjectionArc(it->first, it->second, false));
}
+#ifdef USE_ALLOCATED_TYPE
+ ResumeAllocatedTypeIntercept();
+#endif
}
#if defined(OS_MACOSX)
if (options.synchronize) {
+#ifdef USE_ALLOCATED_TYPE
+ SuspendAllocatedTypeIntercept();
+#endif
// Remap the read side of the synchronization pipe back onto itself,
// ensuring that it won't be closed by CloseSuperfluousFds.
int keep_fd = *synchronization_read_fd.get();
fd_shuffle1.push_back(InjectionArc(keep_fd, keep_fd, false));
fd_shuffle2.push_back(InjectionArc(keep_fd, keep_fd, false));
+#ifdef USE_ALLOCATED_TYPE
+ ResumeAllocatedTypeIntercept();
+#endif
}
#endif // defined(OS_MACOSX)
if (options.environ)
SetEnvironment(new_environ.get());
+#ifdef USE_ALLOCATED_TYPE
+ SuspendAllocatedTypeIntercept();
+#endif
// fd_shuffle1 is mutated by this call because it cannot malloc.
- if (!ShuffleFileDescriptors(&fd_shuffle1))
+ if (!ShuffleFileDescriptors(&fd_shuffle1)) {
+#ifdef USE_ALLOCATED_TYPE
+ ResumeAllocatedTypeIntercept();
+#endif
_exit(127);
+ }
CloseSuperfluousFds(fd_shuffle2);
+#ifdef USE_ALLOCATED_TYPE
+ ResumeAllocatedTypeIntercept();
+#endif
#if defined(OS_MACOSX)
if (options.synchronize) {
@@ -743,9 +778,17 @@ bool LaunchProcess(const std::vector<std::string>& argv,
}
#endif // defined(OS_MACOSX)
+#ifdef USE_ALLOCATED_TYPE
+ SuspendAllocatedTypeIntercept();
+#endif
for (size_t i = 0; i < argv.size(); i++)
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
argv_cstr[argv.size()] = NULL;
+#ifdef USE_ALLOCATED_TYPE
+ // TODO(dmikurube): Consider removing it. It's just befor exec.
+ // This is a temporary comment which should be removed when landing.
+ ResumeAllocatedTypeIntercept();
+#endif
execvp(argv_cstr[0], argv_cstr.get());
RAW_LOG(ERROR, "LaunchProcess: failed to execvp:");
@@ -1108,6 +1151,9 @@ static GetAppOutputInternalResult GetAppOutputInternal(
if (dev_null < 0)
_exit(127);
+#ifdef USE_ALLOCATED_TYPE
+ SuspendAllocatedTypeIntercept();
+#endif
fd_shuffle1.push_back(InjectionArc(pipe_fd[1], STDOUT_FILENO, true));
fd_shuffle1.push_back(InjectionArc(dev_null, STDERR_FILENO, true));
fd_shuffle1.push_back(InjectionArc(dev_null, STDIN_FILENO, true));
@@ -1117,14 +1163,23 @@ static GetAppOutputInternalResult GetAppOutputInternal(
std::copy(fd_shuffle1.begin(), fd_shuffle1.end(),
std::back_inserter(fd_shuffle2));
- if (!ShuffleFileDescriptors(&fd_shuffle1))
+ if (!ShuffleFileDescriptors(&fd_shuffle1)) {
+#ifdef USE_ALLOCATED_TYPE
+ ResumeAllocatedTypeIntercept();
+#endif
_exit(127);
+ }
CloseSuperfluousFds(fd_shuffle2);
for (size_t i = 0; i < argv.size(); i++)
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
argv_cstr[argv.size()] = NULL;
+#ifdef USE_ALLOCATED_TYPE
+ // TODO(dmikurube): Consider removing it. It's just befor exec.
+ // This is a temporary comment which should be removed when landing.
+ ResumeAllocatedTypeIntercept();
+#endif
if (do_search_path)
execvp(argv_cstr[0], argv_cstr.get());
else

Powered by Google App Engine
This is Rietveld 408576698