1 : // Copyright 2014 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Declares SimpleBlockHeap, which is a simple block-aware wrapper of an
16 : // instance of a HeapInterface. This is the primary type of block heap used
17 : // by the Asan instrumentation.
18 :
19 : #ifndef SYZYGY_AGENT_ASAN_HEAPS_SIMPLE_BLOCK_HEAP_H_
20 : #define SYZYGY_AGENT_ASAN_HEAPS_SIMPLE_BLOCK_HEAP_H_
21 :
22 : #include "syzygy/agent/asan/heap.h"
23 :
24 m : namespace agent {
25 m : namespace asan {
26 m : namespace heaps {
27 :
28 : // A block heap that wraps a raw heap.
29 m : class SimpleBlockHeap : public BlockHeapInterface {
30 m : public:
31 : // Constructor.
32 : // @param heap Is the underlying raw heap that will be used by this heap.
33 m : explicit SimpleBlockHeap(HeapInterface* heap);
34 :
35 : // Virtual destructor.
36 m : virtual ~SimpleBlockHeap();
37 :
38 : // @name HeapInterface implementation.
39 : // @{
40 m : virtual HeapType GetHeapType() const;
41 m : virtual uint32 GetHeapFeatures() const;
42 m : virtual void* Allocate(size_t bytes);
43 m : virtual bool Free(void* alloc);
44 m : virtual bool IsAllocated(const void* alloc);
45 m : virtual size_t GetAllocationSize(const void* alloc);
46 m : virtual void Lock();
47 m : virtual void Unlock();
48 m : virtual bool TryLock();
49 : // @}
50 :
51 : // @name BlockHeapInterface implementation.
52 : // @{
53 m : virtual void* AllocateBlock(size_t size,
54 m : size_t min_left_redzone_size,
55 m : size_t min_right_redzone_size,
56 m : BlockLayout* layout);
57 m : virtual bool FreeBlock(const BlockInfo& block_info);
58 : // @}
59 :
60 m : protected:
61 : // The underlying raw heap.
62 m : HeapInterface* heap_;
63 :
64 m : private:
65 m : DISALLOW_COPY_AND_ASSIGN(SimpleBlockHeap);
66 m : };
67 :
68 m : } // namespace heaps
69 m : } // namespace asan
70 m : } // namespace agent
71 :
72 : #endif // SYZYGY_AGENT_ASAN_HEAPS_SIMPLE_BLOCK_HEAP_H_
|