Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 32 // Implement the DwarfCUToModule class; see dwarf_cu_to_module.h. | 32 // Implement the DwarfCUToModule class; see dwarf_cu_to_module.h. |
| 33 | 33 |
| 34 // For <inttypes.h> PRI* macros, before anything else might #include it. | 34 // For <inttypes.h> PRI* macros, before anything else might #include it. |
| 35 #ifndef __STDC_FORMAT_MACROS | 35 #ifndef __STDC_FORMAT_MACROS |
| 36 #define __STDC_FORMAT_MACROS | 36 #define __STDC_FORMAT_MACROS |
| 37 #endif /* __STDC_FORMAT_MACROS */ | 37 #endif /* __STDC_FORMAT_MACROS */ |
| 38 | 38 |
| 39 #include "common/dwarf_cu_to_module.h" | 39 #include "common/dwarf_cu_to_module.h" |
| 40 | 40 |
| 41 #include <assert.h> | 41 #include <assert.h> |
| 42 #if !defined(__ANDROID__) | |
| 43 #include <cxxabi.h> | |
| 44 #endif | |
| 45 #include <inttypes.h> | 42 #include <inttypes.h> |
| 46 #include <stdint.h> | 43 #include <stdint.h> |
| 47 #include <stdio.h> | 44 #include <stdio.h> |
| 48 | 45 |
| 49 #include <algorithm> | 46 #include <algorithm> |
| 50 #include <utility> | 47 #include <utility> |
| 51 | 48 |
| 52 #include "common/dwarf_line_to_module.h" | 49 #include "common/dwarf_line_to_module.h" |
| 53 #include "common/unordered.h" | 50 #include "common/unordered.h" |
| 54 | 51 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 } | 340 } |
| 344 | 341 |
| 345 void DwarfCUToModule::GenericDIEHandler::ProcessAttributeString( | 342 void DwarfCUToModule::GenericDIEHandler::ProcessAttributeString( |
| 346 enum DwarfAttribute attr, | 343 enum DwarfAttribute attr, |
| 347 enum DwarfForm form, | 344 enum DwarfForm form, |
| 348 const string &data) { | 345 const string &data) { |
| 349 switch (attr) { | 346 switch (attr) { |
| 350 case dwarf2reader::DW_AT_name: | 347 case dwarf2reader::DW_AT_name: |
| 351 name_attribute_ = AddStringToPool(data); | 348 name_attribute_ = AddStringToPool(data); |
| 352 break; | 349 break; |
| 353 case dwarf2reader::DW_AT_MIPS_linkage_name: { | 350 case dwarf2reader::DW_AT_MIPS_linkage_name: |
| 354 char* demangled = NULL; | 351 case dwarf2reader::DW_AT_linkage_name: { |
| 355 int status = -1; | 352 string demangled; |
| 356 #if !defined(__ANDROID__) // Android NDK doesn't provide abi::__cxa_demangle. | 353 int status = cu_context_->language->DemangleName(data, |
| 357 demangled = abi::__cxa_demangle(data.c_str(), NULL, NULL, &status); | 354 &demangled); |
| 358 #endif | |
| 359 if (status != 0) { | 355 if (status != 0) { |
| 360 cu_context_->reporter->DemangleError(data, status); | 356 if (status != Language::kDontDemangle) { |
|
Ted Mielczarek
2016/09/14 10:20:10
It's unfortunate that we lose the language context
Mark Mentovai
2016/09/21 17:56:55
Ted Mielczarek wrote:
| |
| 361 demangled_name_ = ""; | 357 cu_context_->reporter->DemangleError(data, status); |
| 362 break; | 358 } |
| 363 } | 359 demangled_name_.clear(); |
| 364 if (demangled) { | 360 } else { |
| 365 demangled_name_ = AddStringToPool(demangled); | 361 demangled_name_ = AddStringToPool(demangled); |
| 366 free(reinterpret_cast<void*>(demangled)); | |
| 367 } | 362 } |
| 368 break; | 363 break; |
| 369 } | 364 } |
| 370 default: break; | 365 default: break; |
| 371 } | 366 } |
| 372 } | 367 } |
| 373 | 368 |
| 374 string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() { | 369 string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() { |
| 375 // Use the demangled name, if one is available. Demangled names are | 370 // Use the demangled name, if one is available. Demangled names are |
| 376 // preferable to those inferred from the DWARF structure because they | 371 // preferable to those inferred from the DWARF structure because they |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 dwarf2reader::DIEHandler *DwarfCUToModule::FindChildHandler( | 749 dwarf2reader::DIEHandler *DwarfCUToModule::FindChildHandler( |
| 755 uint64 offset, | 750 uint64 offset, |
| 756 enum DwarfTag tag) { | 751 enum DwarfTag tag) { |
| 757 switch (tag) { | 752 switch (tag) { |
| 758 case dwarf2reader::DW_TAG_subprogram: | 753 case dwarf2reader::DW_TAG_subprogram: |
| 759 return new FuncHandler(cu_context_.get(), child_context_.get(), offset); | 754 return new FuncHandler(cu_context_.get(), child_context_.get(), offset); |
| 760 case dwarf2reader::DW_TAG_namespace: | 755 case dwarf2reader::DW_TAG_namespace: |
| 761 case dwarf2reader::DW_TAG_class_type: | 756 case dwarf2reader::DW_TAG_class_type: |
| 762 case dwarf2reader::DW_TAG_structure_type: | 757 case dwarf2reader::DW_TAG_structure_type: |
| 763 case dwarf2reader::DW_TAG_union_type: | 758 case dwarf2reader::DW_TAG_union_type: |
| 759 case dwarf2reader::DW_TAG_module: | |
| 764 return new NamedScopeHandler(cu_context_.get(), child_context_.get(), | 760 return new NamedScopeHandler(cu_context_.get(), child_context_.get(), |
| 765 offset); | 761 offset); |
| 766 default: | 762 default: |
| 767 return NULL; | 763 return NULL; |
| 768 } | 764 } |
| 769 } | 765 } |
| 770 | 766 |
| 771 void DwarfCUToModule::SetLanguage(DwarfLanguage language) { | 767 void DwarfCUToModule::SetLanguage(DwarfLanguage language) { |
| 772 switch (language) { | 768 switch (language) { |
| 773 case dwarf2reader::DW_LANG_Java: | 769 case dwarf2reader::DW_LANG_Java: |
| 774 cu_context_->language = Language::Java; | 770 cu_context_->language = Language::Java; |
| 775 break; | 771 break; |
| 776 | 772 |
| 773 case dwarf2reader::DW_LANG_Swift: | |
| 774 cu_context_->language = Language::Swift; | |
| 775 break; | |
| 776 | |
| 777 // DWARF has no generic language code for assembly language; this is | 777 // DWARF has no generic language code for assembly language; this is |
| 778 // what the GNU toolchain uses. | 778 // what the GNU toolchain uses. |
| 779 case dwarf2reader::DW_LANG_Mips_Assembler: | 779 case dwarf2reader::DW_LANG_Mips_Assembler: |
| 780 cu_context_->language = Language::Assembler; | 780 cu_context_->language = Language::Assembler; |
| 781 break; | 781 break; |
| 782 | 782 |
| 783 // C++ covers so many cases that it probably has some way to cope | 783 // C++ covers so many cases that it probably has some way to cope |
| 784 // with whatever the other languages throw at us. So make it the | 784 // with whatever the other languages throw at us. So make it the |
| 785 // default. | 785 // default. |
| 786 // | 786 // |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1066 return dwarf_version >= 2; | 1066 return dwarf_version >= 2; |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 bool DwarfCUToModule::StartRootDIE(uint64 offset, enum DwarfTag tag) { | 1069 bool DwarfCUToModule::StartRootDIE(uint64 offset, enum DwarfTag tag) { |
| 1070 // We don't deal with partial compilation units (the only other tag | 1070 // We don't deal with partial compilation units (the only other tag |
| 1071 // likely to be used for root DIE). | 1071 // likely to be used for root DIE). |
| 1072 return tag == dwarf2reader::DW_TAG_compile_unit; | 1072 return tag == dwarf2reader::DW_TAG_compile_unit; |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 } // namespace google_breakpad | 1075 } // namespace google_breakpad |
| OLD | NEW |