diff options
author | csilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2009-09-11 18:42:32 +0000 |
---|---|---|
committer | csilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2009-09-11 18:42:32 +0000 |
commit | 19dfa9e3733155e57406fbd082273eb53cb2750e (patch) | |
tree | 8c000b5035acf1bd01cb7208972e128bbd98e4b2 /src/tests/heap-checker_unittest.cc | |
parent | 2197cc670204c583bba3903b765c77620f349609 (diff) | |
download | gperftools-19dfa9e3733155e57406fbd082273eb53cb2750e.tar.gz |
Thu Sep 10 13:51:15 2009 Google Inc. <opensource@google.com>
* google-perftools: version 1.4 release
* Add debugallocation library, to catch memory leaks, stomping, etc
* Add --raw mode to allow for delayed processing of pprof files
* Use less memory when reading CPU profiles
* New environment variables to control kernel-allocs (sbrk, memfs, etc)
* Add MarkThreadBusy(): performance improvement
* Remove static thread-cache-size code; all is dynamic now
* Add new HiddenPointer class to heap checker
* BUGFIX: pvalloc(0) allocates now (found by new debugalloc library)
* BUGFIX: valloc test (not implementation) no longer overruns memory
* BUGFIX: GetHeapProfile no longer deadlocks
* BUGFIX: Support unmapping memory regions before main
* BUGFIX: Fix some malloc-stats formatting
* BUGFIX: Don't crash as often when freeing libc-allocated memory
* BUGFIX: Deal better with incorrect PPROF_PATH when symbolizing
* BUGFIX: weaken new/delete/etc in addition to malloc/free/etc
* BUGFIX: Fix return value of GetAllocatedSize
* PORTING: Fix mmap-#define problem on some 64-bit systems
* PORTING: Call ranlib again (some OS X versions need it)
* PORTING: Fix a leak when building with LLVM
* PORTING: Remove some unneeded bash-ishs from testing scripts
* WINDOWS: Support library unloading as well as loading
* WINDOWS/BUGFIX: Set page to 'xrw' instead of 'rw' when patching
git-svn-id: http://gperftools.googlecode.com/svn/trunk@76 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
Diffstat (limited to 'src/tests/heap-checker_unittest.cc')
-rw-r--r-- | src/tests/heap-checker_unittest.cc | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/tests/heap-checker_unittest.cc b/src/tests/heap-checker_unittest.cc index 55b6a21..4be1a7c 100644 --- a/src/tests/heap-checker_unittest.cc +++ b/src/tests/heap-checker_unittest.cc @@ -1,10 +1,10 @@ // Copyright (c) 2005, Google Inc. // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: -// +// // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -58,7 +58,9 @@ // (see the comment in our .h file). #include "config_for_unittests.h" -#include <sys/poll.h> +#ifdef HAVE_POLL_H +#include <poll.h> +#endif #if defined HAVE_STDINT_H #include <stdint.h> // to get uint16_t (ISO naming madness) #elif defined HAVE_INTTYPES_H @@ -539,6 +541,20 @@ static void TestHeapLeakCheckerDeathCountMore() { DeAllocHidden(&bar2); } +static void TestHiddenPointer() { + int i; + void* foo = &i; + HiddenPointer<void> p(foo); + CHECK_EQ(foo, p.get()); + + // Confirm pointer doesn't appear to contain a byte sequence + // that == the pointer. We don't really need to test that + // the xor trick itself works, as without it nothing in this + // test suite would work. See the Hide/Unhide/*Hidden* set + // of helper methods. + CHECK_NE(foo, *reinterpret_cast<void**>(&p)); +} + // simple tests that deallocate what they allocated static void TestHeapLeakChecker() { { HeapLeakChecker check("trivial"); @@ -1304,7 +1320,6 @@ static int Pass() { int main(int argc, char** argv) { run_hidden_ptr = DoRunHidden; wipe_stack_ptr = DoWipeStack; - if (!HeapLeakChecker::IsActive()) { CHECK_EQ(FLAGS_heap_check, ""); LOG(WARNING, "HeapLeakChecker got turned off; we won't test much..."); @@ -1376,6 +1391,8 @@ int main(int argc, char** argv) { HeapLeakChecker heap_check("all"); + TestHiddenPointer(); + TestHeapLeakChecker(); Pause(); TestLeakButTotalsMatch(); @@ -1443,6 +1460,6 @@ int main(int argc, char** argv) { } CHECK(HeapLeakChecker::NoGlobalLeaks()); // so far, so good - + return Pass(); } |