OLD | NEW |
1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 "Are you using another MallocHook client? " | 251 "Are you using another MallocHook client? " |
252 "Do not use --heap_profile=... to avoid this conflict."); | 252 "Do not use --heap_profile=... to avoid this conflict."); |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 dumping = true; | 256 dumping = true; |
257 | 257 |
258 // Make file name | 258 // Make file name |
259 char file_name[1000]; | 259 char file_name[1000]; |
260 dump_count++; | 260 dump_count++; |
261 snprintf(file_name, sizeof(file_name), "%s.%04d%s", | 261 snprintf(file_name, sizeof(file_name), "%s.%05d.%04d%s", |
262 filename_prefix, dump_count, HeapProfileTable::kFileExt); | 262 filename_prefix, getpid(), dump_count, HeapProfileTable::kFileExt); |
263 | 263 |
264 // Dump the profile | 264 // Dump the profile |
265 RAW_VLOG(0, "Dumping heap profile to %s (%s)", file_name, reason); | 265 RAW_VLOG(0, "Dumping heap profile to %s (%s)", file_name, reason); |
266 // We must use file routines that don't access memory, since we hold | 266 // We must use file routines that don't access memory, since we hold |
267 // a memory lock now. | 267 // a memory lock now. |
268 RawFD fd = RawOpenForWriting(file_name); | 268 RawFD fd = RawOpenForWriting(file_name); |
269 if (fd == kIllegalRawFD) { | 269 if (fd == kIllegalRawFD) { |
270 RAW_LOG(ERROR, "Failed dumping heap profile to %s", file_name); | 270 RAW_LOG(ERROR, "Failed dumping heap profile to %s", file_name); |
271 dumping = false; | 271 dumping = false; |
272 return; | 272 return; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 612 |
613 // class used for finalization -- dumps the heap-profile at program exit | 613 // class used for finalization -- dumps the heap-profile at program exit |
614 struct HeapProfileEndWriter { | 614 struct HeapProfileEndWriter { |
615 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } | 615 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } |
616 }; | 616 }; |
617 | 617 |
618 // We want to make sure tcmalloc is up and running before starting the profiler | 618 // We want to make sure tcmalloc is up and running before starting the profiler |
619 static const TCMallocGuard tcmalloc_initializer; | 619 static const TCMallocGuard tcmalloc_initializer; |
620 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); | 620 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); |
621 static HeapProfileEndWriter heap_profile_end_writer; | 621 static HeapProfileEndWriter heap_profile_end_writer; |
OLD | NEW |