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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 /* (0x20) disabled. Thus any marker starting with 0xc0 is a historic */ \ | 71 /* (0x20) disabled. Thus any marker starting with 0xc0 is a historic */ \ |
72 /* block start marker. */ \ | 72 /* block start marker. */ \ |
73 F(kHeapHistoricBlockStartMarker0, 0xC0) \ | 73 F(kHeapHistoricBlockStartMarker0, 0xC0) \ |
74 F(kHeapHistoricBlockStartMarker1, 0xC1) \ | 74 F(kHeapHistoricBlockStartMarker1, 0xC1) \ |
75 F(kHeapHistoricBlockStartMarker2, 0xC2) \ | 75 F(kHeapHistoricBlockStartMarker2, 0xC2) \ |
76 F(kHeapHistoricBlockStartMarker3, 0xC3) \ | 76 F(kHeapHistoricBlockStartMarker3, 0xC3) \ |
77 F(kHeapHistoricBlockStartMarker4, 0xC4) \ | 77 F(kHeapHistoricBlockStartMarker4, 0xC4) \ |
78 F(kHeapHistoricBlockStartMarker5, 0xC5) \ | 78 F(kHeapHistoricBlockStartMarker5, 0xC5) \ |
79 F(kHeapHistoricBlockStartMarker6, 0xC6) \ | 79 F(kHeapHistoricBlockStartMarker6, 0xC6) \ |
80 F(kHeapHistoricBlockStartMarker7, 0xC7) \ | 80 F(kHeapHistoricBlockStartMarker7, 0xC7) \ |
81 /* Nested block start bytes have the bit 0x80 set. */ \ | |
82 F(kHeapHistoricNestedBlockStartMarker0, 0xC8) \ | |
83 F(kHeapHistoricNestedBlockStartMarker1, 0xC9) \ | |
84 F(kHeapHistoricNestedBlockStartMarker2, 0xCA) \ | |
85 F(kHeapHistoricNestedBlockStartMarker3, 0xCB) \ | |
86 F(kHeapHistoricNestedBlockStartMarker4, 0xCC) \ | |
87 F(kHeapHistoricNestedBlockStartMarker5, 0xCD) \ | |
88 F(kHeapHistoricNestedBlockStartMarker6, 0xCE) \ | |
89 F(kHeapHistoricNestedBlockStartMarker7, 0xCF) \ | |
90 /* These are 'historic' markers associated with block left/right */ \ | 81 /* These are 'historic' markers associated with block left/right */ \ |
91 /* redzones and freed data. They consist of the same values as the */ \ | 82 /* redzones and freed data. They consist of the same values as the */ \ |
92 /* active markers, minus the active block bit. */ \ | 83 /* active markers, minus the active block bit. */ \ |
93 F(kHeapHistoricBlockEndMarker, 0xD4) \ | 84 F(kHeapHistoricBlockEndMarker, 0xD4) \ |
94 F(kHeapHistoricNestedBlockEndMarker, 0xD5) \ | |
95 F(kHeapHistoricLeftPaddingMarker, 0xDA) \ | 85 F(kHeapHistoricLeftPaddingMarker, 0xDA) \ |
96 F(kHeapHistoricRightPaddingMarker, 0xDB) \ | 86 F(kHeapHistoricRightPaddingMarker, 0xDB) \ |
97 F(kHeapHistoricFreedMarker, 0xDD) \ | 87 F(kHeapHistoricFreedMarker, 0xDD) \ |
98 /* Any marker starting with 0xe0 marks the beginning of a block. The */ \ | 88 /* Any marker starting with 0xe0 marks the beginning of a block. The */ \ |
99 /* trailing 4 bits of the marker are used to encode additional */ \ | 89 /* trailing 4 bits of the marker are used to encode additional */ \ |
100 /* metadata about the block itself. This is necessary to allow */ \ | 90 /* metadata about the block itself. This is necessary to allow */ \ |
101 /* full introspection of blocks via the shadow. All 'active' block */ \ | 91 /* full introspection of blocks via the shadow. All 'active' block */ \ |
102 /* start bytes have the bit 0x20 set. */ \ | 92 /* start bytes have the bit 0x20 set. */ \ |
103 F(kHeapBlockStartMarker0, 0xE0) \ | 93 F(kHeapBlockStartMarker0, 0xE0) \ |
104 F(kHeapBlockStartMarker1, 0xE1) \ | 94 F(kHeapBlockStartMarker1, 0xE1) \ |
105 F(kHeapBlockStartMarker2, 0xE2) \ | 95 F(kHeapBlockStartMarker2, 0xE2) \ |
106 F(kHeapBlockStartMarker3, 0xE3) \ | 96 F(kHeapBlockStartMarker3, 0xE3) \ |
107 F(kHeapBlockStartMarker4, 0xE4) \ | 97 F(kHeapBlockStartMarker4, 0xE4) \ |
108 F(kHeapBlockStartMarker5, 0xE5) \ | 98 F(kHeapBlockStartMarker5, 0xE5) \ |
109 F(kHeapBlockStartMarker6, 0xE6) \ | 99 F(kHeapBlockStartMarker6, 0xE6) \ |
110 F(kHeapBlockStartMarker7, 0xE7) \ | 100 F(kHeapBlockStartMarker7, 0xE7) \ |
111 /* Nested block start bytes have the bit 0x80 set. */ \ | |
112 F(kHeapNestedBlockStartMarker0, 0xE8) \ | |
113 F(kHeapNestedBlockStartMarker1, 0xE9) \ | |
114 F(kHeapNestedBlockStartMarker2, 0xEA) \ | |
115 F(kHeapNestedBlockStartMarker3, 0xEB) \ | |
116 F(kHeapNestedBlockStartMarker4, 0xEC) \ | |
117 F(kHeapNestedBlockStartMarker5, 0xED) \ | |
118 F(kHeapNestedBlockStartMarker6, 0xEE) \ | |
119 F(kHeapNestedBlockStartMarker7, 0xEF) \ | |
120 /* The data in this block maps to internal memory structures. */ \ | 101 /* The data in this block maps to internal memory structures. */ \ |
121 F(kAsanMemoryMarker, 0xF1) \ | 102 F(kAsanMemoryMarker, 0xF1) \ |
122 /* The address covered by this byte are simply invalid and unable to */ \ | 103 /* The address covered by this byte are simply invalid and unable to */ \ |
123 /* be accessed by user code. */ \ | 104 /* be accessed by user code. */ \ |
124 F(kInvalidAddressMarker, 0xF2) \ | 105 F(kInvalidAddressMarker, 0xF2) \ |
125 /* The bytes are part of a block that has been allocated by the */ \ | 106 /* The bytes are part of a block that has been allocated by the */ \ |
126 /* instrumented code, but subsequently redzoned via the runtime API. */ \ | 107 /* instrumented code, but subsequently redzoned via the runtime API. */ \ |
127 F(kUserRedzoneMarker, 0xF3) \ | 108 F(kUserRedzoneMarker, 0xF3) \ |
128 /* This marker marks the end of a block in memory, and is part of a */ \ | 109 /* This marker marks the end of a block in memory, and is part of a */ \ |
129 /* right redzone. */ \ | 110 /* right redzone. */ \ |
130 F(kHeapBlockEndMarker, 0xF4) \ | 111 F(kHeapBlockEndMarker, 0xF4) \ |
131 F(kHeapNestedBlockEndMarker, 0xF5) \ | |
132 /* The bytes are part of a left redzone (block header padding). */ \ | 112 /* The bytes are part of a left redzone (block header padding). */ \ |
133 /* This is the same value as used by Asan itself. */ \ | 113 /* This is the same value as used by Asan itself. */ \ |
134 F(kHeapLeftPaddingMarker, 0xFA) \ | 114 F(kHeapLeftPaddingMarker, 0xFA) \ |
135 /* The bytes are part of a right redzone (block trailer and padding). */ \ | 115 /* The bytes are part of a right redzone (block trailer and padding). */ \ |
136 /* This is the same value as used by Asan itself. */ \ | 116 /* This is the same value as used by Asan itself. */ \ |
137 F(kHeapRightPaddingMarker, 0xFB) \ | 117 F(kHeapRightPaddingMarker, 0xFB) \ |
138 /* These bytes are part of memory that is destined to be used by the */ \ | 118 /* These bytes are part of memory that is destined to be used by the */ \ |
139 /* heap, has been reserved from the OS, but not yet handed out to */ \ | 119 /* heap, has been reserved from the OS, but not yet handed out to */ \ |
140 /* the code under test. */ \ | 120 /* the code under test. */ \ |
141 F(kAsanReservedMarker, 0xFC) \ | 121 F(kAsanReservedMarker, 0xFC) \ |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // @param marker The shadow marker to query. | 183 // @param marker The shadow marker to query. |
204 // @returns true if the marker describes a historic block start marker. | 184 // @returns true if the marker describes a historic block start marker. |
205 static bool IsHistoricBlockStart(ShadowMarkerValue marker); | 185 static bool IsHistoricBlockStart(ShadowMarkerValue marker); |
206 | 186 |
207 // @param marker The shadow marker to query. | 187 // @param marker The shadow marker to query. |
208 // @returns true if the marker describes a block header marker, historic or | 188 // @returns true if the marker describes a block header marker, historic or |
209 // active. | 189 // active. |
210 static bool IsBlockStart(ShadowMarkerValue marker); | 190 static bool IsBlockStart(ShadowMarkerValue marker); |
211 | 191 |
212 // @param marker The shadow marker to query. | 192 // @param marker The shadow marker to query. |
213 // @returns true if the markers describes a nested block start marker, | |
214 // historic or active. | |
215 static bool IsNestedBlockStart(ShadowMarkerValue marker); | |
216 | |
217 // @param marker The shadow marker to query. | |
218 // @returns the extra data encoded in a block start marker. | 193 // @returns the extra data encoded in a block start marker. |
219 // @note This should only be called for block start markers. | 194 // @note This should only be called for block start markers. |
220 static uint8_t GetBlockStartData(ShadowMarkerValue marker); | 195 static uint8_t GetBlockStartData(ShadowMarkerValue marker); |
221 | 196 |
222 // @param marker The shadow marker to query. | 197 // @param marker The shadow marker to query. |
223 // @returns true if the marker describes an active block start marker. | 198 // @returns true if the marker describes an active block start marker. |
224 static bool IsActiveBlockEnd(ShadowMarkerValue marker); | 199 static bool IsActiveBlockEnd(ShadowMarkerValue marker); |
225 | 200 |
226 // @param marker The shadow marker to query. | 201 // @param marker The shadow marker to query. |
227 // @returns true if the marker describes a historic block start marker. | 202 // @returns true if the marker describes a historic block start marker. |
228 static bool IsHistoricBlockEnd(ShadowMarkerValue marker); | 203 static bool IsHistoricBlockEnd(ShadowMarkerValue marker); |
229 | 204 |
230 // @param marker The shadow marker to query. | 205 // @param marker The shadow marker to query. |
231 // @returns true if the marker describes a block header marker, historic or | 206 // @returns true if the marker describes a block header marker, historic or |
232 // active. | 207 // active. |
233 static bool IsBlockEnd(ShadowMarkerValue marker); | 208 static bool IsBlockEnd(ShadowMarkerValue marker); |
234 | 209 |
235 // @param marker The shadow marker to query. | 210 // @param marker The shadow marker to query. |
236 // @returns true if the markers describes a nested block end marker, | |
237 // historic or active. | |
238 static bool IsNestedBlockEnd(ShadowMarkerValue marker); | |
239 | |
240 // @param marker The shadow marker to query. | |
241 // @returns true if the marker describes a historic left redzone. | 211 // @returns true if the marker describes a historic left redzone. |
242 // Note that block start markers are part of a left redzone. | 212 // Note that block start markers are part of a left redzone. |
243 static bool IsHistoricLeftRedzone(ShadowMarkerValue marker); | 213 static bool IsHistoricLeftRedzone(ShadowMarkerValue marker); |
244 | 214 |
245 // @param marker The shadow marker to query. | 215 // @param marker The shadow marker to query. |
246 // @returns true if the marker describes an active left redzone. | 216 // @returns true if the marker describes an active left redzone. |
247 // Note that block start markers are part of a left redzone. | 217 // Note that block start markers are part of a left redzone. |
248 static bool IsActiveLeftRedzone(ShadowMarkerValue marker); | 218 static bool IsActiveLeftRedzone(ShadowMarkerValue marker); |
249 | 219 |
250 // @param marker The shadow marker to query. | 220 // @param marker The shadow marker to query. |
(...skipping 27 matching lines...) Expand all Loading... |
278 // equivalent historic type. | 248 // equivalent historic type. |
279 static ShadowMarker ToHistoric(ShadowMarkerValue marker); | 249 static ShadowMarker ToHistoric(ShadowMarkerValue marker); |
280 | 250 |
281 // @} | 251 // @} |
282 | 252 |
283 // @name For building shadow markers. | 253 // @name For building shadow markers. |
284 // @{ | 254 // @{ |
285 | 255 |
286 // Builds a block start marker. | 256 // Builds a block start marker. |
287 // @param active True if the block is active, false if its historic. | 257 // @param active True if the block is active, false if its historic. |
288 // @param nested True if the block is nested, false otherwise. | |
289 // @param data The data to be appended to the marker. This can only consist | 258 // @param data The data to be appended to the marker. This can only consist |
290 // of 3 bits of data. | 259 // of 3 bits of data. |
291 // @returns the generated block start marker. | 260 // @returns the generated block start marker. |
292 static ShadowMarker BuildBlockStart(bool active, bool nested, uint8_t data); | 261 static ShadowMarker BuildBlockStart(bool active, uint8_t data); |
293 | 262 |
294 // Builds a block end marker. | 263 // Builds a block end marker. |
295 // @param active True if the block is active, false if its historic. | 264 // @param active True if the block is active, false if its historic. |
296 // @param nested True if the block is nested, false otherwise. | |
297 // @returns the generated block end marker. | 265 // @returns the generated block end marker. |
298 static ShadowMarker BuildBlockEnd(bool active, bool nested); | 266 static ShadowMarker BuildBlockEnd(bool active); |
299 | 267 |
300 // @} | 268 // @} |
301 }; | 269 }; |
302 | 270 |
303 } // namespace asan | 271 } // namespace asan |
304 } // namespace agent | 272 } // namespace agent |
305 | 273 |
306 #endif // SYZYGY_AGENT_ASAN_SHADOW_MARKER_H_ | 274 #endif // SYZYGY_AGENT_ASAN_SHADOW_MARKER_H_ |
OLD | NEW |