OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // x86_THREAD_STATE32, x86_FLOAT_STATE32, and x86_DEBUG_STATE32 flavors. It also | 76 // x86_THREAD_STATE32, x86_FLOAT_STATE32, and x86_DEBUG_STATE32 flavors. It also |
77 // handles the universal x86_THREAD_STATE, x86_FLOAT_STATE, and x86_DEBUG_STATE | 77 // handles the universal x86_THREAD_STATE, x86_FLOAT_STATE, and x86_DEBUG_STATE |
78 // flavors provided that the associated structure carries 32-bit data of the | 78 // flavors provided that the associated structure carries 32-bit data of the |
79 // corresponding state type. |flavor| may be THREAD_STATE_NONE to avoid setting | 79 // corresponding state type. |flavor| may be THREAD_STATE_NONE to avoid setting |
80 // any thread state in |context|. This returns the architecture-specific flavor | 80 // any thread state in |context|. This returns the architecture-specific flavor |
81 // value for the thread state that was actually set, or THREAD_STATE_NONE if no | 81 // value for the thread state that was actually set, or THREAD_STATE_NONE if no |
82 // thread state was set. | 82 // thread state was set. |
83 thread_state_flavor_t InitializeCPUContextX86Flavor( | 83 thread_state_flavor_t InitializeCPUContextX86Flavor( |
84 CPUContextX86* context, | 84 CPUContextX86* context, |
85 thread_state_flavor_t flavor, | 85 thread_state_flavor_t flavor, |
86 const natural_t* state, | 86 ConstThreadState state, |
87 mach_msg_type_number_t state_count) { | 87 mach_msg_type_number_t state_count) { |
88 mach_msg_type_number_t expected_state_count; | 88 mach_msg_type_number_t expected_state_count; |
89 switch (flavor) { | 89 switch (flavor) { |
90 case x86_THREAD_STATE: | 90 case x86_THREAD_STATE: |
91 expected_state_count = x86_THREAD_STATE_COUNT; | 91 expected_state_count = x86_THREAD_STATE_COUNT; |
92 break; | 92 break; |
93 case x86_FLOAT_STATE: | 93 case x86_FLOAT_STATE: |
94 expected_state_count = x86_FLOAT_STATE_COUNT; | 94 expected_state_count = x86_FLOAT_STATE_COUNT; |
95 break; | 95 break; |
96 case x86_DEBUG_STATE: | 96 case x86_DEBUG_STATE: |
(...skipping 27 matching lines...) Expand all Loading... |
124 const x86_thread_state_t* x86_thread_state = | 124 const x86_thread_state_t* x86_thread_state = |
125 reinterpret_cast<const x86_thread_state_t*>(state); | 125 reinterpret_cast<const x86_thread_state_t*>(state); |
126 if (x86_thread_state->tsh.flavor != x86_THREAD_STATE32) { | 126 if (x86_thread_state->tsh.flavor != x86_THREAD_STATE32) { |
127 LOG(WARNING) << "expected flavor x86_THREAD_STATE32, observed " | 127 LOG(WARNING) << "expected flavor x86_THREAD_STATE32, observed " |
128 << x86_thread_state->tsh.flavor; | 128 << x86_thread_state->tsh.flavor; |
129 return THREAD_STATE_NONE; | 129 return THREAD_STATE_NONE; |
130 } | 130 } |
131 return InitializeCPUContextX86Flavor( | 131 return InitializeCPUContextX86Flavor( |
132 context, | 132 context, |
133 x86_thread_state->tsh.flavor, | 133 x86_thread_state->tsh.flavor, |
134 reinterpret_cast<const natural_t*>(&x86_thread_state->uts.ts32), | 134 reinterpret_cast<ConstThreadState>(&x86_thread_state->uts.ts32), |
135 x86_thread_state->tsh.count); | 135 x86_thread_state->tsh.count); |
136 } | 136 } |
137 | 137 |
138 case x86_FLOAT_STATE: { | 138 case x86_FLOAT_STATE: { |
139 const x86_float_state_t* x86_float_state = | 139 const x86_float_state_t* x86_float_state = |
140 reinterpret_cast<const x86_float_state_t*>(state); | 140 reinterpret_cast<const x86_float_state_t*>(state); |
141 if (x86_float_state->fsh.flavor != x86_FLOAT_STATE32) { | 141 if (x86_float_state->fsh.flavor != x86_FLOAT_STATE32) { |
142 LOG(WARNING) << "expected flavor x86_FLOAT_STATE32, observed " | 142 LOG(WARNING) << "expected flavor x86_FLOAT_STATE32, observed " |
143 << x86_float_state->fsh.flavor; | 143 << x86_float_state->fsh.flavor; |
144 return THREAD_STATE_NONE; | 144 return THREAD_STATE_NONE; |
145 } | 145 } |
146 return InitializeCPUContextX86Flavor( | 146 return InitializeCPUContextX86Flavor( |
147 context, | 147 context, |
148 x86_float_state->fsh.flavor, | 148 x86_float_state->fsh.flavor, |
149 reinterpret_cast<const natural_t*>(&x86_float_state->ufs.fs32), | 149 reinterpret_cast<ConstThreadState>(&x86_float_state->ufs.fs32), |
150 x86_float_state->fsh.count); | 150 x86_float_state->fsh.count); |
151 } | 151 } |
152 | 152 |
153 case x86_DEBUG_STATE: { | 153 case x86_DEBUG_STATE: { |
154 const x86_debug_state_t* x86_debug_state = | 154 const x86_debug_state_t* x86_debug_state = |
155 reinterpret_cast<const x86_debug_state_t*>(state); | 155 reinterpret_cast<const x86_debug_state_t*>(state); |
156 if (x86_debug_state->dsh.flavor != x86_DEBUG_STATE32) { | 156 if (x86_debug_state->dsh.flavor != x86_DEBUG_STATE32) { |
157 LOG(WARNING) << "expected flavor x86_DEBUG_STATE32, observed " | 157 LOG(WARNING) << "expected flavor x86_DEBUG_STATE32, observed " |
158 << x86_debug_state->dsh.flavor; | 158 << x86_debug_state->dsh.flavor; |
159 return THREAD_STATE_NONE; | 159 return THREAD_STATE_NONE; |
160 } | 160 } |
161 return InitializeCPUContextX86Flavor( | 161 return InitializeCPUContextX86Flavor( |
162 context, | 162 context, |
163 x86_debug_state->dsh.flavor, | 163 x86_debug_state->dsh.flavor, |
164 reinterpret_cast<const natural_t*>(&x86_debug_state->uds.ds32), | 164 reinterpret_cast<ConstThreadState>(&x86_debug_state->uds.ds32), |
165 x86_debug_state->dsh.count); | 165 x86_debug_state->dsh.count); |
166 } | 166 } |
167 | 167 |
168 case x86_THREAD_STATE32: { | 168 case x86_THREAD_STATE32: { |
169 const x86_thread_state32_t* x86_thread_state32 = | 169 const x86_thread_state32_t* x86_thread_state32 = |
170 reinterpret_cast<const x86_thread_state32_t*>(state); | 170 reinterpret_cast<const x86_thread_state32_t*>(state); |
171 InitializeCPUContextX86Thread(context, x86_thread_state32); | 171 InitializeCPUContextX86Thread(context, x86_thread_state32); |
172 return flavor; | 172 return flavor; |
173 } | 173 } |
174 | 174 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // x86_THREAD_STATE64, x86_FLOAT_STATE64, and x86_DEBUG_STATE64 flavors. It also | 257 // x86_THREAD_STATE64, x86_FLOAT_STATE64, and x86_DEBUG_STATE64 flavors. It also |
258 // handles the universal x86_THREAD_STATE, x86_FLOAT_STATE, and x86_DEBUG_STATE | 258 // handles the universal x86_THREAD_STATE, x86_FLOAT_STATE, and x86_DEBUG_STATE |
259 // flavors provided that the associated structure carries 64-bit data of the | 259 // flavors provided that the associated structure carries 64-bit data of the |
260 // corresponding state type. |flavor| may be THREAD_STATE_NONE to avoid setting | 260 // corresponding state type. |flavor| may be THREAD_STATE_NONE to avoid setting |
261 // any thread state in |context|. This returns the architecture-specific flavor | 261 // any thread state in |context|. This returns the architecture-specific flavor |
262 // value for the thread state that was actually set, or THREAD_STATE_NONE if no | 262 // value for the thread state that was actually set, or THREAD_STATE_NONE if no |
263 // thread state was set. | 263 // thread state was set. |
264 thread_state_flavor_t InitializeCPUContextX86_64Flavor( | 264 thread_state_flavor_t InitializeCPUContextX86_64Flavor( |
265 CPUContextX86_64* context, | 265 CPUContextX86_64* context, |
266 thread_state_flavor_t flavor, | 266 thread_state_flavor_t flavor, |
267 const natural_t* state, | 267 ConstThreadState state, |
268 mach_msg_type_number_t state_count) { | 268 mach_msg_type_number_t state_count) { |
269 mach_msg_type_number_t expected_state_count; | 269 mach_msg_type_number_t expected_state_count; |
270 switch (flavor) { | 270 switch (flavor) { |
271 case x86_THREAD_STATE: | 271 case x86_THREAD_STATE: |
272 expected_state_count = x86_THREAD_STATE_COUNT; | 272 expected_state_count = x86_THREAD_STATE_COUNT; |
273 break; | 273 break; |
274 case x86_FLOAT_STATE: | 274 case x86_FLOAT_STATE: |
275 expected_state_count = x86_FLOAT_STATE_COUNT; | 275 expected_state_count = x86_FLOAT_STATE_COUNT; |
276 break; | 276 break; |
277 case x86_DEBUG_STATE: | 277 case x86_DEBUG_STATE: |
(...skipping 27 matching lines...) Expand all Loading... |
305 const x86_thread_state_t* x86_thread_state = | 305 const x86_thread_state_t* x86_thread_state = |
306 reinterpret_cast<const x86_thread_state_t*>(state); | 306 reinterpret_cast<const x86_thread_state_t*>(state); |
307 if (x86_thread_state->tsh.flavor != x86_THREAD_STATE64) { | 307 if (x86_thread_state->tsh.flavor != x86_THREAD_STATE64) { |
308 LOG(WARNING) << "expected flavor x86_THREAD_STATE64, observed " | 308 LOG(WARNING) << "expected flavor x86_THREAD_STATE64, observed " |
309 << x86_thread_state->tsh.flavor; | 309 << x86_thread_state->tsh.flavor; |
310 return THREAD_STATE_NONE; | 310 return THREAD_STATE_NONE; |
311 } | 311 } |
312 return InitializeCPUContextX86_64Flavor( | 312 return InitializeCPUContextX86_64Flavor( |
313 context, | 313 context, |
314 x86_thread_state->tsh.flavor, | 314 x86_thread_state->tsh.flavor, |
315 reinterpret_cast<const natural_t*>(&x86_thread_state->uts.ts64), | 315 reinterpret_cast<ConstThreadState>(&x86_thread_state->uts.ts64), |
316 x86_thread_state->tsh.count); | 316 x86_thread_state->tsh.count); |
317 } | 317 } |
318 | 318 |
319 case x86_FLOAT_STATE: { | 319 case x86_FLOAT_STATE: { |
320 const x86_float_state_t* x86_float_state = | 320 const x86_float_state_t* x86_float_state = |
321 reinterpret_cast<const x86_float_state_t*>(state); | 321 reinterpret_cast<const x86_float_state_t*>(state); |
322 if (x86_float_state->fsh.flavor != x86_FLOAT_STATE64) { | 322 if (x86_float_state->fsh.flavor != x86_FLOAT_STATE64) { |
323 LOG(WARNING) << "expected flavor x86_FLOAT_STATE64, observed " | 323 LOG(WARNING) << "expected flavor x86_FLOAT_STATE64, observed " |
324 << x86_float_state->fsh.flavor; | 324 << x86_float_state->fsh.flavor; |
325 return THREAD_STATE_NONE; | 325 return THREAD_STATE_NONE; |
326 } | 326 } |
327 return InitializeCPUContextX86_64Flavor( | 327 return InitializeCPUContextX86_64Flavor( |
328 context, | 328 context, |
329 x86_float_state->fsh.flavor, | 329 x86_float_state->fsh.flavor, |
330 reinterpret_cast<const natural_t*>(&x86_float_state->ufs.fs64), | 330 reinterpret_cast<ConstThreadState>(&x86_float_state->ufs.fs64), |
331 x86_float_state->fsh.count); | 331 x86_float_state->fsh.count); |
332 } | 332 } |
333 | 333 |
334 case x86_DEBUG_STATE: { | 334 case x86_DEBUG_STATE: { |
335 const x86_debug_state_t* x86_debug_state = | 335 const x86_debug_state_t* x86_debug_state = |
336 reinterpret_cast<const x86_debug_state_t*>(state); | 336 reinterpret_cast<const x86_debug_state_t*>(state); |
337 if (x86_debug_state->dsh.flavor != x86_DEBUG_STATE64) { | 337 if (x86_debug_state->dsh.flavor != x86_DEBUG_STATE64) { |
338 LOG(WARNING) << "expected flavor x86_DEBUG_STATE64, observed " | 338 LOG(WARNING) << "expected flavor x86_DEBUG_STATE64, observed " |
339 << x86_debug_state->dsh.flavor; | 339 << x86_debug_state->dsh.flavor; |
340 return THREAD_STATE_NONE; | 340 return THREAD_STATE_NONE; |
341 } | 341 } |
342 return InitializeCPUContextX86_64Flavor( | 342 return InitializeCPUContextX86_64Flavor( |
343 context, | 343 context, |
344 x86_debug_state->dsh.flavor, | 344 x86_debug_state->dsh.flavor, |
345 reinterpret_cast<const natural_t*>(&x86_debug_state->uds.ds64), | 345 reinterpret_cast<ConstThreadState>(&x86_debug_state->uds.ds64), |
346 x86_debug_state->dsh.count); | 346 x86_debug_state->dsh.count); |
347 } | 347 } |
348 | 348 |
349 case x86_THREAD_STATE64: { | 349 case x86_THREAD_STATE64: { |
350 const x86_thread_state64_t* x86_thread_state64 = | 350 const x86_thread_state64_t* x86_thread_state64 = |
351 reinterpret_cast<const x86_thread_state64_t*>(state); | 351 reinterpret_cast<const x86_thread_state64_t*>(state); |
352 InitializeCPUContextX86_64Thread(context, x86_thread_state64); | 352 InitializeCPUContextX86_64Thread(context, x86_thread_state64); |
353 return flavor; | 353 return flavor; |
354 } | 354 } |
355 | 355 |
(...skipping 24 matching lines...) Expand all Loading... |
380 } | 380 } |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 } // namespace | 384 } // namespace |
385 | 385 |
386 namespace internal { | 386 namespace internal { |
387 | 387 |
388 void InitializeCPUContextX86(CPUContextX86* context, | 388 void InitializeCPUContextX86(CPUContextX86* context, |
389 thread_state_flavor_t flavor, | 389 thread_state_flavor_t flavor, |
390 const natural_t* state, | 390 ConstThreadState state, |
391 mach_msg_type_number_t state_count, | 391 mach_msg_type_number_t state_count, |
392 const x86_thread_state32_t* x86_thread_state32, | 392 const x86_thread_state32_t* x86_thread_state32, |
393 const x86_float_state32_t* x86_float_state32, | 393 const x86_float_state32_t* x86_float_state32, |
394 const x86_debug_state32_t* x86_debug_state32) { | 394 const x86_debug_state32_t* x86_debug_state32) { |
395 thread_state_flavor_t set_flavor = THREAD_STATE_NONE; | 395 thread_state_flavor_t set_flavor = THREAD_STATE_NONE; |
396 if (flavor != THREAD_STATE_NONE) { | 396 if (flavor != THREAD_STATE_NONE) { |
397 set_flavor = | 397 set_flavor = |
398 InitializeCPUContextX86Flavor(context, flavor, state, state_count); | 398 InitializeCPUContextX86Flavor(context, flavor, state, state_count); |
399 } | 399 } |
400 | 400 |
401 if (set_flavor != x86_THREAD_STATE32) { | 401 if (set_flavor != x86_THREAD_STATE32) { |
402 InitializeCPUContextX86Thread(context, x86_thread_state32); | 402 InitializeCPUContextX86Thread(context, x86_thread_state32); |
403 } | 403 } |
404 if (set_flavor != x86_FLOAT_STATE32) { | 404 if (set_flavor != x86_FLOAT_STATE32) { |
405 InitializeCPUContextX86Float(context, x86_float_state32); | 405 InitializeCPUContextX86Float(context, x86_float_state32); |
406 } | 406 } |
407 if (set_flavor != x86_DEBUG_STATE32) { | 407 if (set_flavor != x86_DEBUG_STATE32) { |
408 InitializeCPUContextX86Debug(context, x86_debug_state32); | 408 InitializeCPUContextX86Debug(context, x86_debug_state32); |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 void InitializeCPUContextX86_64(CPUContextX86_64* context, | 412 void InitializeCPUContextX86_64(CPUContextX86_64* context, |
413 thread_state_flavor_t flavor, | 413 thread_state_flavor_t flavor, |
414 const natural_t* state, | 414 ConstThreadState state, |
415 mach_msg_type_number_t state_count, | 415 mach_msg_type_number_t state_count, |
416 const x86_thread_state64_t* x86_thread_state64, | 416 const x86_thread_state64_t* x86_thread_state64, |
417 const x86_float_state64_t* x86_float_state64, | 417 const x86_float_state64_t* x86_float_state64, |
418 const x86_debug_state64_t* x86_debug_state64) { | 418 const x86_debug_state64_t* x86_debug_state64) { |
419 thread_state_flavor_t set_flavor = THREAD_STATE_NONE; | 419 thread_state_flavor_t set_flavor = THREAD_STATE_NONE; |
420 if (flavor != THREAD_STATE_NONE) { | 420 if (flavor != THREAD_STATE_NONE) { |
421 set_flavor = | 421 set_flavor = |
422 InitializeCPUContextX86_64Flavor(context, flavor, state, state_count); | 422 InitializeCPUContextX86_64Flavor(context, flavor, state, state_count); |
423 } | 423 } |
424 | 424 |
425 if (set_flavor != x86_THREAD_STATE64) { | 425 if (set_flavor != x86_THREAD_STATE64) { |
426 InitializeCPUContextX86_64Thread(context, x86_thread_state64); | 426 InitializeCPUContextX86_64Thread(context, x86_thread_state64); |
427 } | 427 } |
428 if (set_flavor != x86_FLOAT_STATE64) { | 428 if (set_flavor != x86_FLOAT_STATE64) { |
429 InitializeCPUContextX86_64Float(context, x86_float_state64); | 429 InitializeCPUContextX86_64Float(context, x86_float_state64); |
430 } | 430 } |
431 if (set_flavor != x86_DEBUG_STATE64) { | 431 if (set_flavor != x86_DEBUG_STATE64) { |
432 InitializeCPUContextX86_64Debug(context, x86_debug_state64); | 432 InitializeCPUContextX86_64Debug(context, x86_debug_state64); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 } // namespace internal | 436 } // namespace internal |
437 | 437 |
438 #endif | 438 #endif |
439 | 439 |
440 } // namespace crashpad | 440 } // namespace crashpad |
OLD | NEW |