| Index: base/win/scoped_handle.h
|
| ===================================================================
|
| --- base/win/scoped_handle.h (revision 140907)
|
| +++ base/win/scoped_handle.h (working copy)
|
| @@ -16,6 +16,18 @@
|
| namespace base {
|
| namespace win {
|
|
|
| +// TODO(rvargas): remove this with the rest of the verifier.
|
| +#if defined(COMPILER_MSVC)
|
| +// MSDN says to #include <intrin.h>, but that breaks the VS2005 build.
|
| +extern "C" {
|
| + void* _ReturnAddress();
|
| +}
|
| +#define BASE_WIN_GET_CALLER _ReturnAddress()
|
| +#elif defined(COMPILER_GCC)
|
| +#define BASE_WIN_GET_CALLER __builtin_extract_return_addr(\\
|
| + __builtin_return_address(0))
|
| +#endif
|
| +
|
| // Generic wrapper for raw handles that takes care of closing handles
|
| // automatically. The class interface follows the style of
|
| // the ScopedStdioHandle class with a few additions:
|
| @@ -48,7 +60,7 @@
|
|
|
| if (Traits::IsHandleValid(handle)) {
|
| handle_ = handle;
|
| - Verifier::StartTracking(handle, this,
|
| + Verifier::StartTracking(handle, this, BASE_WIN_GET_CALLER,
|
| tracked_objects::GetProgramCounter());
|
| }
|
| }
|
| @@ -66,7 +78,7 @@
|
| DCHECK(!Traits::IsHandleValid(handle_)) << "Handle must be NULL";
|
|
|
| // We cannot track this case :(. Just tell the verifier about it.
|
| - Verifier::StartTracking(INVALID_HANDLE_VALUE, this,
|
| + Verifier::StartTracking(INVALID_HANDLE_VALUE, this, BASE_WIN_GET_CALLER,
|
| tracked_objects::GetProgramCounter());
|
| return &handle_;
|
| }
|
| @@ -75,15 +87,16 @@
|
| Handle Take() {
|
| Handle temp = handle_;
|
| handle_ = Traits::NullHandle();
|
| - Verifier::StopTracking(temp, this, tracked_objects::GetProgramCounter());
|
| + Verifier::StopTracking(temp, this, BASE_WIN_GET_CALLER,
|
| + tracked_objects::GetProgramCounter());
|
| return temp;
|
| }
|
|
|
| // Explicitly closes the owned handle.
|
| void Close() {
|
| if (Traits::IsHandleValid(handle_)) {
|
| - Verifier::StopTracking(handle_, this,
|
| - tracked_objects::GetProgramCounter());
|
| + Verifier::StopTracking(handle_, this, BASE_WIN_GET_CALLER,
|
| + tracked_objects::GetProgramCounter());
|
|
|
| if (!Traits::CloseHandle(handle_))
|
| CHECK(false);
|
| @@ -98,6 +111,8 @@
|
| DISALLOW_COPY_AND_ASSIGN(GenericScopedHandle);
|
| };
|
|
|
| +#undef BASE_WIN_GET_CALLER
|
| +
|
| // The traits class for Win32 handles that can be closed via CloseHandle() API.
|
| class HandleTraits {
|
| public:
|
| @@ -127,8 +142,10 @@
|
| public:
|
| typedef HANDLE Handle;
|
|
|
| - static void StartTracking(HANDLE handle, const void* owner, const void* pc) {}
|
| - static void StopTracking(HANDLE handle, const void* owner, const void* pc) {}
|
| + static void StartTracking(HANDLE handle, const void* owner,
|
| + const void* pc1, const void* pc2) {}
|
| + static void StopTracking(HANDLE handle, const void* owner,
|
| + const void* pc1, const void* pc2) {}
|
|
|
| private:
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(DummyVerifierTraits);
|
| @@ -139,8 +156,10 @@
|
| public:
|
| typedef HANDLE Handle;
|
|
|
| - static void StartTracking(HANDLE handle, const void* owner, const void* pc);
|
| - static void StopTracking(HANDLE handle, const void* owner, const void* pc);
|
| + static void StartTracking(HANDLE handle, const void* owner,
|
| + const void* pc1, const void* pc2);
|
| + static void StopTracking(HANDLE handle, const void* owner,
|
| + const void* pc1, const void* pc2);
|
|
|
| private:
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(VerifierTraits);
|
|
|