| 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 const size_t kBlockHeaderChecksumBits = 13; |
| 116 | 116 |
| 117 // The state of an Asan block. These are in the order that reflects the typical | 117 // The state of an Asan block. These are in the order that reflects the typical |
| 118 // lifespan of an allocation. | 118 // lifespan of an allocation. |
| 119 enum BlockState { | 119 enum BlockState { |
| 120 // The block is allocated and valid for reading/writing. | 120 // The block is allocated and valid for reading/writing. |
| 121 ALLOCATED_BLOCK, | 121 ALLOCATED_BLOCK, |
| 122 // The block has been quarantined, and not valid for reading/writing. | 122 // 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 | 123 // While in the quarantine it is still allocated as far as the underlying |
| 124 // heap is concerned, and won't be reclaimed. | 124 // heap is concerned, and won't be reclaimed. |
| 125 QUARANTINED_BLOCK, | 125 QUARANTINED_BLOCK, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 150 unsigned state : 2; | 150 unsigned state : 2; |
| 151 // If this bit is positive then header padding is present. The size of the | 151 // If this bit is positive then header padding is present. The size of the |
| 152 // header padding is encoded in the padding itself. | 152 // header padding is encoded in the padding itself. |
| 153 unsigned has_header_padding : 1; | 153 unsigned has_header_padding : 1; |
| 154 // If this bit is positive then trailer padding in excess of | 154 // If this bit is positive then trailer padding in excess of |
| 155 // kShadowRatio/2 is present, and the size of the trailer padding itself | 155 // kShadowRatio/2 is present, and the size of the trailer padding itself |
| 156 // will be encoded in these bytes. Otherwise it is implicit as | 156 // will be encoded in these bytes. Otherwise it is implicit as |
| 157 // (kShadowRatio / 2) - (body_size % (kShadowRatio / 2)). | 157 // (kShadowRatio / 2) - (body_size % (kShadowRatio / 2)). |
| 158 unsigned has_excess_trailer_padding : 1; | 158 unsigned has_excess_trailer_padding : 1; |
| 159 // The size of the body of the allocation, in bytes. | 159 // The size of the body of the allocation, in bytes. |
| 160 unsigned body_size : 30; | 160 unsigned body_size : 31; |
| 161 }; | 161 }; |
| 162 // TODO(loskutov): replace pointers with something more compact. | 162 // TODO(loskutov): replace pointers with something more compact. |
| 163 // The allocation stack of this block. | 163 // The allocation stack of this block. |
| 164 const common::StackCapture* alloc_stack; | 164 const common::StackCapture* alloc_stack; |
| 165 // The free stack of this block (NULL if not yet quarantined/freed). | 165 // The free stack of this block (NULL if not yet quarantined/freed). |
| 166 const common::StackCapture* free_stack; | 166 const common::StackCapture* free_stack; |
| 167 }; | 167 }; |
| 168 #pragma pack(pop) | 168 #pragma pack(pop) |
| 169 static_assert((sizeof(BlockHeader) % kShadowRatio) == 0, | 169 static_assert((sizeof(BlockHeader) % kShadowRatio) == 0, |
| 170 "Invalid BlockHeader mod size."); | 170 "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; | 517 typedef base::Callback<void(EXCEPTION_POINTERS*)> OnExceptionCallback; |
| 518 void SetOnExceptionCallback(OnExceptionCallback callback); | 518 void SetOnExceptionCallback(OnExceptionCallback callback); |
| 519 void ClearOnExceptionCallback(); | 519 void ClearOnExceptionCallback(); |
| 520 | 520 |
| 521 } // namespace asan | 521 } // namespace asan |
| 522 } // namespace agent | 522 } // namespace agent |
| 523 | 523 |
| 524 #include "syzygy/agent/asan/block_impl.h" | 524 #include "syzygy/agent/asan/block_impl.h" |
| 525 | 525 |
| 526 #endif // SYZYGY_AGENT_ASAN_BLOCK_H_ | 526 #endif // SYZYGY_AGENT_ASAN_BLOCK_H_ |
| OLD | NEW |