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

Unified Diff: content/browser/tracing/trace_message_filter.cc

Issue 1329273002: [tracing] Send smaps file desciptor to child process for tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 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
« no previous file with comments | « components/tracing/tracing_messages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tracing/trace_message_filter.cc
diff --git a/content/browser/tracing/trace_message_filter.cc b/content/browser/tracing/trace_message_filter.cc
index a26c6542b39d379c2094191fd1e94731b608eab0..6d4c6d1e32b4024ea79da20b97107cfa6c983df2 100644
--- a/content/browser/tracing/trace_message_filter.cc
+++ b/content/browser/tracing/trace_message_filter.cc
@@ -9,6 +9,33 @@
#include "content/browser/tracing/tracing_controller_impl.h"
#include "content/common/child_process_host_impl.h"
+#if defined(OS_LINUX)
+#include <fcntl.h>
+#endif
+
+namespace {
+
+void OpenFilesForProcess(int pid,
+ TracingMsg_MemoryTracingInfo& memory_tracing_info) {
+#if defined(OS_LINUX)
+ std::string proc_smaps_name = base::StringPrintf("/proc/%d/smaps", pid);
+ int smaps_fd = HANDLE_EINTR(open(proc_smaps_name.c_str(), O_RDONLY));
+ if (smaps_fd != -1) {
+ memory_tracing_info.smaps_fd = IPC::GetFileHandleForProcess(
+ smaps_fd, base::GetCurrentProcessHandle(), true);
+ }
+
+ std::string proc_status_name = base::StringPrintf("/proc/%d/status", pid);
+ int status_fd = HANDLE_EINTR(open(proc_status_name.c_str(), O_RDONLY));
+ if (status_fd != -1) {
+ memory_tracing_info.status_fd = IPC::GetFileHandleForProcess(
+ status_fd, base::GetCurrentProcessHandle(), true);
+ }
+#endif
+}
+
+} // namespace
+
namespace content {
TraceMessageFilter::TraceMessageFilter(int child_process_id)
@@ -69,9 +96,15 @@ bool TraceMessageFilter::OnMessageReceived(const IPC::Message& message) {
void TraceMessageFilter::SendBeginTracing(
const base::trace_event::TraceConfig& trace_config) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ TracingMsg_MemoryTracingInfo memory_tracing_info;
+ if (trace_config.IsDetailedMemoryDumpEnabled()) {
+ if (trace_config.IsDetailedMemoryDumpEnabled()) {
+ OpenFilesForProcess(this->peer_pid(), memory_tracing_info);
+ }
+ memory_tracing_info.tracing_process_id = tracing_process_id_;
+ }
Send(new TracingMsg_BeginTracing(
- trace_config.ToString(), base::TraceTicks::Now(), tracing_process_id_));
+ trace_config.ToString(), base::TraceTicks::Now(), memory_tracing_info));
}
void TraceMessageFilter::SendEndTracing() {
« no previous file with comments | « components/tracing/tracing_messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698