OLD | NEW |
1 // Copyright 2014 Google Inc. All Rights Reserved. | 1 // Copyright 2014 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // Various constants for identifying the beginnings of regions of memory. | 105 // Various constants for identifying the beginnings of regions of memory. |
106 static const uint16_t kBlockHeaderMagic = 0xCA80; | 106 static const uint16_t kBlockHeaderMagic = 0xCA80; |
107 | 107 |
108 // Various constants used for filling regions of memory. | 108 // Various constants used for filling regions of memory. |
109 static const uint8_t kBlockHeaderPaddingByte = 0x1C; | 109 static const uint8_t kBlockHeaderPaddingByte = 0x1C; |
110 static const uint8_t kBlockTrailerPaddingByte = 0xC3; | 110 static const uint8_t kBlockTrailerPaddingByte = 0xC3; |
111 static const uint8_t kBlockFloodFillByte = 0xFD; | 111 static const uint8_t kBlockFloodFillByte = 0xFD; |
112 | 112 |
113 // The number of bits in the checksum field. This is parameterized so that | 113 // The number of bits in the checksum field. This is parameterized so that |
114 // it can be referred to by the checksumming code. | 114 // it can be referred to by the checksumming code. |
115 static const size_t kBlockHeaderChecksumBits = 14; | 115 static constexpr size_t kBlockHeaderChecksumBits = 13; |
| 116 |
| 117 // The number of bits used to store the size of an allocation. |
| 118 static constexpr size_t kBlockBodySizeBits = 31; |
116 | 119 |
117 // The state of an Asan block. These are in the order that reflects the typical | 120 // The state of an Asan block. These are in the order that reflects the typical |
118 // lifespan of an allocation. | 121 // lifespan of an allocation. |
119 enum BlockState { | 122 enum BlockState { |
120 // The block is allocated and valid for reading/writing. | 123 // The block is allocated and valid for reading/writing. |
121 ALLOCATED_BLOCK, | 124 ALLOCATED_BLOCK, |
122 // The block has been quarantined, and not valid for reading/writing. | 125 // The block has been quarantined, and not valid for reading/writing. |
123 // While in the quarantine it is still allocated as far as the underlying | 126 // While in the quarantine it is still allocated as far as the underlying |
124 // heap is concerned, and won't be reclaimed. | 127 // heap is concerned, and won't be reclaimed. |
125 QUARANTINED_BLOCK, | 128 QUARANTINED_BLOCK, |
(...skipping 24 matching lines...) Expand all Loading... |
150 unsigned state : 2; | 153 unsigned state : 2; |
151 // If this bit is positive then header padding is present. The size of the | 154 // If this bit is positive then header padding is present. The size of the |
152 // header padding is encoded in the padding itself. | 155 // header padding is encoded in the padding itself. |
153 unsigned has_header_padding : 1; | 156 unsigned has_header_padding : 1; |
154 // If this bit is positive then trailer padding in excess of | 157 // If this bit is positive then trailer padding in excess of |
155 // kShadowRatio/2 is present, and the size of the trailer padding itself | 158 // kShadowRatio/2 is present, and the size of the trailer padding itself |
156 // will be encoded in these bytes. Otherwise it is implicit as | 159 // will be encoded in these bytes. Otherwise it is implicit as |
157 // (kShadowRatio / 2) - (body_size % (kShadowRatio / 2)). | 160 // (kShadowRatio / 2) - (body_size % (kShadowRatio / 2)). |
158 unsigned has_excess_trailer_padding : 1; | 161 unsigned has_excess_trailer_padding : 1; |
159 // The size of the body of the allocation, in bytes. | 162 // The size of the body of the allocation, in bytes. |
160 unsigned body_size : 30; | 163 unsigned body_size : kBlockBodySizeBits; |
161 }; | 164 }; |
162 // TODO(loskutov): replace pointers with something more compact. | 165 // TODO(loskutov): replace pointers with something more compact. |
163 // The allocation stack of this block. | 166 // The allocation stack of this block. |
164 const common::StackCapture* alloc_stack; | 167 const common::StackCapture* alloc_stack; |
165 // The free stack of this block (NULL if not yet quarantined/freed). | 168 // The free stack of this block (NULL if not yet quarantined/freed). |
166 const common::StackCapture* free_stack; | 169 const common::StackCapture* free_stack; |
167 }; | 170 }; |
168 #pragma pack(pop) | 171 #pragma pack(pop) |
169 static_assert((sizeof(BlockHeader) % kShadowRatio) == 0, | 172 static_assert((sizeof(BlockHeader) % kShadowRatio) == 0, |
170 "Invalid BlockHeader mod size."); | 173 "Invalid BlockHeader mod size."); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 typedef base::Callback<void(EXCEPTION_POINTERS*)> OnExceptionCallback; | 520 typedef base::Callback<void(EXCEPTION_POINTERS*)> OnExceptionCallback; |
518 void SetOnExceptionCallback(OnExceptionCallback callback); | 521 void SetOnExceptionCallback(OnExceptionCallback callback); |
519 void ClearOnExceptionCallback(); | 522 void ClearOnExceptionCallback(); |
520 | 523 |
521 } // namespace asan | 524 } // namespace asan |
522 } // namespace agent | 525 } // namespace agent |
523 | 526 |
524 #include "syzygy/agent/asan/block_impl.h" | 527 #include "syzygy/agent/asan/block_impl.h" |
525 | 528 |
526 #endif // SYZYGY_AGENT_ASAN_BLOCK_H_ | 529 #endif // SYZYGY_AGENT_ASAN_BLOCK_H_ |
OLD | NEW |