OLD | NEW |
1 // Copyright (c) 2010 Google Inc. | 1 // Copyright (c) 2010 Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 Swap(&system_time->year); | 190 Swap(&system_time->year); |
191 Swap(&system_time->month); | 191 Swap(&system_time->month); |
192 Swap(&system_time->day_of_week); | 192 Swap(&system_time->day_of_week); |
193 Swap(&system_time->day); | 193 Swap(&system_time->day); |
194 Swap(&system_time->hour); | 194 Swap(&system_time->hour); |
195 Swap(&system_time->minute); | 195 Swap(&system_time->minute); |
196 Swap(&system_time->second); | 196 Swap(&system_time->second); |
197 Swap(&system_time->milliseconds); | 197 Swap(&system_time->milliseconds); |
198 } | 198 } |
199 | 199 |
| 200 static inline void Swap(MDXStateFeature* xstate_feature) { |
| 201 Swap(&xstate_feature->offset); |
| 202 Swap(&xstate_feature->size); |
| 203 } |
| 204 |
| 205 static inline void Swap(MDXStateConfigFeatureMscInfo* xstate_feature_info) { |
| 206 Swap(&xstate_feature_info->size_of_info); |
| 207 Swap(&xstate_feature_info->context_size); |
| 208 Swap(&xstate_feature_info->enabled_features); |
| 209 |
| 210 for (size_t i = 0; i < MD_MAXIMUM_XSTATE_FEATURES; i++) { |
| 211 Swap(&xstate_feature_info->features[i]); |
| 212 } |
| 213 } |
| 214 |
200 static inline void Swap(uint16_t* data, size_t size_in_bytes) { | 215 static inline void Swap(uint16_t* data, size_t size_in_bytes) { |
201 size_t data_length = size_in_bytes / sizeof(data[0]); | 216 size_t data_length = size_in_bytes / sizeof(data[0]); |
202 for (size_t i = 0; i < data_length; i++) { | 217 for (size_t i = 0; i < data_length; i++) { |
203 Swap(&data[i]); | 218 Swap(&data[i]); |
204 } | 219 } |
205 } | 220 } |
206 | 221 |
207 // | 222 // |
208 // Character conversion routines | 223 // Character conversion routines |
209 // | 224 // |
(...skipping 3291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3501 | 3516 |
3502 MinidumpMiscInfo::MinidumpMiscInfo(Minidump* minidump) | 3517 MinidumpMiscInfo::MinidumpMiscInfo(Minidump* minidump) |
3503 : MinidumpStream(minidump), | 3518 : MinidumpStream(minidump), |
3504 misc_info_() { | 3519 misc_info_() { |
3505 } | 3520 } |
3506 | 3521 |
3507 | 3522 |
3508 bool MinidumpMiscInfo::Read(uint32_t expected_size) { | 3523 bool MinidumpMiscInfo::Read(uint32_t expected_size) { |
3509 valid_ = false; | 3524 valid_ = false; |
3510 | 3525 |
| 3526 size_t padding = 0; |
3511 if (expected_size != MD_MISCINFO_SIZE && | 3527 if (expected_size != MD_MISCINFO_SIZE && |
3512 expected_size != MD_MISCINFO2_SIZE && | 3528 expected_size != MD_MISCINFO2_SIZE && |
3513 expected_size != MD_MISCINFO3_SIZE && | 3529 expected_size != MD_MISCINFO3_SIZE && |
3514 expected_size != MD_MISCINFO4_SIZE) { | 3530 expected_size != MD_MISCINFO4_SIZE && |
3515 BPLOG(ERROR) << "MinidumpMiscInfo size mismatch, " << expected_size | 3531 expected_size != MD_MISCINFO5_SIZE) { |
3516 << " != " << MD_MISCINFO_SIZE << ", " << MD_MISCINFO2_SIZE | 3532 if (expected_size > MD_MISCINFO5_SIZE) { |
3517 << ", " << MD_MISCINFO3_SIZE << ", " << MD_MISCINFO4_SIZE | 3533 // Only read the part of the misc info structure we know how to handle |
3518 << ")"; | 3534 BPLOG(INFO) << "MinidumpMiscInfo size larger than expected " |
3519 return false; | 3535 << expected_size << ", skipping over the unknown part"; |
| 3536 padding = expected_size - MD_MISCINFO5_SIZE; |
| 3537 expected_size = MD_MISCINFO5_SIZE; |
| 3538 } else { |
| 3539 BPLOG(ERROR) << "MinidumpMiscInfo size mismatch, " << expected_size |
| 3540 << " != " << MD_MISCINFO_SIZE << ", " << MD_MISCINFO2_SIZE |
| 3541 << ", " << MD_MISCINFO3_SIZE << ", " << MD_MISCINFO4_SIZE |
| 3542 << ", " << MD_MISCINFO5_SIZE << ")"; |
| 3543 return false; |
| 3544 } |
3520 } | 3545 } |
3521 | 3546 |
3522 if (!minidump_->ReadBytes(&misc_info_, expected_size)) { | 3547 if (!minidump_->ReadBytes(&misc_info_, expected_size)) { |
3523 BPLOG(ERROR) << "MinidumpMiscInfo cannot read miscellaneous info"; | 3548 BPLOG(ERROR) << "MinidumpMiscInfo cannot read miscellaneous info"; |
3524 return false; | 3549 return false; |
3525 } | 3550 } |
3526 | 3551 |
| 3552 if (padding != 0) { |
| 3553 off_t saved_position = minidump_->Tell(); |
| 3554 if (saved_position == -1) { |
| 3555 BPLOG(ERROR) << "MinidumpMiscInfo could not tell the current position"; |
| 3556 return false; |
| 3557 } |
| 3558 |
| 3559 if (!minidump_->SeekSet(saved_position + padding)) { |
| 3560 BPLOG(ERROR) << "MinidumpMiscInfo could not seek past the miscellaneous " |
| 3561 << "info structure"; |
| 3562 return false; |
| 3563 } |
| 3564 } |
| 3565 |
3527 if (minidump_->swap()) { | 3566 if (minidump_->swap()) { |
3528 // Swap version 1 fields | 3567 // Swap version 1 fields |
3529 Swap(&misc_info_.size_of_info); | 3568 Swap(&misc_info_.size_of_info); |
3530 Swap(&misc_info_.flags1); | 3569 Swap(&misc_info_.flags1); |
3531 Swap(&misc_info_.process_id); | 3570 Swap(&misc_info_.process_id); |
3532 Swap(&misc_info_.process_create_time); | 3571 Swap(&misc_info_.process_create_time); |
3533 Swap(&misc_info_.process_user_time); | 3572 Swap(&misc_info_.process_user_time); |
3534 Swap(&misc_info_.process_kernel_time); | 3573 Swap(&misc_info_.process_kernel_time); |
3535 if (misc_info_.size_of_info > MD_MISCINFO_SIZE) { | 3574 if (misc_info_.size_of_info > MD_MISCINFO_SIZE) { |
3536 // Swap version 2 fields | 3575 // Swap version 2 fields |
3537 Swap(&misc_info_.processor_max_mhz); | 3576 Swap(&misc_info_.processor_max_mhz); |
3538 Swap(&misc_info_.processor_current_mhz); | 3577 Swap(&misc_info_.processor_current_mhz); |
3539 Swap(&misc_info_.processor_mhz_limit); | 3578 Swap(&misc_info_.processor_mhz_limit); |
3540 Swap(&misc_info_.processor_max_idle_state); | 3579 Swap(&misc_info_.processor_max_idle_state); |
3541 Swap(&misc_info_.processor_current_idle_state); | 3580 Swap(&misc_info_.processor_current_idle_state); |
3542 } | 3581 } |
3543 if (misc_info_.size_of_info > MD_MISCINFO2_SIZE) { | 3582 if (misc_info_.size_of_info > MD_MISCINFO2_SIZE) { |
3544 // Swap version 3 fields | 3583 // Swap version 3 fields |
3545 Swap(&misc_info_.process_integrity_level); | 3584 Swap(&misc_info_.process_integrity_level); |
3546 Swap(&misc_info_.process_execute_flags); | 3585 Swap(&misc_info_.process_execute_flags); |
3547 Swap(&misc_info_.protected_process); | 3586 Swap(&misc_info_.protected_process); |
3548 Swap(&misc_info_.time_zone_id); | 3587 Swap(&misc_info_.time_zone_id); |
3549 Swap(&misc_info_.time_zone); | 3588 Swap(&misc_info_.time_zone); |
3550 } | 3589 } |
3551 if (misc_info_.size_of_info > MD_MISCINFO3_SIZE) { | 3590 if (misc_info_.size_of_info > MD_MISCINFO3_SIZE) { |
3552 // Swap version 4 fields. | 3591 // Swap version 4 fields. |
3553 // Do not swap UTF-16 strings. The swap is done as part of the | 3592 // Do not swap UTF-16 strings. The swap is done as part of the |
3554 // conversion to UTF-8 (code follows below). | 3593 // conversion to UTF-8 (code follows below). |
3555 } | 3594 } |
| 3595 if (misc_info_.size_of_info > MD_MISCINFO4_SIZE) { |
| 3596 // Swap version 5 fields |
| 3597 Swap(&misc_info_.xstate_data); |
| 3598 Swap(&misc_info_.process_cookie); |
| 3599 } |
3556 } | 3600 } |
3557 | 3601 |
3558 if (expected_size != misc_info_.size_of_info) { | 3602 if (expected_size + padding != misc_info_.size_of_info) { |
3559 BPLOG(ERROR) << "MinidumpMiscInfo size mismatch, " << | 3603 BPLOG(ERROR) << "MinidumpMiscInfo size mismatch, " << |
3560 expected_size << " != " << misc_info_.size_of_info; | 3604 expected_size << " != " << misc_info_.size_of_info; |
3561 return false; | 3605 return false; |
3562 } | 3606 } |
3563 | 3607 |
3564 // Convert UTF-16 strings | 3608 // Convert UTF-16 strings |
3565 if (misc_info_.size_of_info > MD_MISCINFO2_SIZE) { | 3609 if (misc_info_.size_of_info > MD_MISCINFO2_SIZE) { |
3566 // Convert UTF-16 strings in version 3 fields | 3610 // Convert UTF-16 strings in version 3 fields |
3567 ConvertUTF16BufferToUTF8String(misc_info_.time_zone.standard_name, | 3611 ConvertUTF16BufferToUTF8String(misc_info_.time_zone.standard_name, |
3568 sizeof(misc_info_.time_zone.standard_name), | 3612 sizeof(misc_info_.time_zone.standard_name), |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3698 if (misc_info_.size_of_info > MD_MISCINFO3_SIZE) { | 3742 if (misc_info_.size_of_info > MD_MISCINFO3_SIZE) { |
3699 // Print version 4 fields | 3743 // Print version 4 fields |
3700 if (misc_info_.flags1 & MD_MISCINFO_FLAGS1_BUILDSTRING) { | 3744 if (misc_info_.flags1 & MD_MISCINFO_FLAGS1_BUILDSTRING) { |
3701 printf(" build_string = %s\n", build_string_.c_str()); | 3745 printf(" build_string = %s\n", build_string_.c_str()); |
3702 printf(" dbg_bld_str = %s\n", dbg_bld_str_.c_str()); | 3746 printf(" dbg_bld_str = %s\n", dbg_bld_str_.c_str()); |
3703 } else { | 3747 } else { |
3704 printf(" build_string = (invalid)\n"); | 3748 printf(" build_string = (invalid)\n"); |
3705 printf(" dbg_bld_str = (invalid)\n"); | 3749 printf(" dbg_bld_str = (invalid)\n"); |
3706 } | 3750 } |
3707 } | 3751 } |
| 3752 if (misc_info_.size_of_info > MD_MISCINFO4_SIZE) { |
| 3753 // Print version 5 fields |
| 3754 if (misc_info_.flags1 & MD_MISCINFO_FLAGS1_PROCESS_COOKIE) { |
| 3755 printf(" xstate_data.size_of_info = %d\n", |
| 3756 misc_info_.xstate_data.size_of_info); |
| 3757 printf(" xstate_data.context_size = %d\n", |
| 3758 misc_info_.xstate_data.context_size); |
| 3759 printf(" xstate_data.enabled_features = 0x%" PRIx64 "\n", |
| 3760 misc_info_.xstate_data.enabled_features); |
| 3761 for (size_t i = 0; i < MD_MAXIMUM_XSTATE_FEATURES; i++) { |
| 3762 if (misc_info_.xstate_data.enabled_features & (1 << i)) { |
| 3763 printf(" xstate_data.features[%02zu] = { %d, %d }\n", i, |
| 3764 misc_info_.xstate_data.features[i].offset, |
| 3765 misc_info_.xstate_data.features[i].size); |
| 3766 } |
| 3767 } |
| 3768 if (misc_info_.xstate_data.enabled_features == 0) { |
| 3769 printf(" xstate_data.features[] = (empty)\n"); |
| 3770 } |
| 3771 printf(" process_cookie = %d\n", |
| 3772 misc_info_.process_cookie); |
| 3773 } else { |
| 3774 printf(" xstate_data.size_of_info = (invalid)\n"); |
| 3775 printf(" xstate_data.context_size = (invalid)\n"); |
| 3776 printf(" xstate_data.enabled_features = (invalid)\n"); |
| 3777 printf(" xstate_data.features[] = (invalid)\n"); |
| 3778 printf(" process_cookie = (invalid)\n"); |
| 3779 } |
| 3780 } |
3708 printf("\n"); | 3781 printf("\n"); |
3709 } | 3782 } |
3710 | 3783 |
3711 | 3784 |
3712 // | 3785 // |
3713 // MinidumpBreakpadInfo | 3786 // MinidumpBreakpadInfo |
3714 // | 3787 // |
3715 | 3788 |
3716 | 3789 |
3717 MinidumpBreakpadInfo::MinidumpBreakpadInfo(Minidump* minidump) | 3790 MinidumpBreakpadInfo::MinidumpBreakpadInfo(Minidump* minidump) |
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4907 return NULL; | 4980 return NULL; |
4908 } | 4981 } |
4909 | 4982 |
4910 *stream = new_stream.release(); | 4983 *stream = new_stream.release(); |
4911 info->stream = *stream; | 4984 info->stream = *stream; |
4912 return *stream; | 4985 return *stream; |
4913 } | 4986 } |
4914 | 4987 |
4915 | 4988 |
4916 } // namespace google_breakpad | 4989 } // namespace google_breakpad |
OLD | NEW |