Commit da7325c4 authored by glider@chromium.org's avatar glider@chromium.org

Fix heap profiler to always append the process id to the heap dump.

To run Chrome:
HEAP_PROFILE_ALLOCATION_INTERVAL=1000000 HEAPPROFILE=heapprof out/Debug/chrome

To analyze:
pprof --text out/Debug/chrome  heapprof.21026.0039.heap
pprof --gv out/Debug/chrome  heapprof.21026.0039.heap
(pprof is slooow)
Review URL: http://codereview.chromium.org/6532051

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86273 0039d316-1c4b-4281-b951-d872f2087c98
parent 4c271b9c
...@@ -176,6 +176,9 @@ const char* GetenvBeforeMain(const char* name) { ...@@ -176,6 +176,9 @@ const char* GetenvBeforeMain(const char* name) {
// in their first character! If that assumption is violated, we'll // in their first character! If that assumption is violated, we'll
// still get a profile, but one with an unexpected name. // still get a profile, but one with an unexpected name.
// TODO(csilvers): set an envvar instead when we can do it reliably. // TODO(csilvers): set an envvar instead when we can do it reliably.
//
// In Chromium this hack is intentionally disabled, because the path is not
// re-initialized upon fork.
bool GetUniquePathFromEnv(const char* env_name, char* path) { bool GetUniquePathFromEnv(const char* env_name, char* path) {
char* envval = getenv(env_name); char* envval = getenv(env_name);
if (envval == NULL || *envval == '\0') if (envval == NULL || *envval == '\0')
...@@ -185,7 +188,9 @@ bool GetUniquePathFromEnv(const char* env_name, char* path) { ...@@ -185,7 +188,9 @@ bool GetUniquePathFromEnv(const char* env_name, char* path) {
envval[0] & 127, envval+1, (unsigned int)(getpid())); envval[0] & 127, envval+1, (unsigned int)(getpid()));
} else { } else {
snprintf(path, PATH_MAX, "%s", envval); snprintf(path, PATH_MAX, "%s", envval);
#if 0
envval[0] |= 128; // set high bit for kids to see envval[0] |= 128; // set high bit for kids to see
#endif
} }
return true; return true;
} }
......
...@@ -258,8 +258,8 @@ static void DumpProfileLocked(const char* reason) { ...@@ -258,8 +258,8 @@ static void DumpProfileLocked(const char* reason) {
// Make file name // Make file name
char file_name[1000]; char file_name[1000];
dump_count++; dump_count++;
snprintf(file_name, sizeof(file_name), "%s.%04d%s", snprintf(file_name, sizeof(file_name), "%s.%05d.%04d%s",
filename_prefix, dump_count, HeapProfileTable::kFileExt); filename_prefix, getpid(), dump_count, HeapProfileTable::kFileExt);
// Dump the profile // Dump the profile
RAW_VLOG(0, "Dumping heap profile to %s (%s)", file_name, reason); RAW_VLOG(0, "Dumping heap profile to %s (%s)", file_name, reason);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment