Merge "profiling: Use cmdline instead of binary name."
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index e4e8e70..75137f9 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -117,6 +117,11 @@
}
}
+ # Disable debug log spam if we're embedded in a third-party project.
+ if (!perfetto_build_with_embedder) {
+ defines += [ "PERFETTO_ENABLE_DLOG" ]
+ }
+
include_dirs = [
"..",
"../include",
diff --git a/heapprofd.rc b/heapprofd.rc
index 10bc845..eb5379a 100644
--- a/heapprofd.rc
+++ b/heapprofd.rc
@@ -16,6 +16,6 @@
disabled
socket heapprofd stream 0666 root root
user nobody
- group nobody
+ group nobody readproc
writepid /dev/cpuset/system-background/tasks
capabilities KILL
diff --git a/include/perfetto/base/logging.h b/include/perfetto/base/logging.h
index ab3e027..8da3e0a 100644
--- a/include/perfetto/base/logging.h
+++ b/include/perfetto/base/logging.h
@@ -28,6 +28,12 @@
#define PERFETTO_DCHECK_IS_ON() 1
#endif
+#if defined(PERFETTO_ENABLE_DLOG)
+#define PERFETTO_DLOG_IS_ON() PERFETTO_DCHECK_IS_ON()
+#else
+#define PERFETTO_DLOG_IS_ON() 0
+#endif
+
#include "perfetto/base/build_config.h"
#include "perfetto/base/utils.h"
@@ -114,13 +120,22 @@
#define PERFETTO_PLOG(x, ...) \
PERFETTO_ELOG(x " (errno: %d, %s)", ##__VA_ARGS__, errno, strerror(errno))
-#if PERFETTO_DCHECK_IS_ON()
+#if PERFETTO_DLOG_IS_ON()
#define PERFETTO_DLOG(fmt, ...) PERFETTO_XLOG(kLogDebug, fmt, ##__VA_ARGS__)
#define PERFETTO_DPLOG(x, ...) \
PERFETTO_DLOG(x " (errno: %d, %s)", ##__VA_ARGS__, errno, strerror(errno))
+#else
+
+#define PERFETTO_DLOG(...) ::perfetto::base::ignore_result(__VA_ARGS__)
+#define PERFETTO_DPLOG(...) ::perfetto::base::ignore_result(__VA_ARGS__)
+
+#endif // PERFETTO_DLOG_IS_ON()
+
+#if PERFETTO_DCHECK_IS_ON()
+
#define PERFETTO_DCHECK(x) \
do { \
if (PERFETTO_UNLIKELY(!(x))) { \
@@ -137,8 +152,6 @@
#else
-#define PERFETTO_DLOG(...) ::perfetto::base::ignore_result(__VA_ARGS__)
-#define PERFETTO_DPLOG(...) ::perfetto::base::ignore_result(__VA_ARGS__)
#define PERFETTO_DCHECK(x) ::perfetto::base::ignore_result(x)
#define PERFETTO_DFATAL(...) ::perfetto::base::ignore_result(__VA_ARGS__)
diff --git a/src/profiling/memory/client.cc b/src/profiling/memory/client.cc
index 22f8beb..b802156 100644
--- a/src/profiling/memory/client.cc
+++ b/src/profiling/memory/client.cc
@@ -204,6 +204,10 @@
uint64_t size = 0;
base::ScopedFile maps(base::OpenFile("/proc/self/maps", O_RDONLY));
base::ScopedFile mem(base::OpenFile("/proc/self/mem", O_RDONLY));
+ if (!maps || !mem) {
+ PERFETTO_DFATAL("Failed to open /proc/self/{maps,mem}");
+ return;
+ }
int fds[2];
fds[0] = *maps;
fds[1] = *mem;
@@ -222,6 +226,7 @@
return;
}
PERFETTO_DCHECK(client_config_.interval >= 1);
+ PERFETTO_DLOG("Initialized client.");
inited_ = true;
}
diff --git a/src/profiling/memory/socket_listener.cc b/src/profiling/memory/socket_listener.cc
index 733c6ea..654fe4e 100644
--- a/src/profiling/memory/socket_listener.cc
+++ b/src/profiling/memory/socket_listener.cc
@@ -26,6 +26,8 @@
if (it != process_info_.end()) {
ProcessInfo& process_info = it->second;
process_info.sockets.erase(self);
+ if (process_info.sockets.empty())
+ process_info_.erase(it);
} else {
PERFETTO_DFATAL("Disconnect from socket without ProcessInfo.");
}