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 MemoryNotifierInterface, an API that is used by runtime
16 : // components to notify the runtime of memory that they have allocated for
17 : // internal use. This results in enhanced shadow redzone coverage.
18 :
19 : #ifndef SYZYGY_AGENT_ASAN_MEMORY_NOTIFIER_H_
20 : #define SYZYGY_AGENT_ASAN_MEMORY_NOTIFIER_H_
21 :
22 : #include <memory>
23 :
24 : namespace agent {
25 : namespace asan {
26 :
27 : // Declares a simple interface that is used by internal runtime components to
28 : // notify the runtime of their own memory use.
29 : class MemoryNotifierInterface {
30 : public:
31 : // Virtual destructor.
32 E : virtual ~MemoryNotifierInterface() { }
33 :
34 : // Reports the given range of memory for internal use by the runtime.
35 : // @param address The address of the memory range.
36 : // @param size The size of the memory range, in bytes.
37 : virtual void NotifyInternalUse(const void* address, size_t size) = 0;
38 :
39 : // Reports the given range of memory as reserved for future external use
40 : // by the runtime. That is, this is memory that is set aside for handing out
41 : // to the instrumented application via a heap allocation.
42 : // @param address The address of the memory range.
43 : // @param size The size of the memory range, in bytes.
44 : virtual void NotifyFutureHeapUse(const void* address, size_t size) = 0;
45 :
46 : // Reports that the given range of memory has been returned to the OS and is
47 : // no longer under the direct control of the runtime.
48 : // @param address The address of the memory range.
49 : // @param size The size of the memory range, in bytes.
50 : virtual void NotifyReturnedToOS(const void* address, size_t size) = 0;
51 : };
52 :
53 : } // namespace asan
54 : } // namespace agent
55 :
56 : #endif // SYZYGY_AGENT_ASAN_MEMORY_NOTIFIER_H_
|