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

Side by Side Diff: third_party/tcmalloc/chromium/src/heap-checker.cc

Issue 440027: Merge r77 from upstream tcmalloc to the local chromium branch.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 29 matching lines...) Expand all
40 #include <errno.h> 40 #include <errno.h>
41 #ifdef HAVE_UNISTD_H 41 #ifdef HAVE_UNISTD_H
42 #include <unistd.h> 42 #include <unistd.h>
43 #endif 43 #endif
44 #ifdef HAVE_MMAP 44 #ifdef HAVE_MMAP
45 #include <sys/mman.h> 45 #include <sys/mman.h>
46 #endif 46 #endif
47 #ifdef HAVE_PTHREAD 47 #ifdef HAVE_PTHREAD
48 #include <pthread.h> 48 #include <pthread.h>
49 #endif 49 #endif
50 #ifdef HAVE_POLL_H
51 #include <poll.h>
52 #endif
50 #include <sys/stat.h> 53 #include <sys/stat.h>
51 #include <sys/types.h> 54 #include <sys/types.h>
52 #include <time.h>
53 #include <assert.h> 55 #include <assert.h>
54 56
55 #ifdef HAVE_LINUX_PTRACE_H 57 #ifdef HAVE_LINUX_PTRACE_H
56 #include <linux/ptrace.h> 58 #include <linux/ptrace.h>
57 #endif 59 #endif
58 #ifdef HAVE_SYS_SYSCALL_H 60 #ifdef HAVE_SYS_SYSCALL_H
59 #include <sys/syscall.h> 61 #include <sys/syscall.h>
60 #endif 62 #endif
61 #if defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) || defined(_ _MINGW32__) 63 #if defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) || defined(_ _MINGW32__)
62 #include <wtypes.h> 64 #include <wtypes.h>
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 } 2291 }
2290 2292
2291 // This function is executed after all global object destructors run. 2293 // This function is executed after all global object destructors run.
2292 void HeapLeakChecker_AfterDestructors() { 2294 void HeapLeakChecker_AfterDestructors() {
2293 { SpinLockHolder l(&heap_checker_lock); 2295 { SpinLockHolder l(&heap_checker_lock);
2294 // can get here (via forks?) with other pids 2296 // can get here (via forks?) with other pids
2295 if (heap_checker_pid != getpid()) return; 2297 if (heap_checker_pid != getpid()) return;
2296 } 2298 }
2297 if (FLAGS_heap_check_after_destructors) { 2299 if (FLAGS_heap_check_after_destructors) {
2298 if (HeapLeakChecker::DoMainHeapCheck()) { 2300 if (HeapLeakChecker::DoMainHeapCheck()) {
2299 const struct timespec sleep_time = { 0, 500000000 }; // 500 ms 2301 poll(0, 0, 500);
2300 nanosleep(&sleep_time, NULL);
2301 // Need this hack to wait for other pthreads to exit. 2302 // Need this hack to wait for other pthreads to exit.
2302 // Otherwise tcmalloc find errors 2303 // Otherwise tcmalloc find errors
2303 // on a free() call from pthreads. 2304 // on a free() call from pthreads.
2304 } 2305 }
2305 } 2306 }
2306 SpinLockHolder l(&heap_checker_lock); 2307 SpinLockHolder l(&heap_checker_lock);
2307 RAW_CHECK(!do_main_heap_check, "should have done it"); 2308 RAW_CHECK(!do_main_heap_check, "should have done it");
2308 } 2309 }
2309 2310
2310 //---------------------------------------------------------------------- 2311 //----------------------------------------------------------------------
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 // static 2361 // static
2361 const void* HeapLeakChecker::GetAllocCaller(void* ptr) { 2362 const void* HeapLeakChecker::GetAllocCaller(void* ptr) {
2362 // this is used only in the unittest, so the heavy checks are fine 2363 // this is used only in the unittest, so the heavy checks are fine
2363 HeapProfileTable::AllocInfo info; 2364 HeapProfileTable::AllocInfo info;
2364 { SpinLockHolder l(&heap_checker_lock); 2365 { SpinLockHolder l(&heap_checker_lock);
2365 RAW_CHECK(heap_profile->FindAllocDetails(ptr, &info), ""); 2366 RAW_CHECK(heap_profile->FindAllocDetails(ptr, &info), "");
2366 } 2367 }
2367 RAW_CHECK(info.stack_depth >= 1, ""); 2368 RAW_CHECK(info.stack_depth >= 1, "");
2368 return info.call_stack[0]; 2369 return info.call_stack[0];
2369 } 2370 }
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/google/malloc_extension_c.h ('k') | third_party/tcmalloc/chromium/src/malloc_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698