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 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2605 | 2605 |
2606 uint64_t base_address = module->base_address(); | 2606 uint64_t base_address = module->base_address(); |
2607 uint64_t module_size = module->size(); | 2607 uint64_t module_size = module->size(); |
2608 if (base_address == static_cast<uint64_t>(-1)) { | 2608 if (base_address == static_cast<uint64_t>(-1)) { |
2609 BPLOG(ERROR) << "MinidumpModuleList found bad base address " | 2609 BPLOG(ERROR) << "MinidumpModuleList found bad base address " |
2610 "for module " << module_index << "/" << module_count << | 2610 "for module " << module_index << "/" << module_count << |
2611 ", " << module->code_file(); | 2611 ", " << module->code_file(); |
2612 return false; | 2612 return false; |
2613 } | 2613 } |
2614 | 2614 |
2615 if (!range_map_->StoreRange(base_address, module_size, module_index)) { | 2615 if (!range_map_->StoreRange(base_address, 0 /* delta */, module_size, |
| 2616 module_index)) { |
2616 // Android's shared memory implementation /dev/ashmem can contain | 2617 // Android's shared memory implementation /dev/ashmem can contain |
2617 // duplicate entries for JITted code, so ignore these. | 2618 // duplicate entries for JITted code, so ignore these. |
2618 // TODO(wfh): Remove this code when Android is fixed. | 2619 // TODO(wfh): Remove this code when Android is fixed. |
2619 // See https://crbug.com/439531 | 2620 // See https://crbug.com/439531 |
2620 const string kDevAshmem("/dev/ashmem/"); | 2621 const string kDevAshmem("/dev/ashmem/"); |
2621 if (module->code_file().compare( | 2622 if (module->code_file().compare( |
2622 0, kDevAshmem.length(), kDevAshmem) != 0) { | 2623 0, kDevAshmem.length(), kDevAshmem) != 0) { |
2623 if (base_address < last_end_address) { | 2624 if (base_address < last_end_address) { |
2624 // If failed due to apparent range overlap the cause may be | 2625 // If failed due to apparent range overlap the cause may be |
2625 // the client correction applied for Android packed relocations. | 2626 // the client correction applied for Android packed relocations. |
2626 // If this is the case, back out the client correction and retry. | 2627 // If this is the case, back out the client correction and retry. |
2627 module_size -= last_end_address - base_address; | 2628 module_size -= last_end_address - base_address; |
2628 base_address = last_end_address; | 2629 base_address = last_end_address; |
2629 if (!range_map_->StoreRange(base_address, | 2630 if (!range_map_->StoreRange(base_address, 0 /* delta */, |
2630 module_size, module_index)) { | 2631 module_size, module_index)) { |
2631 BPLOG(ERROR) << "MinidumpModuleList could not store module " << | 2632 BPLOG(ERROR) << "MinidumpModuleList could not store module " << |
2632 module_index << "/" << module_count << ", " << | 2633 module_index << "/" << module_count << ", " << |
2633 module->code_file() << ", " << | 2634 module->code_file() << ", " << |
2634 HexString(base_address) << "+" << | 2635 HexString(base_address) << "+" << |
2635 HexString(module_size) << ", after adjusting"; | 2636 HexString(module_size) << ", after adjusting"; |
2636 return false; | 2637 return false; |
2637 } | 2638 } |
2638 } else { | 2639 } else { |
2639 BPLOG(ERROR) << "MinidumpModuleList could not store module " << | 2640 BPLOG(ERROR) << "MinidumpModuleList could not store module " << |
(...skipping 25 matching lines...) Expand all Loading... |
2665 | 2666 |
2666 | 2667 |
2667 const MinidumpModule* MinidumpModuleList::GetModuleForAddress( | 2668 const MinidumpModule* MinidumpModuleList::GetModuleForAddress( |
2668 uint64_t address) const { | 2669 uint64_t address) const { |
2669 if (!valid_) { | 2670 if (!valid_) { |
2670 BPLOG(ERROR) << "Invalid MinidumpModuleList for GetModuleForAddress"; | 2671 BPLOG(ERROR) << "Invalid MinidumpModuleList for GetModuleForAddress"; |
2671 return NULL; | 2672 return NULL; |
2672 } | 2673 } |
2673 | 2674 |
2674 unsigned int module_index; | 2675 unsigned int module_index; |
2675 if (!range_map_->RetrieveRange(address, &module_index, NULL, NULL)) { | 2676 if (!range_map_->RetrieveRange(address, &module_index, NULL, NULL, NULL)) { |
2676 BPLOG(INFO) << "MinidumpModuleList has no module at " << | 2677 BPLOG(INFO) << "MinidumpModuleList has no module at " << |
2677 HexString(address); | 2678 HexString(address); |
2678 return NULL; | 2679 return NULL; |
2679 } | 2680 } |
2680 | 2681 |
2681 return GetModuleAtIndex(module_index); | 2682 return GetModuleAtIndex(module_index); |
2682 } | 2683 } |
2683 | 2684 |
2684 | 2685 |
2685 const MinidumpModule* MinidumpModuleList::GetMainModule() const { | 2686 const MinidumpModule* MinidumpModuleList::GetMainModule() const { |
(...skipping 15 matching lines...) Expand all Loading... |
2701 return NULL; | 2702 return NULL; |
2702 } | 2703 } |
2703 | 2704 |
2704 if (sequence >= module_count_) { | 2705 if (sequence >= module_count_) { |
2705 BPLOG(ERROR) << "MinidumpModuleList sequence out of range: " << | 2706 BPLOG(ERROR) << "MinidumpModuleList sequence out of range: " << |
2706 sequence << "/" << module_count_; | 2707 sequence << "/" << module_count_; |
2707 return NULL; | 2708 return NULL; |
2708 } | 2709 } |
2709 | 2710 |
2710 unsigned int module_index; | 2711 unsigned int module_index; |
2711 if (!range_map_->RetrieveRangeAtIndex(sequence, &module_index, NULL, NULL)) { | 2712 if (!range_map_->RetrieveRangeAtIndex(sequence, &module_index, NULL, NULL, |
| 2713 NULL)) { |
2712 BPLOG(ERROR) << "MinidumpModuleList has no module at sequence " << sequence; | 2714 BPLOG(ERROR) << "MinidumpModuleList has no module at sequence " << sequence; |
2713 return NULL; | 2715 return NULL; |
2714 } | 2716 } |
2715 | 2717 |
2716 return GetModuleAtIndex(module_index); | 2718 return GetModuleAtIndex(module_index); |
2717 } | 2719 } |
2718 | 2720 |
2719 | 2721 |
2720 const MinidumpModule* MinidumpModuleList::GetModuleAtIndex( | 2722 const MinidumpModule* MinidumpModuleList::GetModuleAtIndex( |
2721 unsigned int index) const { | 2723 unsigned int index) const { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2869 // Check for base + size overflow or undersize. | 2871 // Check for base + size overflow or undersize. |
2870 if (region_size == 0 || | 2872 if (region_size == 0 || |
2871 region_size > numeric_limits<uint64_t>::max() - base_address) { | 2873 region_size > numeric_limits<uint64_t>::max() - base_address) { |
2872 BPLOG(ERROR) << "MinidumpMemoryList has a memory region problem, " << | 2874 BPLOG(ERROR) << "MinidumpMemoryList has a memory region problem, " << |
2873 " region " << region_index << "/" << region_count << | 2875 " region " << region_index << "/" << region_count << |
2874 ", " << HexString(base_address) << "+" << | 2876 ", " << HexString(base_address) << "+" << |
2875 HexString(region_size); | 2877 HexString(region_size); |
2876 return false; | 2878 return false; |
2877 } | 2879 } |
2878 | 2880 |
2879 if (!range_map_->StoreRange(base_address, region_size, region_index)) { | 2881 if (!range_map_->StoreRange(base_address, 0 /* delta */, region_size, |
| 2882 region_index)) { |
2880 BPLOG(ERROR) << "MinidumpMemoryList could not store memory region " << | 2883 BPLOG(ERROR) << "MinidumpMemoryList could not store memory region " << |
2881 region_index << "/" << region_count << ", " << | 2884 region_index << "/" << region_count << ", " << |
2882 HexString(base_address) << "+" << | 2885 HexString(base_address) << "+" << |
2883 HexString(region_size); | 2886 HexString(region_size); |
2884 return false; | 2887 return false; |
2885 } | 2888 } |
2886 | 2889 |
2887 (*regions)[region_index].SetDescriptor(descriptor); | 2890 (*regions)[region_index].SetDescriptor(descriptor); |
2888 } | 2891 } |
2889 | 2892 |
(...skipping 26 matching lines...) Expand all Loading... |
2916 | 2919 |
2917 | 2920 |
2918 MinidumpMemoryRegion* MinidumpMemoryList::GetMemoryRegionForAddress( | 2921 MinidumpMemoryRegion* MinidumpMemoryList::GetMemoryRegionForAddress( |
2919 uint64_t address) { | 2922 uint64_t address) { |
2920 if (!valid_) { | 2923 if (!valid_) { |
2921 BPLOG(ERROR) << "Invalid MinidumpMemoryList for GetMemoryRegionForAddress"; | 2924 BPLOG(ERROR) << "Invalid MinidumpMemoryList for GetMemoryRegionForAddress"; |
2922 return NULL; | 2925 return NULL; |
2923 } | 2926 } |
2924 | 2927 |
2925 unsigned int region_index; | 2928 unsigned int region_index; |
2926 if (!range_map_->RetrieveRange(address, ®ion_index, NULL, NULL)) { | 2929 if (!range_map_->RetrieveRange(address, ®ion_index, NULL, NULL, NULL)) { |
2927 BPLOG(INFO) << "MinidumpMemoryList has no memory region at " << | 2930 BPLOG(INFO) << "MinidumpMemoryList has no memory region at " << |
2928 HexString(address); | 2931 HexString(address); |
2929 return NULL; | 2932 return NULL; |
2930 } | 2933 } |
2931 | 2934 |
2932 return GetMemoryRegionAtIndex(region_index); | 2935 return GetMemoryRegionAtIndex(region_index); |
2933 } | 2936 } |
2934 | 2937 |
2935 | 2938 |
2936 void MinidumpMemoryList::Print() { | 2939 void MinidumpMemoryList::Print() { |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3974 // Assume that the file offset is correct after the last read. | 3977 // Assume that the file offset is correct after the last read. |
3975 if (!info->Read()) { | 3978 if (!info->Read()) { |
3976 BPLOG(ERROR) << "MinidumpMemoryInfoList cannot read info " << | 3979 BPLOG(ERROR) << "MinidumpMemoryInfoList cannot read info " << |
3977 index << "/" << header.number_of_entries; | 3980 index << "/" << header.number_of_entries; |
3978 return false; | 3981 return false; |
3979 } | 3982 } |
3980 | 3983 |
3981 uint64_t base_address = info->GetBase(); | 3984 uint64_t base_address = info->GetBase(); |
3982 uint64_t region_size = info->GetSize(); | 3985 uint64_t region_size = info->GetSize(); |
3983 | 3986 |
3984 if (!range_map_->StoreRange(base_address, region_size, index)) { | 3987 if (!range_map_->StoreRange(base_address, 0 /* delta */, region_size, |
| 3988 index)) { |
3985 BPLOG(ERROR) << "MinidumpMemoryInfoList could not store" | 3989 BPLOG(ERROR) << "MinidumpMemoryInfoList could not store" |
3986 " memory region " << | 3990 " memory region " << |
3987 index << "/" << header.number_of_entries << ", " << | 3991 index << "/" << header.number_of_entries << ", " << |
3988 HexString(base_address) << "+" << | 3992 HexString(base_address) << "+" << |
3989 HexString(region_size); | 3993 HexString(region_size); |
3990 return false; | 3994 return false; |
3991 } | 3995 } |
3992 } | 3996 } |
3993 | 3997 |
3994 infos_ = infos.release(); | 3998 infos_ = infos.release(); |
(...skipping 25 matching lines...) Expand all Loading... |
4020 | 4024 |
4021 const MinidumpMemoryInfo* MinidumpMemoryInfoList::GetMemoryInfoForAddress( | 4025 const MinidumpMemoryInfo* MinidumpMemoryInfoList::GetMemoryInfoForAddress( |
4022 uint64_t address) const { | 4026 uint64_t address) const { |
4023 if (!valid_) { | 4027 if (!valid_) { |
4024 BPLOG(ERROR) << "Invalid MinidumpMemoryInfoList for" | 4028 BPLOG(ERROR) << "Invalid MinidumpMemoryInfoList for" |
4025 " GetMemoryInfoForAddress"; | 4029 " GetMemoryInfoForAddress"; |
4026 return NULL; | 4030 return NULL; |
4027 } | 4031 } |
4028 | 4032 |
4029 unsigned int info_index; | 4033 unsigned int info_index; |
4030 if (!range_map_->RetrieveRange(address, &info_index, NULL, NULL)) { | 4034 if (!range_map_->RetrieveRange(address, &info_index, NULL, NULL, NULL)) { |
4031 BPLOG(INFO) << "MinidumpMemoryInfoList has no memory info at " << | 4035 BPLOG(INFO) << "MinidumpMemoryInfoList has no memory info at " << |
4032 HexString(address); | 4036 HexString(address); |
4033 return NULL; | 4037 return NULL; |
4034 } | 4038 } |
4035 | 4039 |
4036 return GetMemoryInfoAtIndex(info_index); | 4040 return GetMemoryInfoAtIndex(info_index); |
4037 } | 4041 } |
4038 | 4042 |
4039 | 4043 |
4040 void MinidumpMemoryInfoList::Print() { | 4044 void MinidumpMemoryInfoList::Print() { |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4865 return NULL; | 4869 return NULL; |
4866 } | 4870 } |
4867 | 4871 |
4868 *stream = new_stream.release(); | 4872 *stream = new_stream.release(); |
4869 info->stream = *stream; | 4873 info->stream = *stream; |
4870 return *stream; | 4874 return *stream; |
4871 } | 4875 } |
4872 | 4876 |
4873 | 4877 |
4874 } // namespace google_breakpad | 4878 } // namespace google_breakpad |
OLD | NEW |