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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 SpinLockHolder l(&heap_lock); | 655 SpinLockHolder l(&heap_lock); |
656 | 656 |
657 if (!is_on) return; | 657 if (!is_on) return; |
658 | 658 |
659 heap_profile->DumpMarkedObjects(HeapProfileTable::MARK_TWO, filename); | 659 heap_profile->DumpMarkedObjects(HeapProfileTable::MARK_TWO, filename); |
660 } | 660 } |
661 | 661 |
662 //---------------------------------------------------------------------- | 662 //---------------------------------------------------------------------- |
663 // Initialization/finalization code | 663 // Initialization/finalization code |
664 //---------------------------------------------------------------------- | 664 //---------------------------------------------------------------------- |
665 | 665 #if defined(ENABLE_PROFILING) |
666 // Initialization code | 666 // Initialization code |
667 static void HeapProfilerInit() { | 667 static void HeapProfilerInit() { |
668 // Everything after this point is for setting up the profiler based on envvar | 668 // Everything after this point is for setting up the profiler based on envvar |
669 char fname[PATH_MAX]; | 669 char fname[PATH_MAX]; |
670 if (!GetUniquePathFromEnv(HEAPPROFILE, fname)) { | 670 if (!GetUniquePathFromEnv(HEAPPROFILE, fname)) { |
671 return; | 671 return; |
672 } | 672 } |
673 // We do a uid check so we don't write out files in a setuid executable. | 673 // We do a uid check so we don't write out files in a setuid executable. |
674 #ifdef HAVE_GETEUID | 674 #ifdef HAVE_GETEUID |
675 if (getuid() != geteuid()) { | 675 if (getuid() != geteuid()) { |
(...skipping 10 matching lines...) Expand all Loading... |
686 | 686 |
687 // class used for finalization -- dumps the heap-profile at program exit | 687 // class used for finalization -- dumps the heap-profile at program exit |
688 struct HeapProfileEndWriter { | 688 struct HeapProfileEndWriter { |
689 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } | 689 ~HeapProfileEndWriter() { HeapProfilerDump("Exiting"); } |
690 }; | 690 }; |
691 | 691 |
692 // We want to make sure tcmalloc is up and running before starting the profiler | 692 // We want to make sure tcmalloc is up and running before starting the profiler |
693 static const TCMallocGuard tcmalloc_initializer; | 693 static const TCMallocGuard tcmalloc_initializer; |
694 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); | 694 REGISTER_MODULE_INITIALIZER(heapprofiler, HeapProfilerInit()); |
695 static HeapProfileEndWriter heap_profile_end_writer; | 695 static HeapProfileEndWriter heap_profile_end_writer; |
| 696 #endif // defined(ENABLE_PROFILING) |
OLD | NEW |