| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SymbolFileDWARF.cpp ------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "SymbolFileDWARF.h" |
| 11 | |
| 12 | // Other libraries and framework includes |
| 13 | #include "clang/AST/ASTConsumer.h" |
| 14 | #include "clang/AST/ASTContext.h" |
| 15 | #include "clang/AST/Decl.h" |
| 16 | #include "clang/AST/DeclGroup.h" |
| 17 | #include "clang/Basic/Builtins.h" |
| 18 | #include "clang/Basic/IdentifierTable.h" |
| 19 | #include "clang/Basic/LangOptions.h" |
| 20 | #include "clang/Basic/SourceManager.h" |
| 21 | #include "clang/Basic/TargetInfo.h" |
| 22 | #include "clang/Basic/Specifiers.h" |
| 23 | |
| 24 | #include "lldb/Core/Module.h" |
| 25 | #include "lldb/Core/PluginManager.h" |
| 26 | #include "lldb/Core/RegularExpression.h" |
| 27 | #include "lldb/Core/Scalar.h" |
| 28 | #include "lldb/Core/Section.h" |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 29 | #include "lldb/Core/StreamFile.h" |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | #include "lldb/Core/Timer.h" |
| 31 | #include "lldb/Core/Value.h" |
| 32 | |
| 33 | #include "lldb/Symbol/Block.h" |
| 34 | #include "lldb/Symbol/CompileUnit.h" |
| 35 | #include "lldb/Symbol/LineTable.h" |
| 36 | #include "lldb/Symbol/ObjectFile.h" |
| 37 | #include "lldb/Symbol/SymbolVendor.h" |
| 38 | #include "lldb/Symbol/VariableList.h" |
| 39 | |
| 40 | #include "DWARFCompileUnit.h" |
| 41 | #include "DWARFDebugAbbrev.h" |
| 42 | #include "DWARFDebugAranges.h" |
| 43 | #include "DWARFDebugInfo.h" |
| 44 | #include "DWARFDebugInfoEntry.h" |
| 45 | #include "DWARFDebugLine.h" |
| 46 | #include "DWARFDebugPubnames.h" |
| 47 | #include "DWARFDebugRanges.h" |
| 48 | #include "DWARFDIECollection.h" |
| 49 | #include "DWARFFormValue.h" |
| 50 | #include "DWARFLocationList.h" |
| 51 | #include "LogChannelDWARF.h" |
| 52 | |
| 53 | #include <map> |
| 54 | |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 55 | #define DIE_IS_BEING_PARSED ((lldb_private::Type*)1) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | |
| 57 | using namespace lldb; |
| 58 | using namespace lldb_private; |
| 59 | |
| 60 | |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 61 | static AccessType |
| Greg Clayton | 8cf0593 | 2010-07-22 18:30:50 +0000 | [diff] [blame] | 62 | DW_ACCESS_to_AccessType (uint32_t dwarf_accessibility) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 63 | { |
| 64 | switch (dwarf_accessibility) |
| 65 | { |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 66 | case DW_ACCESS_public: return eAccessPublic; |
| 67 | case DW_ACCESS_private: return eAccessPrivate; |
| 68 | case DW_ACCESS_protected: return eAccessProtected; |
| Greg Clayton | 8cf0593 | 2010-07-22 18:30:50 +0000 | [diff] [blame] | 69 | default: break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 70 | } |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 71 | return eAccessNone; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | void |
| 75 | SymbolFileDWARF::Initialize() |
| 76 | { |
| 77 | LogChannelDWARF::Initialize(); |
| 78 | PluginManager::RegisterPlugin (GetPluginNameStatic(), |
| 79 | GetPluginDescriptionStatic(), |
| 80 | CreateInstance); |
| 81 | } |
| 82 | |
| 83 | void |
| 84 | SymbolFileDWARF::Terminate() |
| 85 | { |
| 86 | PluginManager::UnregisterPlugin (CreateInstance); |
| 87 | LogChannelDWARF::Initialize(); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | const char * |
| 92 | SymbolFileDWARF::GetPluginNameStatic() |
| 93 | { |
| 94 | return "symbol-file.dwarf2"; |
| 95 | } |
| 96 | |
| 97 | const char * |
| 98 | SymbolFileDWARF::GetPluginDescriptionStatic() |
| 99 | { |
| 100 | return "DWARF and DWARF3 debug symbol file reader."; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | SymbolFile* |
| 105 | SymbolFileDWARF::CreateInstance (ObjectFile* obj_file) |
| 106 | { |
| 107 | return new SymbolFileDWARF(obj_file); |
| 108 | } |
| 109 | |
| 110 | //---------------------------------------------------------------------- |
| 111 | // Gets the first parent that is a lexical block, function or inlined |
| 112 | // subroutine, or compile unit. |
| 113 | //---------------------------------------------------------------------- |
| 114 | static const DWARFDebugInfoEntry * |
| 115 | GetParentSymbolContextDIE(const DWARFDebugInfoEntry *child_die) |
| 116 | { |
| 117 | const DWARFDebugInfoEntry *die; |
| 118 | for (die = child_die->GetParent(); die != NULL; die = die->GetParent()) |
| 119 | { |
| 120 | dw_tag_t tag = die->Tag(); |
| 121 | |
| 122 | switch (tag) |
| 123 | { |
| 124 | case DW_TAG_compile_unit: |
| 125 | case DW_TAG_subprogram: |
| 126 | case DW_TAG_inlined_subroutine: |
| 127 | case DW_TAG_lexical_block: |
| 128 | return die; |
| 129 | } |
| 130 | } |
| 131 | return NULL; |
| 132 | } |
| 133 | |
| 134 | |
| 135 | SymbolFileDWARF::SymbolFileDWARF(ObjectFile* ofile) : |
| 136 | SymbolFile(ofile), |
| 137 | m_flags(), |
| 138 | m_data_debug_abbrev(), |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 139 | m_data_debug_frame(), |
| 140 | m_data_debug_info(), |
| 141 | m_data_debug_line(), |
| 142 | m_data_debug_loc(), |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 143 | m_data_debug_ranges(), |
| 144 | m_data_debug_str(), |
| 145 | m_abbr(), |
| 146 | m_aranges(), |
| 147 | m_info(), |
| 148 | m_line(), |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 149 | m_function_basename_index(), |
| 150 | m_function_fullname_index(), |
| 151 | m_function_method_index(), |
| 152 | m_function_selector_index(), |
| 153 | m_global_index(), |
| 154 | m_types_index(), |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 155 | m_indexed(false), |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 156 | m_ranges() |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 157 | { |
| 158 | } |
| 159 | |
| 160 | SymbolFileDWARF::~SymbolFileDWARF() |
| 161 | { |
| 162 | } |
| 163 | |
| 164 | bool |
| 165 | SymbolFileDWARF::SupportedVersion(uint16_t version) |
| 166 | { |
| 167 | return version == 2 || version == 3; |
| 168 | } |
| 169 | |
| 170 | uint32_t |
| 171 | SymbolFileDWARF::GetAbilities () |
| 172 | { |
| 173 | uint32_t abilities = 0; |
| 174 | if (m_obj_file != NULL) |
| 175 | { |
| 176 | const Section* section = NULL; |
| 177 | const SectionList *section_list = m_obj_file->GetSectionList(); |
| 178 | if (section_list == NULL) |
| 179 | return 0; |
| 180 | |
| 181 | uint64_t debug_abbrev_file_size = 0; |
| 182 | uint64_t debug_aranges_file_size = 0; |
| 183 | uint64_t debug_frame_file_size = 0; |
| 184 | uint64_t debug_info_file_size = 0; |
| 185 | uint64_t debug_line_file_size = 0; |
| 186 | uint64_t debug_loc_file_size = 0; |
| 187 | uint64_t debug_macinfo_file_size = 0; |
| 188 | uint64_t debug_pubnames_file_size = 0; |
| 189 | uint64_t debug_pubtypes_file_size = 0; |
| 190 | uint64_t debug_ranges_file_size = 0; |
| 191 | uint64_t debug_str_file_size = 0; |
| 192 | |
| 193 | static ConstString g_dwarf_section_name ("__DWARF"); |
| 194 | |
| 195 | section = section_list->FindSectionByName(g_dwarf_section_name).get(); |
| 196 | |
| 197 | if (section) |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 198 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 199 | section->MemoryMapSectionDataFromObjectFile(m_obj_file, m_dwarf_data); |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 200 | section_list = §ion->GetChildren (); |
| 201 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 202 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 203 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugInfo, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 204 | if (section != NULL) |
| 205 | { |
| 206 | debug_info_file_size = section->GetByteSize(); |
| 207 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 208 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugAbbrev, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 209 | if (section) |
| 210 | debug_abbrev_file_size = section->GetByteSize(); |
| 211 | else |
| 212 | m_flags.Set (flagsGotDebugAbbrevData); |
| 213 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 214 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugAranges, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 215 | if (section) |
| 216 | debug_aranges_file_size = section->GetByteSize(); |
| 217 | else |
| 218 | m_flags.Set (flagsGotDebugArangesData); |
| 219 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 220 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugFrame, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 221 | if (section) |
| 222 | debug_frame_file_size = section->GetByteSize(); |
| 223 | else |
| 224 | m_flags.Set (flagsGotDebugFrameData); |
| 225 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 226 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugLine, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 227 | if (section) |
| 228 | debug_line_file_size = section->GetByteSize(); |
| 229 | else |
| 230 | m_flags.Set (flagsGotDebugLineData); |
| 231 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 232 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugLoc, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 233 | if (section) |
| 234 | debug_loc_file_size = section->GetByteSize(); |
| 235 | else |
| 236 | m_flags.Set (flagsGotDebugLocData); |
| 237 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 238 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugMacInfo, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 239 | if (section) |
| 240 | debug_macinfo_file_size = section->GetByteSize(); |
| 241 | else |
| 242 | m_flags.Set (flagsGotDebugMacInfoData); |
| 243 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 244 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubNames, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 245 | if (section) |
| 246 | debug_pubnames_file_size = section->GetByteSize(); |
| 247 | else |
| 248 | m_flags.Set (flagsGotDebugPubNamesData); |
| 249 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 250 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubTypes, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 251 | if (section) |
| 252 | debug_pubtypes_file_size = section->GetByteSize(); |
| 253 | else |
| 254 | m_flags.Set (flagsGotDebugPubTypesData); |
| 255 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 256 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugRanges, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 257 | if (section) |
| 258 | debug_ranges_file_size = section->GetByteSize(); |
| 259 | else |
| 260 | m_flags.Set (flagsGotDebugRangesData); |
| 261 | |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 262 | section = section_list->FindSectionByType (eSectionTypeDWARFDebugStr, true).get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 263 | if (section) |
| 264 | debug_str_file_size = section->GetByteSize(); |
| 265 | else |
| 266 | m_flags.Set (flagsGotDebugStrData); |
| 267 | } |
| 268 | |
| 269 | if (debug_abbrev_file_size > 0 && debug_info_file_size > 0) |
| 270 | abilities |= CompileUnits | Functions | Blocks | GlobalVariables | LocalVariables | VariableTypes; |
| 271 | |
| 272 | if (debug_line_file_size > 0) |
| 273 | abilities |= LineTables; |
| 274 | |
| 275 | if (debug_aranges_file_size > 0) |
| 276 | abilities |= AddressAcceleratorTable; |
| 277 | |
| 278 | if (debug_pubnames_file_size > 0) |
| 279 | abilities |= FunctionAcceleratorTable; |
| 280 | |
| 281 | if (debug_pubtypes_file_size > 0) |
| 282 | abilities |= TypeAcceleratorTable; |
| 283 | |
| 284 | if (debug_macinfo_file_size > 0) |
| 285 | abilities |= MacroInformation; |
| 286 | |
| 287 | if (debug_frame_file_size > 0) |
| 288 | abilities |= CallFrameInformation; |
| 289 | } |
| 290 | return abilities; |
| 291 | } |
| 292 | |
| 293 | const DataExtractor& |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 294 | SymbolFileDWARF::GetCachedSectionData (uint32_t got_flag, SectionType sect_type, DataExtractor &data) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 295 | { |
| 296 | if (m_flags.IsClear (got_flag)) |
| 297 | { |
| 298 | m_flags.Set (got_flag); |
| 299 | const SectionList *section_list = m_obj_file->GetSectionList(); |
| 300 | if (section_list) |
| 301 | { |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 302 | Section *section = section_list->FindSectionByType(sect_type, true).get(); |
| 303 | if (section) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 304 | { |
| 305 | // See if we memory mapped the DWARF segment? |
| 306 | if (m_dwarf_data.GetByteSize()) |
| 307 | { |
| 308 | data.SetData(m_dwarf_data, section->GetOffset (), section->GetByteSize()); |
| 309 | } |
| 310 | else |
| 311 | { |
| 312 | if (section->ReadSectionDataFromObjectFile(m_obj_file, data) == 0) |
| 313 | data.Clear(); |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | return data; |
| 319 | } |
| 320 | |
| 321 | const DataExtractor& |
| 322 | SymbolFileDWARF::get_debug_abbrev_data() |
| 323 | { |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 324 | return GetCachedSectionData (flagsGotDebugAbbrevData, eSectionTypeDWARFDebugAbbrev, m_data_debug_abbrev); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | const DataExtractor& |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 328 | SymbolFileDWARF::get_debug_frame_data() |
| 329 | { |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 330 | return GetCachedSectionData (flagsGotDebugFrameData, eSectionTypeDWARFDebugFrame, m_data_debug_frame); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | const DataExtractor& |
| 334 | SymbolFileDWARF::get_debug_info_data() |
| 335 | { |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 336 | return GetCachedSectionData (flagsGotDebugInfoData, eSectionTypeDWARFDebugInfo, m_data_debug_info); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | const DataExtractor& |
| 340 | SymbolFileDWARF::get_debug_line_data() |
| 341 | { |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 342 | return GetCachedSectionData (flagsGotDebugLineData, eSectionTypeDWARFDebugLine, m_data_debug_line); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | const DataExtractor& |
| 346 | SymbolFileDWARF::get_debug_loc_data() |
| 347 | { |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 348 | return GetCachedSectionData (flagsGotDebugLocData, eSectionTypeDWARFDebugLoc, m_data_debug_loc); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | const DataExtractor& |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 352 | SymbolFileDWARF::get_debug_ranges_data() |
| 353 | { |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 354 | return GetCachedSectionData (flagsGotDebugRangesData, eSectionTypeDWARFDebugRanges, m_data_debug_ranges); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | const DataExtractor& |
| 358 | SymbolFileDWARF::get_debug_str_data() |
| 359 | { |
| Greg Clayton | 4ceb998 | 2010-07-21 22:54:26 +0000 | [diff] [blame] | 360 | return GetCachedSectionData (flagsGotDebugStrData, eSectionTypeDWARFDebugStr, m_data_debug_str); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | |
| 364 | DWARFDebugAbbrev* |
| 365 | SymbolFileDWARF::DebugAbbrev() |
| 366 | { |
| 367 | if (m_abbr.get() == NULL) |
| 368 | { |
| 369 | const DataExtractor &debug_abbrev_data = get_debug_abbrev_data(); |
| 370 | if (debug_abbrev_data.GetByteSize() > 0) |
| 371 | { |
| 372 | m_abbr.reset(new DWARFDebugAbbrev()); |
| 373 | if (m_abbr.get()) |
| 374 | m_abbr->Parse(debug_abbrev_data); |
| 375 | } |
| 376 | } |
| 377 | return m_abbr.get(); |
| 378 | } |
| 379 | |
| 380 | const DWARFDebugAbbrev* |
| 381 | SymbolFileDWARF::DebugAbbrev() const |
| 382 | { |
| 383 | return m_abbr.get(); |
| 384 | } |
| 385 | |
| 386 | DWARFDebugAranges* |
| 387 | SymbolFileDWARF::DebugAranges() |
| 388 | { |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 389 | // It turns out that llvm-gcc doesn't generate .debug_aranges in .o files |
| 390 | // and we are already parsing all of the DWARF because the .debug_pubnames |
| 391 | // is useless (it only mentions symbols that are externally visible), so |
| 392 | // don't use the .debug_aranges section, we should be using a debug aranges |
| 393 | // we got from SymbolFileDWARF::Index(). |
| 394 | |
| 395 | if (!m_indexed) |
| 396 | Index(); |
| 397 | |
| 398 | |
| 399 | // if (m_aranges.get() == NULL) |
| 400 | // { |
| 401 | // Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); |
| 402 | // m_aranges.reset(new DWARFDebugAranges()); |
| 403 | // if (m_aranges.get()) |
| 404 | // { |
| 405 | // const DataExtractor &debug_aranges_data = get_debug_aranges_data(); |
| 406 | // if (debug_aranges_data.GetByteSize() > 0) |
| 407 | // m_aranges->Extract(debug_aranges_data); |
| 408 | // else |
| 409 | // m_aranges->Generate(this); |
| 410 | // } |
| 411 | // } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 412 | return m_aranges.get(); |
| 413 | } |
| 414 | |
| 415 | const DWARFDebugAranges* |
| 416 | SymbolFileDWARF::DebugAranges() const |
| 417 | { |
| 418 | return m_aranges.get(); |
| 419 | } |
| 420 | |
| 421 | |
| 422 | DWARFDebugInfo* |
| 423 | SymbolFileDWARF::DebugInfo() |
| 424 | { |
| 425 | if (m_info.get() == NULL) |
| 426 | { |
| 427 | Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); |
| 428 | if (get_debug_info_data().GetByteSize() > 0) |
| 429 | { |
| 430 | m_info.reset(new DWARFDebugInfo()); |
| 431 | if (m_info.get()) |
| 432 | { |
| 433 | m_info->SetDwarfData(this); |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | return m_info.get(); |
| 438 | } |
| 439 | |
| 440 | const DWARFDebugInfo* |
| 441 | SymbolFileDWARF::DebugInfo() const |
| 442 | { |
| 443 | return m_info.get(); |
| 444 | } |
| 445 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 446 | DWARFCompileUnit* |
| 447 | SymbolFileDWARF::GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid) |
| 448 | { |
| 449 | DWARFDebugInfo* info = DebugInfo(); |
| 450 | if (info) |
| 451 | return info->GetCompileUnit(cu_uid).get(); |
| 452 | return NULL; |
| 453 | } |
| 454 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 455 | |
| 456 | DWARFDebugRanges* |
| 457 | SymbolFileDWARF::DebugRanges() |
| 458 | { |
| 459 | if (m_ranges.get() == NULL) |
| 460 | { |
| 461 | Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); |
| 462 | if (get_debug_ranges_data().GetByteSize() > 0) |
| 463 | { |
| 464 | m_ranges.reset(new DWARFDebugRanges()); |
| 465 | if (m_ranges.get()) |
| 466 | m_ranges->Extract(this); |
| 467 | } |
| 468 | } |
| 469 | return m_ranges.get(); |
| 470 | } |
| 471 | |
| 472 | const DWARFDebugRanges* |
| 473 | SymbolFileDWARF::DebugRanges() const |
| 474 | { |
| 475 | return m_ranges.get(); |
| 476 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 477 | |
| 478 | bool |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 479 | SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* cu, CompUnitSP& compile_unit_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 480 | { |
| 481 | if (cu != NULL) |
| 482 | { |
| 483 | const DWARFDebugInfoEntry * cu_die = cu->GetCompileUnitDIEOnly (); |
| 484 | if (cu_die) |
| 485 | { |
| 486 | const char * cu_die_name = cu_die->GetName(this, cu); |
| 487 | const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, cu, DW_AT_comp_dir, NULL); |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 488 | LanguageType class_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, cu, DW_AT_language, 0); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 489 | if (cu_die_name) |
| 490 | { |
| Jim Ingham | 0909e5f | 2010-09-16 00:57:33 +0000 | [diff] [blame] | 491 | FileSpec cu_file_spec; |
| 492 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 493 | if (cu_die_name[0] == '/' || cu_comp_dir == NULL && cu_comp_dir[0]) |
| 494 | { |
| Jim Ingham | 0909e5f | 2010-09-16 00:57:33 +0000 | [diff] [blame] | 495 | // If we have a full path to the compile unit, we don't need to resolve |
| 496 | // the file. This can be expensive e.g. when the source files are NFS mounted. |
| 497 | cu_file_spec.SetFile (cu_die_name, false); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 498 | } |
| 499 | else |
| 500 | { |
| 501 | std::string fullpath(cu_comp_dir); |
| 502 | if (*fullpath.rbegin() != '/') |
| 503 | fullpath += '/'; |
| 504 | fullpath += cu_die_name; |
| Jim Ingham | 0909e5f | 2010-09-16 00:57:33 +0000 | [diff] [blame] | 505 | cu_file_spec.SetFile (fullpath.c_str(), false); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 506 | } |
| 507 | |
| Jim Ingham | 0909e5f | 2010-09-16 00:57:33 +0000 | [diff] [blame] | 508 | compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, cu_file_spec, cu->GetOffset(), class_language)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 509 | if (compile_unit_sp.get()) |
| 510 | { |
| 511 | cu->SetUserData(compile_unit_sp.get()); |
| 512 | return true; |
| 513 | } |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | return false; |
| 518 | } |
| 519 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 520 | uint32_t |
| 521 | SymbolFileDWARF::GetNumCompileUnits() |
| 522 | { |
| 523 | DWARFDebugInfo* info = DebugInfo(); |
| 524 | if (info) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 525 | return info->GetNumCompileUnits(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 526 | return 0; |
| 527 | } |
| 528 | |
| 529 | CompUnitSP |
| 530 | SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) |
| 531 | { |
| 532 | CompUnitSP comp_unit; |
| 533 | DWARFDebugInfo* info = DebugInfo(); |
| 534 | if (info) |
| 535 | { |
| 536 | DWARFCompileUnit* cu = info->GetCompileUnitAtIndex(cu_idx); |
| 537 | if (cu != NULL) |
| 538 | { |
| 539 | // Our symbol vendor shouldn't be asking us to add a compile unit that |
| 540 | // has already been added to it, which this DWARF plug-in knows as it |
| 541 | // stores the lldb compile unit (CompileUnit) pointer in each |
| 542 | // DWARFCompileUnit object when it gets added. |
| 543 | assert(cu->GetUserData() == NULL); |
| 544 | ParseCompileUnit(cu, comp_unit); |
| 545 | } |
| 546 | } |
| 547 | return comp_unit; |
| 548 | } |
| 549 | |
| 550 | static void |
| 551 | AddRangesToBlock |
| 552 | ( |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 553 | Block& block, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 554 | DWARFDebugRanges::RangeList& ranges, |
| 555 | addr_t block_base_addr |
| 556 | ) |
| 557 | { |
| 558 | ranges.SubtractOffset (block_base_addr); |
| 559 | size_t range_idx = 0; |
| 560 | const DWARFDebugRanges::Range *debug_range; |
| 561 | for (range_idx = 0; (debug_range = ranges.RangeAtIndex(range_idx)) != NULL; range_idx++) |
| 562 | { |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 563 | block.AddRange(debug_range->begin_offset, debug_range->end_offset); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 564 | } |
| 565 | } |
| 566 | |
| 567 | |
| 568 | Function * |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 569 | SymbolFileDWARF::ParseCompileUnitFunction (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 570 | { |
| 571 | DWARFDebugRanges::RangeList func_ranges; |
| 572 | const char *name = NULL; |
| 573 | const char *mangled = NULL; |
| 574 | int decl_file = 0; |
| 575 | int decl_line = 0; |
| 576 | int decl_column = 0; |
| 577 | int call_file = 0; |
| 578 | int call_line = 0; |
| 579 | int call_column = 0; |
| 580 | DWARFExpression frame_base; |
| 581 | |
| 582 | // Parse the function prototype as a type that can then be added to concrete function instance |
| 583 | ParseTypes (sc, dwarf_cu, die, false, false); |
| 584 | //FixupTypes(); |
| 585 | |
| 586 | if (die->GetDIENamesAndRanges(this, dwarf_cu, name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column, &frame_base)) |
| 587 | { |
| 588 | // Union of all ranges in the function DIE (if the function is discontiguous) |
| 589 | AddressRange func_range; |
| 590 | lldb::addr_t lowest_func_addr = func_ranges.LowestAddress(0); |
| 591 | lldb::addr_t highest_func_addr = func_ranges.HighestAddress(0); |
| 592 | if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr) |
| 593 | { |
| 594 | func_range.GetBaseAddress().ResolveAddressUsingFileSections (lowest_func_addr, m_obj_file->GetSectionList()); |
| 595 | if (func_range.GetBaseAddress().IsValid()) |
| 596 | func_range.SetByteSize(highest_func_addr - lowest_func_addr); |
| 597 | } |
| 598 | |
| 599 | if (func_range.GetBaseAddress().IsValid()) |
| 600 | { |
| 601 | Mangled func_name; |
| 602 | if (mangled) |
| 603 | func_name.SetValue(mangled, true); |
| 604 | else if (name) |
| 605 | func_name.SetValue(name, false); |
| 606 | |
| 607 | FunctionSP func_sp; |
| 608 | std::auto_ptr<Declaration> decl_ap; |
| 609 | if (decl_file != 0 || decl_line != 0 || decl_column != 0) |
| 610 | decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column)); |
| 611 | |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 612 | Type *func_type = m_die_to_type.lookup (die); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 613 | |
| 614 | assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED); |
| 615 | |
| 616 | func_range.GetBaseAddress().ResolveLinkedAddress(); |
| 617 | |
| 618 | func_sp.reset(new Function (sc.comp_unit, |
| 619 | die->GetOffset(), // UserID is the DIE offset |
| 620 | die->GetOffset(), |
| 621 | func_name, |
| 622 | func_type, |
| 623 | func_range)); // first address range |
| 624 | |
| 625 | if (func_sp.get() != NULL) |
| 626 | { |
| 627 | func_sp->GetFrameBaseExpression() = frame_base; |
| 628 | sc.comp_unit->AddFunction(func_sp); |
| 629 | return func_sp.get(); |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | return NULL; |
| 634 | } |
| 635 | |
| 636 | size_t |
| 637 | SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) |
| 638 | { |
| 639 | assert (sc.comp_unit); |
| 640 | size_t functions_added = 0; |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 641 | DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 642 | if (dwarf_cu) |
| 643 | { |
| 644 | DWARFDIECollection function_dies; |
| 645 | const size_t num_funtions = dwarf_cu->AppendDIEsWithTag (DW_TAG_subprogram, function_dies); |
| 646 | size_t func_idx; |
| 647 | for (func_idx = 0; func_idx < num_funtions; ++func_idx) |
| 648 | { |
| 649 | const DWARFDebugInfoEntry *die = function_dies.GetDIEPtrAtIndex(func_idx); |
| 650 | if (sc.comp_unit->FindFunctionByUID (die->GetOffset()).get() == NULL) |
| 651 | { |
| 652 | if (ParseCompileUnitFunction(sc, dwarf_cu, die)) |
| 653 | ++functions_added; |
| 654 | } |
| 655 | } |
| 656 | //FixupTypes(); |
| 657 | } |
| 658 | return functions_added; |
| 659 | } |
| 660 | |
| 661 | bool |
| 662 | SymbolFileDWARF::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files) |
| 663 | { |
| 664 | assert (sc.comp_unit); |
| 665 | DWARFCompileUnit* cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); |
| 666 | assert (cu); |
| 667 | const DWARFDebugInfoEntry * cu_die = cu->GetCompileUnitDIEOnly(); |
| 668 | |
| 669 | if (cu_die) |
| 670 | { |
| 671 | const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, cu, DW_AT_comp_dir, NULL); |
| 672 | dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, cu, DW_AT_stmt_list, DW_INVALID_OFFSET); |
| 673 | |
| 674 | // All file indexes in DWARF are one based and a file of index zero is |
| 675 | // supposed to be the compile unit itself. |
| 676 | support_files.Append (*sc.comp_unit); |
| 677 | |
| 678 | return DWARFDebugLine::ParseSupportFiles(get_debug_line_data(), cu_comp_dir, stmt_list, support_files); |
| 679 | } |
| 680 | return false; |
| 681 | } |
| 682 | |
| 683 | struct ParseDWARFLineTableCallbackInfo |
| 684 | { |
| 685 | LineTable* line_table; |
| 686 | const SectionList *section_list; |
| 687 | lldb::addr_t prev_sect_file_base_addr; |
| 688 | lldb::addr_t curr_sect_file_base_addr; |
| 689 | bool is_oso_for_debug_map; |
| 690 | bool prev_in_final_executable; |
| 691 | DWARFDebugLine::Row prev_row; |
| 692 | SectionSP prev_section_sp; |
| 693 | SectionSP curr_section_sp; |
| 694 | }; |
| 695 | |
| 696 | //---------------------------------------------------------------------- |
| 697 | // ParseStatementTableCallback |
| 698 | //---------------------------------------------------------------------- |
| 699 | static void |
| 700 | ParseDWARFLineTableCallback(dw_offset_t offset, const DWARFDebugLine::State& state, void* userData) |
| 701 | { |
| 702 | LineTable* line_table = ((ParseDWARFLineTableCallbackInfo*)userData)->line_table; |
| 703 | if (state.row == DWARFDebugLine::State::StartParsingLineTable) |
| 704 | { |
| 705 | // Just started parsing the line table |
| 706 | } |
| 707 | else if (state.row == DWARFDebugLine::State::DoneParsingLineTable) |
| 708 | { |
| 709 | // Done parsing line table, nothing to do for the cleanup |
| 710 | } |
| 711 | else |
| 712 | { |
| 713 | ParseDWARFLineTableCallbackInfo* info = (ParseDWARFLineTableCallbackInfo*)userData; |
| 714 | // We have a new row, lets append it |
| 715 | |
| 716 | if (info->curr_section_sp.get() == NULL || info->curr_section_sp->ContainsFileAddress(state.address) == false) |
| 717 | { |
| 718 | info->prev_section_sp = info->curr_section_sp; |
| 719 | info->prev_sect_file_base_addr = info->curr_sect_file_base_addr; |
| 720 | // If this is an end sequence entry, then we subtract one from the |
| 721 | // address to make sure we get an address that is not the end of |
| 722 | // a section. |
| 723 | if (state.end_sequence && state.address != 0) |
| 724 | info->curr_section_sp = info->section_list->FindSectionContainingFileAddress (state.address - 1); |
| 725 | else |
| 726 | info->curr_section_sp = info->section_list->FindSectionContainingFileAddress (state.address); |
| 727 | |
| 728 | if (info->curr_section_sp.get()) |
| 729 | info->curr_sect_file_base_addr = info->curr_section_sp->GetFileAddress (); |
| 730 | else |
| 731 | info->curr_sect_file_base_addr = 0; |
| 732 | } |
| 733 | if (info->curr_section_sp.get()) |
| 734 | { |
| 735 | lldb::addr_t curr_line_section_offset = state.address - info->curr_sect_file_base_addr; |
| 736 | // Check for the fancy section magic to determine if we |
| 737 | |
| 738 | if (info->is_oso_for_debug_map) |
| 739 | { |
| 740 | // When this is a debug map object file that contains DWARF |
| 741 | // (referenced from an N_OSO debug map nlist entry) we will have |
| 742 | // a file address in the file range for our section from the |
| 743 | // original .o file, and a load address in the executable that |
| 744 | // contains the debug map. |
| 745 | // |
| 746 | // If the sections for the file range and load range are |
| 747 | // different, we have a remapped section for the function and |
| 748 | // this address is resolved. If they are the same, then the |
| 749 | // function for this address didn't make it into the final |
| 750 | // executable. |
| 751 | bool curr_in_final_executable = info->curr_section_sp->GetLinkedSection () != NULL; |
| 752 | |
| 753 | // If we are doing DWARF with debug map, then we need to carefully |
| 754 | // add each line table entry as there may be gaps as functions |
| 755 | // get moved around or removed. |
| 756 | if (!info->prev_row.end_sequence && info->prev_section_sp.get()) |
| 757 | { |
| 758 | if (info->prev_in_final_executable) |
| 759 | { |
| 760 | bool terminate_previous_entry = false; |
| 761 | if (!curr_in_final_executable) |
| 762 | { |
| 763 | // Check for the case where the previous line entry |
| 764 | // in a function made it into the final executable, |
| 765 | // yet the current line entry falls in a function |
| 766 | // that didn't. The line table used to be contiguous |
| 767 | // through this address range but now it isn't. We |
| 768 | // need to terminate the previous line entry so |
| 769 | // that we can reconstruct the line range correctly |
| 770 | // for it and to keep the line table correct. |
| 771 | terminate_previous_entry = true; |
| 772 | } |
| 773 | else if (info->curr_section_sp.get() != info->prev_section_sp.get()) |
| 774 | { |
| 775 | // Check for cases where the line entries used to be |
| 776 | // contiguous address ranges, but now they aren't. |
| 777 | // This can happen when order files specify the |
| 778 | // ordering of the functions. |
| 779 | lldb::addr_t prev_line_section_offset = info->prev_row.address - info->prev_sect_file_base_addr; |
| 780 | Section *curr_sect = info->curr_section_sp.get(); |
| 781 | Section *prev_sect = info->prev_section_sp.get(); |
| 782 | assert (curr_sect->GetLinkedSection()); |
| 783 | assert (prev_sect->GetLinkedSection()); |
| 784 | lldb::addr_t object_file_addr_delta = state.address - info->prev_row.address; |
| 785 | lldb::addr_t curr_linked_file_addr = curr_sect->GetLinkedFileAddress() + curr_line_section_offset; |
| 786 | lldb::addr_t prev_linked_file_addr = prev_sect->GetLinkedFileAddress() + prev_line_section_offset; |
| 787 | lldb::addr_t linked_file_addr_delta = curr_linked_file_addr - prev_linked_file_addr; |
| 788 | if (object_file_addr_delta != linked_file_addr_delta) |
| 789 | terminate_previous_entry = true; |
| 790 | } |
| 791 | |
| 792 | if (terminate_previous_entry) |
| 793 | { |
| 794 | line_table->InsertLineEntry (info->prev_section_sp, |
| 795 | state.address - info->prev_sect_file_base_addr, |
| 796 | info->prev_row.line, |
| 797 | info->prev_row.column, |
| 798 | info->prev_row.file, |
| 799 | false, // is_stmt |
| 800 | false, // basic_block |
| 801 | false, // state.prologue_end |
| 802 | false, // state.epilogue_begin |
| 803 | true); // end_sequence); |
| 804 | } |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | if (curr_in_final_executable) |
| 809 | { |
| 810 | line_table->InsertLineEntry (info->curr_section_sp, |
| 811 | curr_line_section_offset, |
| 812 | state.line, |
| 813 | state.column, |
| 814 | state.file, |
| 815 | state.is_stmt, |
| 816 | state.basic_block, |
| 817 | state.prologue_end, |
| 818 | state.epilogue_begin, |
| 819 | state.end_sequence); |
| 820 | info->prev_section_sp = info->curr_section_sp; |
| 821 | } |
| 822 | else |
| 823 | { |
| 824 | // If the current address didn't make it into the final |
| 825 | // executable, the current section will be the __text |
| 826 | // segment in the .o file, so we need to clear this so |
| 827 | // we can catch the next function that did make it into |
| 828 | // the final executable. |
| 829 | info->prev_section_sp.reset(); |
| 830 | info->curr_section_sp.reset(); |
| 831 | } |
| 832 | |
| 833 | info->prev_in_final_executable = curr_in_final_executable; |
| 834 | } |
| 835 | else |
| 836 | { |
| 837 | // We are not in an object file that contains DWARF for an |
| 838 | // N_OSO, this is just a normal DWARF file. The DWARF spec |
| 839 | // guarantees that the addresses will be in increasing order |
| 840 | // so, since we store line tables in file address order, we |
| 841 | // can always just append the line entry without needing to |
| 842 | // search for the correct insertion point (we don't need to |
| 843 | // use LineEntry::InsertLineEntry()). |
| 844 | line_table->AppendLineEntry (info->curr_section_sp, |
| 845 | curr_line_section_offset, |
| 846 | state.line, |
| 847 | state.column, |
| 848 | state.file, |
| 849 | state.is_stmt, |
| 850 | state.basic_block, |
| 851 | state.prologue_end, |
| 852 | state.epilogue_begin, |
| 853 | state.end_sequence); |
| 854 | } |
| 855 | } |
| 856 | |
| 857 | info->prev_row = state; |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | bool |
| 862 | SymbolFileDWARF::ParseCompileUnitLineTable (const SymbolContext &sc) |
| 863 | { |
| 864 | assert (sc.comp_unit); |
| 865 | if (sc.comp_unit->GetLineTable() != NULL) |
| 866 | return true; |
| 867 | |
| 868 | DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); |
| 869 | if (dwarf_cu) |
| 870 | { |
| 871 | const DWARFDebugInfoEntry *dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly(); |
| 872 | const dw_offset_t cu_line_offset = dwarf_cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET); |
| 873 | if (cu_line_offset != DW_INVALID_OFFSET) |
| 874 | { |
| 875 | std::auto_ptr<LineTable> line_table_ap(new LineTable(sc.comp_unit)); |
| 876 | if (line_table_ap.get()) |
| 877 | { |
| 878 | ParseDWARFLineTableCallbackInfo info = { line_table_ap.get(), m_obj_file->GetSectionList(), 0, 0, m_flags.IsSet (flagsDWARFIsOSOForDebugMap), false}; |
| 879 | uint32_t offset = cu_line_offset; |
| 880 | DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, ParseDWARFLineTableCallback, &info); |
| 881 | sc.comp_unit->SetLineTable(line_table_ap.release()); |
| 882 | return true; |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | return false; |
| 887 | } |
| 888 | |
| 889 | size_t |
| 890 | SymbolFileDWARF::ParseFunctionBlocks |
| 891 | ( |
| 892 | const SymbolContext& sc, |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 893 | Block *parent_block, |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 894 | DWARFCompileUnit* dwarf_cu, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 895 | const DWARFDebugInfoEntry *die, |
| 896 | addr_t subprogram_low_pc, |
| 897 | bool parse_siblings, |
| 898 | bool parse_children |
| 899 | ) |
| 900 | { |
| 901 | size_t blocks_added = 0; |
| 902 | while (die != NULL) |
| 903 | { |
| 904 | dw_tag_t tag = die->Tag(); |
| 905 | |
| 906 | switch (tag) |
| 907 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 908 | case DW_TAG_inlined_subroutine: |
| Jim Ingham | b0be442 | 2010-08-12 01:20:14 +0000 | [diff] [blame] | 909 | case DW_TAG_subprogram: |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 910 | case DW_TAG_lexical_block: |
| 911 | { |
| 912 | DWARFDebugRanges::RangeList ranges; |
| 913 | const char *name = NULL; |
| 914 | const char *mangled_name = NULL; |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 915 | Block *block = NULL; |
| 916 | if (tag != DW_TAG_subprogram) |
| 917 | { |
| 918 | BlockSP block_sp(new Block (die->GetOffset())); |
| 919 | parent_block->AddChild(block_sp); |
| 920 | block = block_sp.get(); |
| 921 | } |
| 922 | else |
| 923 | { |
| 924 | block = parent_block; |
| 925 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 926 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 927 | int decl_file = 0; |
| 928 | int decl_line = 0; |
| 929 | int decl_column = 0; |
| 930 | int call_file = 0; |
| 931 | int call_line = 0; |
| 932 | int call_column = 0; |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 933 | if (die->GetDIENamesAndRanges (this, |
| 934 | dwarf_cu, |
| 935 | name, |
| 936 | mangled_name, |
| 937 | ranges, |
| 938 | decl_file, decl_line, decl_column, |
| 939 | call_file, call_line, call_column)) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 940 | { |
| 941 | if (tag == DW_TAG_subprogram) |
| 942 | { |
| 943 | assert (subprogram_low_pc == LLDB_INVALID_ADDRESS); |
| 944 | subprogram_low_pc = ranges.LowestAddress(0); |
| 945 | } |
| Jim Ingham | b0be442 | 2010-08-12 01:20:14 +0000 | [diff] [blame] | 946 | else if (tag == DW_TAG_inlined_subroutine) |
| 947 | { |
| 948 | // We get called here for inlined subroutines in two ways. |
| 949 | // The first time is when we are making the Function object |
| 950 | // for this inlined concrete instance. Since we're creating a top level block at |
| 951 | // here, the subprogram_low_pc will be LLDB_INVALID_ADDRESS. So we need to |
| 952 | // adjust the containing address. |
| 953 | // The second time is when we are parsing the blocks inside the function that contains |
| 954 | // the inlined concrete instance. Since these will be blocks inside the containing "real" |
| 955 | // function the offset will be for that function. |
| 956 | if (subprogram_low_pc == LLDB_INVALID_ADDRESS) |
| 957 | { |
| 958 | subprogram_low_pc = ranges.LowestAddress(0); |
| 959 | } |
| 960 | } |
| 961 | |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 962 | AddRangesToBlock (*block, ranges, subprogram_low_pc); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 963 | |
| 964 | if (tag != DW_TAG_subprogram && (name != NULL || mangled_name != NULL)) |
| 965 | { |
| 966 | std::auto_ptr<Declaration> decl_ap; |
| 967 | if (decl_file != 0 || decl_line != 0 || decl_column != 0) |
| Jim Ingham | b0be442 | 2010-08-12 01:20:14 +0000 | [diff] [blame] | 968 | decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), |
| 969 | decl_line, decl_column)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 970 | |
| 971 | std::auto_ptr<Declaration> call_ap; |
| 972 | if (call_file != 0 || call_line != 0 || call_column != 0) |
| Jim Ingham | b0be442 | 2010-08-12 01:20:14 +0000 | [diff] [blame] | 973 | call_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(call_file), |
| 974 | call_line, call_column)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 975 | |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 976 | block->SetInlinedFunctionInfo (name, mangled_name, decl_ap.get(), call_ap.get()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | ++blocks_added; |
| 980 | |
| 981 | if (parse_children && die->HasChildren()) |
| 982 | { |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 983 | blocks_added += ParseFunctionBlocks (sc, |
| 984 | block, |
| 985 | dwarf_cu, |
| 986 | die->GetFirstChild(), |
| 987 | subprogram_low_pc, |
| 988 | true, |
| 989 | true); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 990 | } |
| 991 | } |
| 992 | } |
| 993 | break; |
| 994 | default: |
| 995 | break; |
| 996 | } |
| 997 | |
| 998 | if (parse_siblings) |
| 999 | die = die->GetSibling(); |
| 1000 | else |
| 1001 | die = NULL; |
| 1002 | } |
| 1003 | return blocks_added; |
| 1004 | } |
| 1005 | |
| 1006 | size_t |
| 1007 | SymbolFileDWARF::ParseChildMembers |
| 1008 | ( |
| 1009 | const SymbolContext& sc, |
| 1010 | TypeSP& type_sp, |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1011 | DWARFCompileUnit* dwarf_cu, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1012 | const DWARFDebugInfoEntry *parent_die, |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 1013 | void *class_clang_type, |
| 1014 | const LanguageType class_language, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1015 | std::vector<clang::CXXBaseSpecifier *>& base_classes, |
| 1016 | std::vector<int>& member_accessibilities, |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 1017 | AccessType& default_accessibility, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1018 | bool &is_a_class |
| 1019 | ) |
| 1020 | { |
| 1021 | if (parent_die == NULL) |
| 1022 | return 0; |
| 1023 | |
| 1024 | TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); |
| 1025 | |
| 1026 | size_t count = 0; |
| 1027 | const DWARFDebugInfoEntry *die; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 1028 | const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); |
| 1029 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1030 | for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) |
| 1031 | { |
| 1032 | dw_tag_t tag = die->Tag(); |
| 1033 | |
| 1034 | switch (tag) |
| 1035 | { |
| 1036 | case DW_TAG_member: |
| 1037 | { |
| 1038 | DWARFDebugInfoEntry::Attributes attributes; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 1039 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1040 | if (num_attributes > 0) |
| 1041 | { |
| 1042 | Declaration decl; |
| 1043 | DWARFExpression location; |
| 1044 | const char *name = NULL; |
| 1045 | lldb::user_id_t encoding_uid = LLDB_INVALID_UID; |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 1046 | AccessType accessibility = eAccessNone; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1047 | off_t member_offset = 0; |
| 1048 | size_t byte_size = 0; |
| 1049 | size_t bit_offset = 0; |
| 1050 | size_t bit_size = 0; |
| 1051 | uint32_t i; |
| 1052 | for (i=0; i<num_attributes; ++i) |
| 1053 | { |
| 1054 | const dw_attr_t attr = attributes.AttributeAtIndex(i); |
| 1055 | DWARFFormValue form_value; |
| 1056 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 1057 | { |
| 1058 | switch (attr) |
| 1059 | { |
| 1060 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 1061 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 1062 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 1063 | case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break; |
| 1064 | case DW_AT_type: encoding_uid = form_value.Reference(dwarf_cu); break; |
| 1065 | case DW_AT_bit_offset: bit_offset = form_value.Unsigned(); break; |
| 1066 | case DW_AT_bit_size: bit_size = form_value.Unsigned(); break; |
| 1067 | case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; |
| 1068 | case DW_AT_data_member_location: |
| 1069 | if (form_value.BlockData()) |
| 1070 | { |
| 1071 | Value initialValue(0); |
| 1072 | Value memberOffset(0); |
| 1073 | const DataExtractor& debug_info_data = get_debug_info_data(); |
| 1074 | uint32_t block_length = form_value.Unsigned(); |
| 1075 | uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); |
| 1076 | if (DWARFExpression::Evaluate(NULL, NULL, debug_info_data, NULL, NULL, block_offset, block_length, eRegisterKindDWARF, &initialValue, memberOffset, NULL)) |
| 1077 | { |
| 1078 | member_offset = memberOffset.ResolveValue(NULL, NULL).UInt(); |
| 1079 | } |
| 1080 | } |
| 1081 | break; |
| 1082 | |
| Greg Clayton | 8cf0593 | 2010-07-22 18:30:50 +0000 | [diff] [blame] | 1083 | case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType (form_value.Unsigned()); break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1084 | case DW_AT_declaration: |
| 1085 | case DW_AT_description: |
| 1086 | case DW_AT_mutable: |
| 1087 | case DW_AT_visibility: |
| 1088 | default: |
| 1089 | case DW_AT_sibling: |
| 1090 | break; |
| 1091 | } |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | Type *member_type = ResolveTypeUID(encoding_uid); |
| 1096 | assert(member_type); |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 1097 | if (accessibility == eAccessNone) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1098 | accessibility = default_accessibility; |
| 1099 | member_accessibilities.push_back(accessibility); |
| 1100 | |
| 1101 | type_list->GetClangASTContext().AddFieldToRecordType (type_sp->GetOpaqueClangQualType(), name, member_type->GetOpaqueClangQualType(), accessibility, bit_size); |
| 1102 | } |
| 1103 | } |
| 1104 | break; |
| 1105 | |
| 1106 | case DW_TAG_subprogram: |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1107 | // Let the type parsing code handle this one for us... |
| 1108 | ResolveType (dwarf_cu, die); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1109 | break; |
| 1110 | |
| 1111 | case DW_TAG_inheritance: |
| 1112 | { |
| 1113 | is_a_class = true; |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 1114 | if (default_accessibility == eAccessNone) |
| 1115 | default_accessibility = eAccessPrivate; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1116 | // TODO: implement DW_TAG_inheritance type parsing |
| 1117 | DWARFDebugInfoEntry::Attributes attributes; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 1118 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1119 | if (num_attributes > 0) |
| 1120 | { |
| 1121 | Declaration decl; |
| 1122 | DWARFExpression location; |
| 1123 | lldb::user_id_t encoding_uid = LLDB_INVALID_UID; |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 1124 | AccessType accessibility = default_accessibility; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1125 | bool is_virtual = false; |
| 1126 | bool is_base_of_class = true; |
| 1127 | off_t member_offset = 0; |
| 1128 | uint32_t i; |
| 1129 | for (i=0; i<num_attributes; ++i) |
| 1130 | { |
| 1131 | const dw_attr_t attr = attributes.AttributeAtIndex(i); |
| 1132 | DWARFFormValue form_value; |
| 1133 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 1134 | { |
| 1135 | switch (attr) |
| 1136 | { |
| 1137 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 1138 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 1139 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 1140 | case DW_AT_type: encoding_uid = form_value.Reference(dwarf_cu); break; |
| 1141 | case DW_AT_data_member_location: |
| 1142 | if (form_value.BlockData()) |
| 1143 | { |
| 1144 | Value initialValue(0); |
| 1145 | Value memberOffset(0); |
| 1146 | const DataExtractor& debug_info_data = get_debug_info_data(); |
| 1147 | uint32_t block_length = form_value.Unsigned(); |
| 1148 | uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); |
| 1149 | if (DWARFExpression::Evaluate(NULL, NULL, debug_info_data, NULL, NULL, block_offset, block_length, eRegisterKindDWARF, &initialValue, memberOffset, NULL)) |
| 1150 | { |
| 1151 | member_offset = memberOffset.ResolveValue(NULL, NULL).UInt(); |
| 1152 | } |
| 1153 | } |
| 1154 | break; |
| 1155 | |
| 1156 | case DW_AT_accessibility: |
| Greg Clayton | 8cf0593 | 2010-07-22 18:30:50 +0000 | [diff] [blame] | 1157 | accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1158 | break; |
| 1159 | |
| 1160 | case DW_AT_virtuality: is_virtual = form_value.Unsigned() != 0; break; |
| 1161 | default: |
| 1162 | case DW_AT_sibling: |
| 1163 | break; |
| 1164 | } |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | Type *base_class_dctype = ResolveTypeUID(encoding_uid); |
| 1169 | assert(base_class_dctype); |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 1170 | |
| 1171 | if (class_language == eLanguageTypeObjC) |
| 1172 | { |
| 1173 | type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetOpaqueClangQualType()); |
| 1174 | } |
| 1175 | else |
| 1176 | { |
| 1177 | base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetOpaqueClangQualType(), accessibility, is_virtual, is_base_of_class)); |
| 1178 | assert(base_classes.back()); |
| 1179 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1180 | } |
| 1181 | } |
| 1182 | break; |
| 1183 | |
| 1184 | default: |
| 1185 | break; |
| 1186 | } |
| 1187 | } |
| 1188 | return count; |
| 1189 | } |
| 1190 | |
| 1191 | |
| 1192 | clang::DeclContext* |
| 1193 | SymbolFileDWARF::GetClangDeclContextForTypeUID (lldb::user_id_t type_uid) |
| 1194 | { |
| 1195 | DWARFDebugInfo* debug_info = DebugInfo(); |
| 1196 | if (debug_info) |
| 1197 | { |
| 1198 | DWARFCompileUnitSP cu_sp; |
| 1199 | const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp); |
| 1200 | if (die) |
| 1201 | return GetClangDeclContextForDIE (cu_sp.get(), die); |
| 1202 | } |
| 1203 | return NULL; |
| 1204 | } |
| 1205 | |
| 1206 | Type* |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1207 | SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1208 | { |
| 1209 | DWARFDebugInfo* debug_info = DebugInfo(); |
| 1210 | if (debug_info) |
| 1211 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1212 | DWARFCompileUnitSP cu_sp; |
| 1213 | const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1214 | if (type_die != NULL) |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 1215 | return ResolveType (cu_sp.get(), type_die); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1216 | } |
| 1217 | return NULL; |
| 1218 | } |
| 1219 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1220 | Type* |
| 1221 | SymbolFileDWARF::ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die) |
| 1222 | { |
| 1223 | if (type_die != NULL) |
| 1224 | { |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 1225 | Type *type = m_die_to_type.lookup (type_die); |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1226 | if (type == NULL) |
| 1227 | { |
| 1228 | TypeSP owning_type_sp; |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 1229 | type = GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0).get(); |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1230 | } |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 1231 | assert (type != DIE_IS_BEING_PARSED); |
| 1232 | return type; |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1233 | } |
| 1234 | return NULL; |
| 1235 | } |
| 1236 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1237 | CompileUnit* |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1238 | SymbolFileDWARF::GetCompUnitForDWARFCompUnit (DWARFCompileUnit* cu, uint32_t cu_idx) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1239 | { |
| 1240 | // Check if the symbol vendor already knows about this compile unit? |
| 1241 | if (cu->GetUserData() == NULL) |
| 1242 | { |
| 1243 | // The symbol vendor doesn't know about this compile unit, we |
| 1244 | // need to parse and add it to the symbol vendor object. |
| 1245 | CompUnitSP dc_cu; |
| 1246 | ParseCompileUnit(cu, dc_cu); |
| 1247 | if (dc_cu.get()) |
| 1248 | { |
| 1249 | // Figure out the compile unit index if we weren't given one |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1250 | if (cu_idx == UINT32_MAX) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1251 | DebugInfo()->GetCompileUnit(cu->GetOffset(), &cu_idx); |
| 1252 | |
| 1253 | m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(dc_cu, cu_idx); |
| 1254 | } |
| 1255 | } |
| 1256 | return (CompileUnit*)cu->GetUserData(); |
| 1257 | } |
| 1258 | |
| 1259 | bool |
| 1260 | SymbolFileDWARF::GetFunction (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* func_die, SymbolContext& sc) |
| 1261 | { |
| 1262 | sc.Clear(); |
| 1263 | // Check if the symbol vendor already knows about this compile unit? |
| 1264 | sc.module_sp = m_obj_file->GetModule()->GetSP(); |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1265 | sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1266 | |
| 1267 | sc.function = sc.comp_unit->FindFunctionByUID (func_die->GetOffset()).get(); |
| 1268 | if (sc.function == NULL) |
| 1269 | sc.function = ParseCompileUnitFunction(sc, cu, func_die); |
| 1270 | |
| 1271 | return sc.function != NULL; |
| 1272 | } |
| 1273 | |
| 1274 | uint32_t |
| 1275 | SymbolFileDWARF::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) |
| 1276 | { |
| 1277 | Timer scoped_timer(__PRETTY_FUNCTION__, |
| 1278 | "SymbolFileDWARF::ResolveSymbolContext (so_addr = { section = %p, offset = 0x%llx }, resolve_scope = 0x%8.8x)", |
| 1279 | so_addr.GetSection(), |
| 1280 | so_addr.GetOffset(), |
| 1281 | resolve_scope); |
| 1282 | uint32_t resolved = 0; |
| 1283 | if (resolve_scope & ( eSymbolContextCompUnit | |
| 1284 | eSymbolContextFunction | |
| 1285 | eSymbolContextBlock | |
| 1286 | eSymbolContextLineEntry)) |
| 1287 | { |
| 1288 | lldb::addr_t file_vm_addr = so_addr.GetFileAddress(); |
| 1289 | |
| 1290 | DWARFDebugAranges* debug_aranges = DebugAranges(); |
| 1291 | DWARFDebugInfo* debug_info = DebugInfo(); |
| 1292 | if (debug_aranges) |
| 1293 | { |
| 1294 | dw_offset_t cu_offset = debug_aranges->FindAddress(file_vm_addr); |
| 1295 | if (cu_offset != DW_INVALID_OFFSET) |
| 1296 | { |
| 1297 | uint32_t cu_idx; |
| 1298 | DWARFCompileUnit* cu = debug_info->GetCompileUnit(cu_offset, &cu_idx).get(); |
| 1299 | if (cu) |
| 1300 | { |
| 1301 | sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, cu_idx); |
| 1302 | assert(sc.comp_unit != NULL); |
| 1303 | resolved |= eSymbolContextCompUnit; |
| 1304 | |
| 1305 | if (resolve_scope & eSymbolContextLineEntry) |
| 1306 | { |
| 1307 | LineTable *line_table = sc.comp_unit->GetLineTable(); |
| 1308 | if (line_table == NULL) |
| 1309 | { |
| 1310 | if (ParseCompileUnitLineTable(sc)) |
| 1311 | line_table = sc.comp_unit->GetLineTable(); |
| 1312 | } |
| 1313 | if (line_table != NULL) |
| 1314 | { |
| 1315 | if (so_addr.IsLinkedAddress()) |
| 1316 | { |
| 1317 | Address linked_addr (so_addr); |
| 1318 | linked_addr.ResolveLinkedAddress(); |
| 1319 | if (line_table->FindLineEntryByAddress (linked_addr, sc.line_entry)) |
| 1320 | { |
| 1321 | resolved |= eSymbolContextLineEntry; |
| 1322 | } |
| 1323 | } |
| 1324 | else if (line_table->FindLineEntryByAddress (so_addr, sc.line_entry)) |
| 1325 | { |
| 1326 | resolved |= eSymbolContextLineEntry; |
| 1327 | } |
| 1328 | } |
| 1329 | } |
| 1330 | |
| 1331 | if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock)) |
| 1332 | { |
| 1333 | DWARFDebugInfoEntry *function_die = NULL; |
| 1334 | DWARFDebugInfoEntry *block_die = NULL; |
| 1335 | if (resolve_scope & eSymbolContextBlock) |
| 1336 | { |
| 1337 | cu->LookupAddress(file_vm_addr, &function_die, &block_die); |
| 1338 | } |
| 1339 | else |
| 1340 | { |
| 1341 | cu->LookupAddress(file_vm_addr, &function_die, NULL); |
| 1342 | } |
| 1343 | |
| 1344 | if (function_die != NULL) |
| 1345 | { |
| 1346 | sc.function = sc.comp_unit->FindFunctionByUID (function_die->GetOffset()).get(); |
| 1347 | if (sc.function == NULL) |
| 1348 | sc.function = ParseCompileUnitFunction(sc, cu, function_die); |
| 1349 | } |
| 1350 | |
| 1351 | if (sc.function != NULL) |
| 1352 | { |
| 1353 | resolved |= eSymbolContextFunction; |
| 1354 | |
| 1355 | if (resolve_scope & eSymbolContextBlock) |
| 1356 | { |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 1357 | Block& block = sc.function->GetBlock (true); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1358 | |
| 1359 | if (block_die != NULL) |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 1360 | sc.block = block.FindBlockByID (block_die->GetOffset()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1361 | else |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 1362 | sc.block = block.FindBlockByID (function_die->GetOffset()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1363 | if (sc.block) |
| 1364 | resolved |= eSymbolContextBlock; |
| 1365 | } |
| 1366 | } |
| 1367 | } |
| 1368 | } |
| 1369 | } |
| 1370 | } |
| 1371 | } |
| 1372 | return resolved; |
| 1373 | } |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | uint32_t |
| 1378 | SymbolFileDWARF::ResolveSymbolContext(const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) |
| 1379 | { |
| 1380 | const uint32_t prev_size = sc_list.GetSize(); |
| 1381 | if (resolve_scope & eSymbolContextCompUnit) |
| 1382 | { |
| 1383 | DWARFDebugInfo* debug_info = DebugInfo(); |
| 1384 | if (debug_info) |
| 1385 | { |
| 1386 | uint32_t cu_idx; |
| 1387 | DWARFCompileUnit* cu = NULL; |
| 1388 | |
| 1389 | for (cu_idx = 0; (cu = debug_info->GetCompileUnitAtIndex(cu_idx)) != NULL; ++cu_idx) |
| 1390 | { |
| 1391 | CompileUnit *dc_cu = GetCompUnitForDWARFCompUnit(cu, cu_idx); |
| 1392 | bool file_spec_matches_cu_file_spec = dc_cu != NULL && FileSpec::Compare(file_spec, *dc_cu, false) == 0; |
| 1393 | if (check_inlines || file_spec_matches_cu_file_spec) |
| 1394 | { |
| 1395 | SymbolContext sc (m_obj_file->GetModule()); |
| 1396 | sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, cu_idx); |
| 1397 | assert(sc.comp_unit != NULL); |
| 1398 | |
| 1399 | uint32_t file_idx = UINT32_MAX; |
| 1400 | |
| 1401 | // If we are looking for inline functions only and we don't |
| 1402 | // find it in the support files, we are done. |
| 1403 | if (check_inlines) |
| 1404 | { |
| 1405 | file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex (1, file_spec); |
| 1406 | if (file_idx == UINT32_MAX) |
| 1407 | continue; |
| 1408 | } |
| 1409 | |
| 1410 | if (line != 0) |
| 1411 | { |
| 1412 | LineTable *line_table = sc.comp_unit->GetLineTable(); |
| 1413 | |
| 1414 | if (line_table != NULL && line != 0) |
| 1415 | { |
| 1416 | // We will have already looked up the file index if |
| 1417 | // we are searching for inline entries. |
| 1418 | if (!check_inlines) |
| 1419 | file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex (1, file_spec); |
| 1420 | |
| 1421 | if (file_idx != UINT32_MAX) |
| 1422 | { |
| 1423 | uint32_t found_line; |
| 1424 | uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_idx, line, false, &sc.line_entry); |
| 1425 | found_line = sc.line_entry.line; |
| 1426 | |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1427 | while (line_idx != UINT32_MAX) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1428 | { |
| 1429 | sc.function = NULL; |
| 1430 | sc.block = NULL; |
| 1431 | if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock)) |
| 1432 | { |
| 1433 | const lldb::addr_t file_vm_addr = sc.line_entry.range.GetBaseAddress().GetFileAddress(); |
| 1434 | if (file_vm_addr != LLDB_INVALID_ADDRESS) |
| 1435 | { |
| 1436 | DWARFDebugInfoEntry *function_die = NULL; |
| 1437 | DWARFDebugInfoEntry *block_die = NULL; |
| 1438 | cu->LookupAddress(file_vm_addr, &function_die, resolve_scope & eSymbolContextBlock ? &block_die : NULL); |
| 1439 | |
| 1440 | if (function_die != NULL) |
| 1441 | { |
| 1442 | sc.function = sc.comp_unit->FindFunctionByUID (function_die->GetOffset()).get(); |
| 1443 | if (sc.function == NULL) |
| 1444 | sc.function = ParseCompileUnitFunction(sc, cu, function_die); |
| 1445 | } |
| 1446 | |
| 1447 | if (sc.function != NULL) |
| 1448 | { |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 1449 | Block& block = sc.function->GetBlock (true); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1450 | |
| 1451 | if (block_die != NULL) |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 1452 | sc.block = block.FindBlockByID (block_die->GetOffset()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1453 | else |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 1454 | sc.block = block.FindBlockByID (function_die->GetOffset()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1455 | } |
| 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | sc_list.Append(sc); |
| 1460 | line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_idx, found_line, true, &sc.line_entry); |
| 1461 | } |
| 1462 | } |
| 1463 | } |
| 1464 | else if (file_spec_matches_cu_file_spec && !check_inlines) |
| 1465 | { |
| 1466 | // only append the context if we aren't looking for inline call sites |
| 1467 | // by file and line and if the file spec matches that of the compile unit |
| 1468 | sc_list.Append(sc); |
| 1469 | } |
| 1470 | } |
| 1471 | else if (file_spec_matches_cu_file_spec && !check_inlines) |
| 1472 | { |
| 1473 | // only append the context if we aren't looking for inline call sites |
| 1474 | // by file and line and if the file spec matches that of the compile unit |
| 1475 | sc_list.Append(sc); |
| 1476 | } |
| 1477 | |
| 1478 | if (!check_inlines) |
| 1479 | break; |
| 1480 | } |
| 1481 | } |
| 1482 | } |
| 1483 | } |
| 1484 | return sc_list.GetSize() - prev_size; |
| 1485 | } |
| 1486 | |
| 1487 | void |
| 1488 | SymbolFileDWARF::Index () |
| 1489 | { |
| 1490 | if (m_indexed) |
| 1491 | return; |
| 1492 | m_indexed = true; |
| 1493 | Timer scoped_timer (__PRETTY_FUNCTION__, |
| 1494 | "SymbolFileDWARF::Index (%s)", |
| 1495 | GetObjectFile()->GetFileSpec().GetFilename().AsCString()); |
| 1496 | |
| 1497 | DWARFDebugInfo* debug_info = DebugInfo(); |
| 1498 | if (debug_info) |
| 1499 | { |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1500 | m_aranges.reset(new DWARFDebugAranges()); |
| 1501 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1502 | uint32_t cu_idx = 0; |
| 1503 | const uint32_t num_compile_units = GetNumCompileUnits(); |
| 1504 | for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) |
| 1505 | { |
| 1506 | DWARFCompileUnit* cu = debug_info->GetCompileUnitAtIndex(cu_idx); |
| 1507 | |
| 1508 | bool clear_dies = cu->ExtractDIEsIfNeeded (false) > 1; |
| 1509 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1510 | cu->Index (cu_idx, |
| 1511 | m_function_basename_index, |
| 1512 | m_function_fullname_index, |
| 1513 | m_function_method_index, |
| 1514 | m_function_selector_index, |
| 1515 | m_global_index, |
| 1516 | m_types_index, |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1517 | DebugRanges(), |
| 1518 | m_aranges.get()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1519 | |
| 1520 | // Keep memory down by clearing DIEs if this generate function |
| 1521 | // caused them to be parsed |
| 1522 | if (clear_dies) |
| 1523 | cu->ClearDIEs (true); |
| 1524 | } |
| 1525 | |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1526 | m_aranges->Sort(); |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1527 | |
| 1528 | #if 0 |
| 1529 | StreamFile s(stdout); |
| 1530 | s.Printf("DWARF index for '%s':", GetObjectFile()->GetFileSpec().GetFilename().AsCString()); |
| 1531 | s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s); |
| 1532 | s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s); |
| 1533 | s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s); |
| 1534 | s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s); |
| 1535 | s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s); |
| 1536 | s.Printf("\nTypes:\n"); m_types_index.Dump (&s); |
| 1537 | #endif |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1538 | } |
| 1539 | } |
| 1540 | |
| 1541 | uint32_t |
| 1542 | SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variables) |
| 1543 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1544 | DWARFDebugInfo* info = DebugInfo(); |
| 1545 | if (info == NULL) |
| 1546 | return 0; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1547 | |
| 1548 | // If we aren't appending the results to this list, then clear the list |
| 1549 | if (!append) |
| 1550 | variables.Clear(); |
| 1551 | |
| 1552 | // Remember how many variables are in the list before we search in case |
| 1553 | // we are appending the results to a variable list. |
| 1554 | const uint32_t original_size = variables.GetSize(); |
| 1555 | |
| 1556 | // Index the DWARF if we haven't already |
| 1557 | if (!m_indexed) |
| 1558 | Index (); |
| 1559 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1560 | SymbolContext sc; |
| 1561 | sc.module_sp = m_obj_file->GetModule()->GetSP(); |
| 1562 | assert (sc.module_sp); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1563 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1564 | DWARFCompileUnit* cu = NULL; |
| 1565 | DWARFCompileUnit* prev_cu = NULL; |
| 1566 | const DWARFDebugInfoEntry* die = NULL; |
| 1567 | std::vector<NameToDIE::Info> die_info_array; |
| 1568 | const size_t num_matches = m_global_index.Find(name, die_info_array); |
| 1569 | for (size_t i=0; i<num_matches; ++i, prev_cu = cu) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1570 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1571 | cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); |
| 1572 | |
| 1573 | if (cu != prev_cu) |
| 1574 | cu->ExtractDIEsIfNeeded (false); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1575 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1576 | die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1577 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1578 | sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); |
| 1579 | assert(sc.comp_unit != NULL); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1580 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1581 | ParseVariables(sc, cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); |
| 1582 | |
| 1583 | if (variables.GetSize() - original_size >= max_matches) |
| 1584 | break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | // Return the number of variable that were appended to the list |
| 1588 | return variables.GetSize() - original_size; |
| 1589 | } |
| 1590 | |
| 1591 | uint32_t |
| 1592 | SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) |
| 1593 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1594 | DWARFDebugInfo* info = DebugInfo(); |
| 1595 | if (info == NULL) |
| 1596 | return 0; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1597 | |
| 1598 | // If we aren't appending the results to this list, then clear the list |
| 1599 | if (!append) |
| 1600 | variables.Clear(); |
| 1601 | |
| 1602 | // Remember how many variables are in the list before we search in case |
| 1603 | // we are appending the results to a variable list. |
| 1604 | const uint32_t original_size = variables.GetSize(); |
| 1605 | |
| 1606 | // Index the DWARF if we haven't already |
| 1607 | if (!m_indexed) |
| 1608 | Index (); |
| 1609 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1610 | SymbolContext sc; |
| 1611 | sc.module_sp = m_obj_file->GetModule()->GetSP(); |
| 1612 | assert (sc.module_sp); |
| 1613 | |
| 1614 | DWARFCompileUnit* cu = NULL; |
| 1615 | DWARFCompileUnit* prev_cu = NULL; |
| 1616 | const DWARFDebugInfoEntry* die = NULL; |
| 1617 | std::vector<NameToDIE::Info> die_info_array; |
| 1618 | const size_t num_matches = m_global_index.Find(regex, die_info_array); |
| 1619 | for (size_t i=0; i<num_matches; ++i, prev_cu = cu) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1620 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1621 | cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); |
| 1622 | |
| 1623 | if (cu != prev_cu) |
| 1624 | cu->ExtractDIEsIfNeeded (false); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1625 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1626 | die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1627 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1628 | sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); |
| 1629 | assert(sc.comp_unit != NULL); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1630 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1631 | ParseVariables(sc, cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1632 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1633 | if (variables.GetSize() - original_size >= max_matches) |
| 1634 | break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1635 | } |
| 1636 | |
| 1637 | // Return the number of variable that were appended to the list |
| 1638 | return variables.GetSize() - original_size; |
| 1639 | } |
| 1640 | |
| 1641 | |
| Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 1642 | void |
| 1643 | SymbolFileDWARF::FindFunctions |
| 1644 | ( |
| 1645 | const ConstString &name, |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1646 | const NameToDIE &name_to_die, |
| Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 1647 | SymbolContextList& sc_list |
| 1648 | ) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1649 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1650 | DWARFDebugInfo* info = DebugInfo(); |
| 1651 | if (info == NULL) |
| 1652 | return; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1653 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1654 | SymbolContext sc; |
| 1655 | sc.module_sp = m_obj_file->GetModule()->GetSP(); |
| 1656 | assert (sc.module_sp); |
| 1657 | |
| 1658 | DWARFCompileUnit* cu = NULL; |
| 1659 | DWARFCompileUnit* prev_cu = NULL; |
| 1660 | const DWARFDebugInfoEntry* die = NULL; |
| 1661 | std::vector<NameToDIE::Info> die_info_array; |
| 1662 | const size_t num_matches = name_to_die.Find(name, die_info_array); |
| 1663 | for (size_t i=0; i<num_matches; ++i, prev_cu = cu) |
| 1664 | { |
| 1665 | cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); |
| 1666 | |
| 1667 | if (cu != prev_cu) |
| 1668 | cu->ExtractDIEsIfNeeded (false); |
| 1669 | |
| 1670 | die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); |
| 1671 | if (GetFunction (cu, die, sc)) |
| 1672 | { |
| 1673 | // We found the function, so we should find the line table |
| 1674 | // and line table entry as well |
| 1675 | LineTable *line_table = sc.comp_unit->GetLineTable(); |
| 1676 | if (line_table == NULL) |
| 1677 | { |
| 1678 | if (ParseCompileUnitLineTable(sc)) |
| 1679 | line_table = sc.comp_unit->GetLineTable(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1680 | } |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1681 | if (line_table != NULL) |
| 1682 | line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry); |
| 1683 | |
| 1684 | sc_list.Append(sc); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1685 | } |
| 1686 | } |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1687 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1688 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1689 | |
| 1690 | void |
| 1691 | SymbolFileDWARF::FindFunctions |
| 1692 | ( |
| 1693 | const RegularExpression ®ex, |
| 1694 | const NameToDIE &name_to_die, |
| 1695 | SymbolContextList& sc_list |
| 1696 | ) |
| 1697 | { |
| 1698 | DWARFDebugInfo* info = DebugInfo(); |
| 1699 | if (info == NULL) |
| 1700 | return; |
| 1701 | |
| 1702 | SymbolContext sc; |
| 1703 | sc.module_sp = m_obj_file->GetModule()->GetSP(); |
| 1704 | assert (sc.module_sp); |
| 1705 | |
| 1706 | DWARFCompileUnit* cu = NULL; |
| 1707 | DWARFCompileUnit* prev_cu = NULL; |
| 1708 | const DWARFDebugInfoEntry* die = NULL; |
| 1709 | std::vector<NameToDIE::Info> die_info_array; |
| 1710 | const size_t num_matches = name_to_die.Find(regex, die_info_array); |
| 1711 | for (size_t i=0; i<num_matches; ++i, prev_cu = cu) |
| 1712 | { |
| 1713 | cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); |
| 1714 | |
| 1715 | if (cu != prev_cu) |
| 1716 | cu->ExtractDIEsIfNeeded (false); |
| 1717 | |
| 1718 | die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); |
| 1719 | if (GetFunction (cu, die, sc)) |
| 1720 | { |
| 1721 | // We found the function, so we should find the line table |
| 1722 | // and line table entry as well |
| 1723 | LineTable *line_table = sc.comp_unit->GetLineTable(); |
| 1724 | if (line_table == NULL) |
| 1725 | { |
| 1726 | if (ParseCompileUnitLineTable(sc)) |
| 1727 | line_table = sc.comp_unit->GetLineTable(); |
| 1728 | } |
| 1729 | if (line_table != NULL) |
| 1730 | line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry); |
| 1731 | |
| 1732 | sc_list.Append(sc); |
| 1733 | } |
| 1734 | } |
| Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 1735 | } |
| 1736 | |
| 1737 | uint32_t |
| 1738 | SymbolFileDWARF::FindFunctions |
| 1739 | ( |
| 1740 | const ConstString &name, |
| 1741 | uint32_t name_type_mask, |
| 1742 | bool append, |
| 1743 | SymbolContextList& sc_list |
| 1744 | ) |
| 1745 | { |
| 1746 | Timer scoped_timer (__PRETTY_FUNCTION__, |
| 1747 | "SymbolFileDWARF::FindFunctions (name = '%s')", |
| 1748 | name.AsCString()); |
| 1749 | |
| Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 1750 | // If we aren't appending the results to this list, then clear the list |
| 1751 | if (!append) |
| 1752 | sc_list.Clear(); |
| 1753 | |
| 1754 | // Remember how many sc_list are in the list before we search in case |
| 1755 | // we are appending the results to a variable list. |
| 1756 | uint32_t original_size = sc_list.GetSize(); |
| 1757 | |
| 1758 | // Index the DWARF if we haven't already |
| 1759 | if (!m_indexed) |
| 1760 | Index (); |
| 1761 | |
| 1762 | if (name_type_mask & eFunctionNameTypeBase) |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1763 | FindFunctions (name, m_function_basename_index, sc_list); |
| Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 1764 | |
| 1765 | if (name_type_mask & eFunctionNameTypeFull) |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1766 | FindFunctions (name, m_function_fullname_index, sc_list); |
| Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 1767 | |
| 1768 | if (name_type_mask & eFunctionNameTypeMethod) |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1769 | FindFunctions (name, m_function_method_index, sc_list); |
| Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 1770 | |
| 1771 | if (name_type_mask & eFunctionNameTypeSelector) |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1772 | FindFunctions (name, m_function_selector_index, sc_list); |
| Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 1773 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1774 | // Return the number of variable that were appended to the list |
| 1775 | return sc_list.GetSize() - original_size; |
| 1776 | } |
| 1777 | |
| 1778 | |
| 1779 | uint32_t |
| 1780 | SymbolFileDWARF::FindFunctions(const RegularExpression& regex, bool append, SymbolContextList& sc_list) |
| 1781 | { |
| 1782 | Timer scoped_timer (__PRETTY_FUNCTION__, |
| 1783 | "SymbolFileDWARF::FindFunctions (regex = '%s')", |
| 1784 | regex.GetText()); |
| 1785 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1786 | // If we aren't appending the results to this list, then clear the list |
| 1787 | if (!append) |
| 1788 | sc_list.Clear(); |
| 1789 | |
| 1790 | // Remember how many sc_list are in the list before we search in case |
| 1791 | // we are appending the results to a variable list. |
| 1792 | uint32_t original_size = sc_list.GetSize(); |
| 1793 | |
| 1794 | // Index the DWARF if we haven't already |
| 1795 | if (!m_indexed) |
| 1796 | Index (); |
| 1797 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1798 | FindFunctions (regex, m_function_basename_index, sc_list); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1799 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1800 | FindFunctions (regex, m_function_fullname_index, sc_list); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1801 | |
| 1802 | // Return the number of variable that were appended to the list |
| 1803 | return sc_list.GetSize() - original_size; |
| 1804 | } |
| 1805 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1806 | uint32_t |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 1807 | SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1808 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1809 | DWARFDebugInfo* info = DebugInfo(); |
| 1810 | if (info == NULL) |
| 1811 | return 0; |
| 1812 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1813 | // If we aren't appending the results to this list, then clear the list |
| 1814 | if (!append) |
| 1815 | types.Clear(); |
| 1816 | |
| Greg Clayton | 6dbd398 | 2010-09-15 05:51:24 +0000 | [diff] [blame] | 1817 | // Index if we already haven't to make sure the compile units |
| 1818 | // get indexed and make their global DIE index list |
| 1819 | if (!m_indexed) |
| 1820 | Index (); |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 1821 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1822 | const uint32_t initial_types_size = types.GetSize(); |
| 1823 | DWARFCompileUnit* cu = NULL; |
| 1824 | DWARFCompileUnit* prev_cu = NULL; |
| 1825 | const DWARFDebugInfoEntry* die = NULL; |
| 1826 | std::vector<NameToDIE::Info> die_info_array; |
| 1827 | const size_t num_matches = m_types_index.Find (name, die_info_array); |
| 1828 | for (size_t i=0; i<num_matches; ++i, prev_cu = cu) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1829 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1830 | cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); |
| 1831 | |
| 1832 | if (cu != prev_cu) |
| 1833 | cu->ExtractDIEsIfNeeded (false); |
| 1834 | |
| 1835 | die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); |
| 1836 | |
| 1837 | Type *matching_type = ResolveType (cu, die); |
| 1838 | if (matching_type) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1839 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1840 | // We found a type pointer, now find the shared pointer form our type list |
| 1841 | TypeSP type_sp (m_obj_file->GetModule()->GetTypeList()->FindType(matching_type->GetID())); |
| 1842 | assert (type_sp.get() != NULL); |
| 1843 | types.InsertUnique (type_sp); |
| 1844 | if (types.GetSize() >= max_matches) |
| 1845 | break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1846 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1847 | } |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 1848 | return types.GetSize() - initial_types_size; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1849 | } |
| 1850 | |
| 1851 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1852 | uint32_t |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 1853 | SymbolFileDWARF::FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, TypeList& types) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1854 | { |
| 1855 | // Remember how many sc_list are in the list before we search in case |
| 1856 | // we are appending the results to a variable list. |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 1857 | uint32_t original_size = types.GetSize(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1858 | |
| 1859 | const uint32_t num_die_offsets = die_offsets.size(); |
| 1860 | // Parse all of the types we found from the pubtypes matches |
| 1861 | uint32_t i; |
| 1862 | uint32_t num_matches = 0; |
| 1863 | for (i = 0; i < num_die_offsets; ++i) |
| 1864 | { |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 1865 | Type *matching_type = ResolveTypeUID (die_offsets[i]); |
| 1866 | if (matching_type) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1867 | { |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 1868 | // We found a type pointer, now find the shared pointer form our type list |
| 1869 | TypeSP type_sp (m_obj_file->GetModule()->GetTypeList()->FindType(matching_type->GetID())); |
| 1870 | assert (type_sp.get() != NULL); |
| 1871 | types.InsertUnique (type_sp); |
| 1872 | ++num_matches; |
| 1873 | if (num_matches >= max_matches) |
| 1874 | break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1875 | } |
| 1876 | } |
| 1877 | |
| 1878 | // Return the number of variable that were appended to the list |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 1879 | return types.GetSize() - original_size; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1880 | } |
| 1881 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1882 | |
| 1883 | size_t |
| 1884 | SymbolFileDWARF::ParseChildParameters |
| 1885 | ( |
| 1886 | const SymbolContext& sc, |
| 1887 | TypeSP& type_sp, |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1888 | DWARFCompileUnit* dwarf_cu, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1889 | const DWARFDebugInfoEntry *parent_die, |
| Greg Clayton | a51ed9b | 2010-09-23 01:09:21 +0000 | [diff] [blame] | 1890 | bool skip_artificial, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1891 | TypeList* type_list, |
| 1892 | std::vector<void *>& function_param_types, |
| 1893 | std::vector<clang::ParmVarDecl*>& function_param_decls |
| 1894 | ) |
| 1895 | { |
| 1896 | if (parent_die == NULL) |
| 1897 | return 0; |
| 1898 | |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 1899 | const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); |
| 1900 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1901 | size_t count = 0; |
| 1902 | const DWARFDebugInfoEntry *die; |
| 1903 | for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) |
| 1904 | { |
| 1905 | dw_tag_t tag = die->Tag(); |
| 1906 | switch (tag) |
| 1907 | { |
| 1908 | case DW_TAG_formal_parameter: |
| 1909 | { |
| 1910 | DWARFDebugInfoEntry::Attributes attributes; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 1911 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1912 | if (num_attributes > 0) |
| 1913 | { |
| 1914 | const char *name = NULL; |
| 1915 | Declaration decl; |
| 1916 | dw_offset_t param_type_die_offset = DW_INVALID_OFFSET; |
| Greg Clayton | a51ed9b | 2010-09-23 01:09:21 +0000 | [diff] [blame] | 1917 | bool is_artificial = false; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1918 | // one of None, Auto, Register, Extern, Static, PrivateExtern |
| 1919 | |
| Sean Callanan | e2ef6e3 | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 1920 | clang::StorageClass storage = clang::SC_None; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1921 | uint32_t i; |
| 1922 | for (i=0; i<num_attributes; ++i) |
| 1923 | { |
| 1924 | const dw_attr_t attr = attributes.AttributeAtIndex(i); |
| 1925 | DWARFFormValue form_value; |
| 1926 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 1927 | { |
| 1928 | switch (attr) |
| 1929 | { |
| 1930 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 1931 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 1932 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 1933 | case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break; |
| 1934 | case DW_AT_type: param_type_die_offset = form_value.Reference(dwarf_cu); break; |
| Greg Clayton | a51ed9b | 2010-09-23 01:09:21 +0000 | [diff] [blame] | 1935 | case DW_AT_artificial: is_artificial = form_value.Unsigned() != 0; break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1936 | case DW_AT_location: |
| 1937 | // if (form_value.BlockData()) |
| 1938 | // { |
| 1939 | // const DataExtractor& debug_info_data = debug_info(); |
| 1940 | // uint32_t block_length = form_value.Unsigned(); |
| 1941 | // DataExtractor location(debug_info_data, form_value.BlockData() - debug_info_data.GetDataStart(), block_length); |
| 1942 | // } |
| 1943 | // else |
| 1944 | // { |
| 1945 | // } |
| 1946 | // break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1947 | case DW_AT_const_value: |
| 1948 | case DW_AT_default_value: |
| 1949 | case DW_AT_description: |
| 1950 | case DW_AT_endianity: |
| 1951 | case DW_AT_is_optional: |
| 1952 | case DW_AT_segment: |
| 1953 | case DW_AT_variable_parameter: |
| 1954 | default: |
| 1955 | case DW_AT_abstract_origin: |
| 1956 | case DW_AT_sibling: |
| 1957 | break; |
| 1958 | } |
| 1959 | } |
| 1960 | } |
| Greg Clayton | a51ed9b | 2010-09-23 01:09:21 +0000 | [diff] [blame] | 1961 | |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1962 | bool skip = false; |
| 1963 | if (skip_artificial) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1964 | { |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1965 | if (is_artificial) |
| 1966 | skip = true; |
| 1967 | else |
| 1968 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1969 | |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1970 | // HACK: Objective C formal parameters "self" and "_cmd" |
| 1971 | // are not marked as artificial in the DWARF... |
| 1972 | CompileUnit *cu = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); |
| 1973 | if (cu && (cu->GetLanguage() == eLanguageTypeObjC || cu->GetLanguage() == eLanguageTypeObjC_plus_plus)) |
| 1974 | { |
| 1975 | if (name && name[0] && (strcmp (name, "self") == 0 || strcmp (name, "_cmd") == 0)) |
| 1976 | skip = true; |
| 1977 | } |
| 1978 | } |
| 1979 | } |
| 1980 | |
| 1981 | if (!skip) |
| 1982 | { |
| 1983 | Type *type = ResolveTypeUID(param_type_die_offset); |
| 1984 | if (type) |
| 1985 | { |
| 1986 | function_param_types.push_back (type->GetOpaqueClangQualType()); |
| 1987 | |
| 1988 | clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetOpaqueClangQualType(), storage); |
| 1989 | assert(param_var_decl); |
| 1990 | function_param_decls.push_back(param_var_decl); |
| 1991 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1992 | } |
| 1993 | } |
| 1994 | } |
| 1995 | break; |
| 1996 | |
| 1997 | default: |
| 1998 | break; |
| 1999 | } |
| 2000 | } |
| 2001 | return count; |
| 2002 | } |
| 2003 | |
| 2004 | size_t |
| 2005 | SymbolFileDWARF::ParseChildEnumerators |
| 2006 | ( |
| 2007 | const SymbolContext& sc, |
| 2008 | TypeSP& type_sp, |
| 2009 | void * enumerator_qual_type, |
| 2010 | uint32_t enumerator_byte_size, |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2011 | DWARFCompileUnit* dwarf_cu, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2012 | const DWARFDebugInfoEntry *parent_die |
| 2013 | ) |
| 2014 | { |
| 2015 | if (parent_die == NULL) |
| 2016 | return 0; |
| 2017 | |
| 2018 | size_t enumerators_added = 0; |
| 2019 | const DWARFDebugInfoEntry *die; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2020 | const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); |
| 2021 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2022 | for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) |
| 2023 | { |
| 2024 | const dw_tag_t tag = die->Tag(); |
| 2025 | if (tag == DW_TAG_enumerator) |
| 2026 | { |
| 2027 | DWARFDebugInfoEntry::Attributes attributes; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2028 | const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2029 | if (num_child_attributes > 0) |
| 2030 | { |
| 2031 | const char *name = NULL; |
| 2032 | bool got_value = false; |
| 2033 | int64_t enum_value = 0; |
| 2034 | Declaration decl; |
| 2035 | |
| 2036 | uint32_t i; |
| 2037 | for (i=0; i<num_child_attributes; ++i) |
| 2038 | { |
| 2039 | const dw_attr_t attr = attributes.AttributeAtIndex(i); |
| 2040 | DWARFFormValue form_value; |
| 2041 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2042 | { |
| 2043 | switch (attr) |
| 2044 | { |
| 2045 | case DW_AT_const_value: |
| 2046 | got_value = true; |
| 2047 | enum_value = form_value.Unsigned(); |
| 2048 | break; |
| 2049 | |
| 2050 | case DW_AT_name: |
| 2051 | name = form_value.AsCString(&get_debug_str_data()); |
| 2052 | break; |
| 2053 | |
| 2054 | case DW_AT_description: |
| 2055 | default: |
| 2056 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 2057 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 2058 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 2059 | case DW_AT_sibling: |
| 2060 | break; |
| 2061 | } |
| 2062 | } |
| 2063 | } |
| 2064 | |
| 2065 | if (name && name[0] && got_value) |
| 2066 | { |
| 2067 | TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); |
| 2068 | type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (type_sp->GetOpaqueClangQualType(), enumerator_qual_type, decl, name, enum_value, enumerator_byte_size * 8); |
| 2069 | ++enumerators_added; |
| 2070 | } |
| 2071 | } |
| 2072 | } |
| 2073 | } |
| 2074 | return enumerators_added; |
| 2075 | } |
| 2076 | |
| 2077 | void |
| 2078 | SymbolFileDWARF::ParseChildArrayInfo |
| 2079 | ( |
| 2080 | const SymbolContext& sc, |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2081 | DWARFCompileUnit* dwarf_cu, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2082 | const DWARFDebugInfoEntry *parent_die, |
| 2083 | int64_t& first_index, |
| 2084 | std::vector<uint64_t>& element_orders, |
| 2085 | uint32_t& byte_stride, |
| 2086 | uint32_t& bit_stride |
| 2087 | ) |
| 2088 | { |
| 2089 | if (parent_die == NULL) |
| 2090 | return; |
| 2091 | |
| 2092 | const DWARFDebugInfoEntry *die; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2093 | const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2094 | for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) |
| 2095 | { |
| 2096 | const dw_tag_t tag = die->Tag(); |
| 2097 | switch (tag) |
| 2098 | { |
| 2099 | case DW_TAG_enumerator: |
| 2100 | { |
| 2101 | DWARFDebugInfoEntry::Attributes attributes; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2102 | const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2103 | if (num_child_attributes > 0) |
| 2104 | { |
| 2105 | const char *name = NULL; |
| 2106 | bool got_value = false; |
| 2107 | int64_t enum_value = 0; |
| 2108 | |
| 2109 | uint32_t i; |
| 2110 | for (i=0; i<num_child_attributes; ++i) |
| 2111 | { |
| 2112 | const dw_attr_t attr = attributes.AttributeAtIndex(i); |
| 2113 | DWARFFormValue form_value; |
| 2114 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2115 | { |
| 2116 | switch (attr) |
| 2117 | { |
| 2118 | case DW_AT_const_value: |
| 2119 | got_value = true; |
| 2120 | enum_value = form_value.Unsigned(); |
| 2121 | break; |
| 2122 | |
| 2123 | case DW_AT_name: |
| 2124 | name = form_value.AsCString(&get_debug_str_data()); |
| 2125 | break; |
| 2126 | |
| 2127 | case DW_AT_description: |
| 2128 | default: |
| 2129 | case DW_AT_decl_file: |
| 2130 | case DW_AT_decl_line: |
| 2131 | case DW_AT_decl_column: |
| 2132 | case DW_AT_sibling: |
| 2133 | break; |
| 2134 | } |
| 2135 | } |
| 2136 | } |
| 2137 | } |
| 2138 | } |
| 2139 | break; |
| 2140 | |
| 2141 | case DW_TAG_subrange_type: |
| 2142 | { |
| 2143 | DWARFDebugInfoEntry::Attributes attributes; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2144 | const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2145 | if (num_child_attributes > 0) |
| 2146 | { |
| 2147 | const char *name = NULL; |
| 2148 | bool got_value = false; |
| 2149 | uint64_t byte_size = 0; |
| 2150 | int64_t enum_value = 0; |
| 2151 | uint64_t num_elements = 0; |
| 2152 | uint64_t lower_bound = 0; |
| 2153 | uint64_t upper_bound = 0; |
| 2154 | uint32_t i; |
| 2155 | for (i=0; i<num_child_attributes; ++i) |
| 2156 | { |
| 2157 | const dw_attr_t attr = attributes.AttributeAtIndex(i); |
| 2158 | DWARFFormValue form_value; |
| 2159 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2160 | { |
| 2161 | switch (attr) |
| 2162 | { |
| 2163 | case DW_AT_const_value: |
| 2164 | got_value = true; |
| 2165 | enum_value = form_value.Unsigned(); |
| 2166 | break; |
| 2167 | |
| 2168 | case DW_AT_name: |
| 2169 | name = form_value.AsCString(&get_debug_str_data()); |
| 2170 | break; |
| 2171 | |
| 2172 | case DW_AT_count: |
| 2173 | num_elements = form_value.Unsigned(); |
| 2174 | break; |
| 2175 | |
| 2176 | case DW_AT_bit_stride: |
| 2177 | bit_stride = form_value.Unsigned(); |
| 2178 | break; |
| 2179 | |
| 2180 | case DW_AT_byte_stride: |
| 2181 | byte_stride = form_value.Unsigned(); |
| 2182 | break; |
| 2183 | |
| 2184 | case DW_AT_byte_size: |
| 2185 | byte_size = form_value.Unsigned(); |
| 2186 | break; |
| 2187 | |
| 2188 | case DW_AT_lower_bound: |
| 2189 | lower_bound = form_value.Unsigned(); |
| 2190 | break; |
| 2191 | |
| 2192 | case DW_AT_upper_bound: |
| 2193 | upper_bound = form_value.Unsigned(); |
| 2194 | break; |
| 2195 | |
| 2196 | default: |
| 2197 | //printf("0x%8.8x: %-30s skipping attribute at 0x%8.8x: %s\n", die->GetOffset(), DW_TAG_value_to_name(tag), attributes.die_offsets[i], DW_AT_value_to_name(attr)); // remove this, debug only |
| 2198 | |
| 2199 | case DW_AT_abstract_origin: |
| 2200 | case DW_AT_accessibility: |
| 2201 | case DW_AT_allocated: |
| 2202 | case DW_AT_associated: |
| 2203 | case DW_AT_data_location: |
| 2204 | case DW_AT_declaration: |
| 2205 | case DW_AT_description: |
| 2206 | case DW_AT_sibling: |
| 2207 | case DW_AT_threads_scaled: |
| 2208 | case DW_AT_type: |
| 2209 | case DW_AT_visibility: |
| 2210 | break; |
| 2211 | } |
| 2212 | } |
| 2213 | } |
| 2214 | |
| 2215 | if (upper_bound > lower_bound) |
| 2216 | num_elements = upper_bound - lower_bound + 1; |
| 2217 | |
| 2218 | if (num_elements > 0) |
| 2219 | element_orders.push_back (num_elements); |
| 2220 | } |
| 2221 | } |
| 2222 | break; |
| 2223 | } |
| 2224 | } |
| 2225 | } |
| 2226 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2227 | TypeSP |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2228 | SymbolFileDWARF::GetTypeForDIE |
| 2229 | ( |
| 2230 | DWARFCompileUnit *cu, |
| 2231 | const DWARFDebugInfoEntry* die, |
| 2232 | TypeSP& owning_type_sp, |
| 2233 | int32_t child_type, |
| 2234 | uint32_t idx |
| 2235 | ) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2236 | { |
| 2237 | TypeSP type_sp; |
| 2238 | if (die != NULL) |
| 2239 | { |
| 2240 | assert(cu != NULL); |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2241 | Type *type_ptr = m_die_to_type.lookup (die); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2242 | if (type_ptr == NULL) |
| 2243 | { |
| 2244 | SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); |
| 2245 | bool type_is_new = false; |
| 2246 | type_sp = ParseType(sc, cu, die, type_is_new); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2247 | if (owning_type_sp.get() == NULL) |
| 2248 | owning_type_sp = type_sp; |
| 2249 | } |
| 2250 | else if (type_ptr != DIE_IS_BEING_PARSED) |
| 2251 | { |
| 2252 | // Grab the existing type from the master types lists |
| 2253 | type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(type_ptr->GetID()); |
| 2254 | } |
| 2255 | |
| 2256 | } |
| 2257 | return type_sp; |
| 2258 | } |
| 2259 | |
| 2260 | clang::DeclContext * |
| 2261 | SymbolFileDWARF::GetClangDeclContextForDIEOffset (dw_offset_t die_offset) |
| 2262 | { |
| 2263 | if (die_offset != DW_INVALID_OFFSET) |
| 2264 | { |
| 2265 | DWARFCompileUnitSP cu_sp; |
| 2266 | const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr(die_offset, &cu_sp); |
| 2267 | return GetClangDeclContextForDIE (cu_sp.get(), die); |
| 2268 | } |
| 2269 | return NULL; |
| 2270 | } |
| 2271 | |
| 2272 | |
| 2273 | |
| 2274 | clang::DeclContext * |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2275 | SymbolFileDWARF::GetClangDeclContextForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2276 | { |
| 2277 | DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die); |
| 2278 | if (pos != m_die_to_decl_ctx.end()) |
| 2279 | return pos->second; |
| 2280 | |
| 2281 | while (die != NULL) |
| 2282 | { |
| 2283 | switch (die->Tag()) |
| 2284 | { |
| 2285 | case DW_TAG_namespace: |
| 2286 | { |
| 2287 | const char *namespace_name = die->GetAttributeValueAsString(this, cu, DW_AT_name, NULL); |
| 2288 | if (namespace_name) |
| 2289 | { |
| 2290 | TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); |
| 2291 | assert(type_list); |
| 2292 | Declaration decl; // TODO: fill in the decl object |
| 2293 | clang::NamespaceDecl *namespace_decl = type_list->GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (cu, die->GetParent())); |
| 2294 | if (namespace_decl) |
| 2295 | m_die_to_decl_ctx[die] = (clang::DeclContext*)namespace_decl; |
| 2296 | return namespace_decl; |
| 2297 | } |
| 2298 | } |
| 2299 | break; |
| 2300 | |
| 2301 | default: |
| 2302 | break; |
| 2303 | } |
| 2304 | clang::DeclContext *decl_ctx; |
| 2305 | decl_ctx = GetClangDeclContextForDIEOffset (die->GetAttributeValueAsUnsigned(this, cu, DW_AT_specification, DW_INVALID_OFFSET)); |
| 2306 | if (decl_ctx) |
| 2307 | return decl_ctx; |
| 2308 | |
| 2309 | decl_ctx = GetClangDeclContextForDIEOffset (die->GetAttributeValueAsUnsigned(this, cu, DW_AT_abstract_origin, DW_INVALID_OFFSET)); |
| 2310 | if (decl_ctx) |
| 2311 | return decl_ctx; |
| 2312 | |
| 2313 | die = die->GetParent(); |
| 2314 | } |
| 2315 | return NULL; |
| 2316 | } |
| 2317 | |
| 2318 | TypeSP |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2319 | SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool &type_is_new) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2320 | { |
| 2321 | TypeSP type_sp; |
| 2322 | |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 2323 | AccessType accessibility = eAccessNone; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2324 | if (die != NULL) |
| 2325 | { |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2326 | Type *type_ptr = m_die_to_type.lookup (die); |
| 2327 | if (type_ptr == NULL) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2328 | { |
| 2329 | type_is_new = true; |
| 2330 | |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2331 | const dw_tag_t tag = die->Tag(); |
| 2332 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2333 | bool is_forward_declaration = false; |
| 2334 | DWARFDebugInfoEntry::Attributes attributes; |
| 2335 | const char *type_name_cstr = NULL; |
| 2336 | ConstString type_name_dbstr; |
| 2337 | Type::EncodingUIDType encoding_uid_type = Type::eIsTypeWithUID; |
| 2338 | void *clang_type = NULL; |
| 2339 | |
| 2340 | TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); |
| 2341 | dw_attr_t attr; |
| 2342 | |
| 2343 | switch (tag) |
| 2344 | { |
| 2345 | case DW_TAG_base_type: |
| 2346 | case DW_TAG_pointer_type: |
| 2347 | case DW_TAG_reference_type: |
| 2348 | case DW_TAG_typedef: |
| 2349 | case DW_TAG_const_type: |
| 2350 | case DW_TAG_restrict_type: |
| 2351 | case DW_TAG_volatile_type: |
| 2352 | { |
| 2353 | //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); |
| 2354 | // Set a bit that lets us know that we are currently parsing this |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2355 | m_die_to_type[die] = DIE_IS_BEING_PARSED; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2356 | |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2357 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2358 | Declaration decl; |
| 2359 | uint32_t encoding = 0; |
| 2360 | size_t byte_size = 0; |
| 2361 | lldb::user_id_t encoding_uid = LLDB_INVALID_UID; |
| 2362 | |
| 2363 | if (num_attributes > 0) |
| 2364 | { |
| 2365 | uint32_t i; |
| 2366 | for (i=0; i<num_attributes; ++i) |
| 2367 | { |
| 2368 | attr = attributes.AttributeAtIndex(i); |
| 2369 | DWARFFormValue form_value; |
| 2370 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2371 | { |
| 2372 | switch (attr) |
| 2373 | { |
| 2374 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 2375 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 2376 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 2377 | case DW_AT_name: |
| 2378 | type_name_cstr = form_value.AsCString(&get_debug_str_data()); |
| 2379 | type_name_dbstr.SetCString(type_name_cstr); |
| 2380 | break; |
| 2381 | case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; |
| 2382 | case DW_AT_encoding: encoding = form_value.Unsigned(); break; |
| 2383 | case DW_AT_type: encoding_uid = form_value.Reference(dwarf_cu); break; |
| 2384 | default: |
| 2385 | case DW_AT_sibling: |
| 2386 | break; |
| 2387 | } |
| 2388 | } |
| 2389 | } |
| 2390 | } |
| 2391 | |
| 2392 | switch (tag) |
| 2393 | { |
| 2394 | default: |
| 2395 | case DW_TAG_base_type: |
| 2396 | clang_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr, encoding, byte_size * 8); |
| 2397 | break; |
| 2398 | |
| 2399 | case DW_TAG_pointer_type: |
| 2400 | // The encoding_uid will be embedded into the |
| 2401 | // Type object and will be looked up when the Type::GetOpaqueClangQualType() |
| 2402 | encoding_uid_type = Type::ePointerToTypeWithUID; |
| 2403 | break; |
| 2404 | |
| 2405 | case DW_TAG_reference_type: |
| 2406 | // The encoding_uid will be embedded into the |
| 2407 | // Type object and will be looked up when the Type::GetOpaqueClangQualType() |
| 2408 | encoding_uid_type = Type::eLValueReferenceToTypeWithUID; |
| 2409 | break; |
| 2410 | |
| 2411 | case DW_TAG_typedef: |
| 2412 | // The encoding_uid will be embedded into the |
| 2413 | // Type object and will be looked up when the Type::GetOpaqueClangQualType() |
| 2414 | encoding_uid_type = Type::eTypedefToTypeWithUID; |
| 2415 | break; |
| 2416 | |
| 2417 | case DW_TAG_const_type: |
| 2418 | // The encoding_uid will be embedded into the |
| 2419 | // Type object and will be looked up when the Type::GetOpaqueClangQualType() |
| 2420 | encoding_uid_type = Type::eIsConstTypeWithUID; //ClangASTContext::AddConstModifier (clang_type); |
| 2421 | break; |
| 2422 | |
| 2423 | case DW_TAG_restrict_type: |
| 2424 | // The encoding_uid will be embedded into the |
| 2425 | // Type object and will be looked up when the Type::GetOpaqueClangQualType() |
| 2426 | encoding_uid_type = Type::eIsRestrictTypeWithUID; //ClangASTContext::AddRestrictModifier (clang_type); |
| 2427 | break; |
| 2428 | |
| 2429 | case DW_TAG_volatile_type: |
| 2430 | // The encoding_uid will be embedded into the |
| 2431 | // Type object and will be looked up when the Type::GetOpaqueClangQualType() |
| 2432 | encoding_uid_type = Type::eIsVolatileTypeWithUID; //ClangASTContext::AddVolatileModifier (clang_type); |
| 2433 | break; |
| 2434 | } |
| 2435 | |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 2436 | if (type_name_cstr != NULL && sc.comp_unit != NULL && |
| 2437 | (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus)) |
| 2438 | { |
| 2439 | static ConstString g_objc_type_name_id("id"); |
| 2440 | static ConstString g_objc_type_name_Class("Class"); |
| 2441 | static ConstString g_objc_type_name_selector("SEL"); |
| 2442 | |
| 2443 | if (type_name_dbstr == g_objc_type_name_id) |
| 2444 | { |
| 2445 | clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_id(); |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 2446 | } |
| 2447 | else if (type_name_dbstr == g_objc_type_name_Class) |
| 2448 | { |
| 2449 | clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_Class(); |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 2450 | } |
| 2451 | else if (type_name_dbstr == g_objc_type_name_selector) |
| 2452 | { |
| 2453 | clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_selector(); |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 2454 | } |
| 2455 | } |
| 2456 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2457 | type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, encoding_uid_type, &decl, clang_type)); |
| 2458 | |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2459 | m_die_to_type[die] = type_sp.get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2460 | |
| 2461 | // Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false); |
| 2462 | // if (encoding_type != NULL) |
| 2463 | // { |
| 2464 | // if (encoding_type != DIE_IS_BEING_PARSED) |
| 2465 | // type_sp->SetEncodingType(encoding_type); |
| 2466 | // else |
| 2467 | // m_indirect_fixups.push_back(type_sp.get()); |
| 2468 | // } |
| 2469 | } |
| 2470 | break; |
| 2471 | |
| 2472 | case DW_TAG_structure_type: |
| 2473 | case DW_TAG_union_type: |
| 2474 | case DW_TAG_class_type: |
| 2475 | { |
| 2476 | //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); |
| 2477 | // Set a bit that lets us know that we are currently parsing this |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2478 | m_die_to_type[die] = DIE_IS_BEING_PARSED; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2479 | |
| 2480 | size_t byte_size = 0; |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 2481 | LanguageType class_language = eLanguageTypeUnknown; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2482 | //bool struct_is_class = false; |
| 2483 | Declaration decl; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2484 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2485 | if (num_attributes > 0) |
| 2486 | { |
| 2487 | uint32_t i; |
| 2488 | for (i=0; i<num_attributes; ++i) |
| 2489 | { |
| 2490 | attr = attributes.AttributeAtIndex(i); |
| 2491 | DWARFFormValue form_value; |
| 2492 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2493 | { |
| 2494 | switch (attr) |
| 2495 | { |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 2496 | case DW_AT_decl_file: |
| 2497 | decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); |
| 2498 | break; |
| 2499 | |
| 2500 | case DW_AT_decl_line: |
| 2501 | decl.SetLine(form_value.Unsigned()); |
| 2502 | break; |
| 2503 | |
| 2504 | case DW_AT_decl_column: |
| 2505 | decl.SetColumn(form_value.Unsigned()); |
| 2506 | break; |
| 2507 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2508 | case DW_AT_name: |
| 2509 | type_name_cstr = form_value.AsCString(&get_debug_str_data()); |
| 2510 | type_name_dbstr.SetCString(type_name_cstr); |
| 2511 | break; |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 2512 | |
| 2513 | case DW_AT_byte_size: |
| 2514 | byte_size = form_value.Unsigned(); |
| 2515 | break; |
| 2516 | |
| 2517 | case DW_AT_accessibility: |
| 2518 | accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); |
| 2519 | break; |
| 2520 | |
| 2521 | case DW_AT_declaration: |
| 2522 | is_forward_declaration = form_value.Unsigned() != 0; |
| 2523 | break; |
| 2524 | |
| 2525 | case DW_AT_APPLE_runtime_class: |
| 2526 | class_language = (LanguageType)form_value.Signed(); |
| 2527 | break; |
| 2528 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2529 | case DW_AT_allocated: |
| 2530 | case DW_AT_associated: |
| 2531 | case DW_AT_data_location: |
| 2532 | case DW_AT_description: |
| 2533 | case DW_AT_start_scope: |
| 2534 | case DW_AT_visibility: |
| 2535 | default: |
| 2536 | case DW_AT_sibling: |
| 2537 | break; |
| 2538 | } |
| 2539 | } |
| 2540 | } |
| 2541 | } |
| 2542 | |
| 2543 | int tag_decl_kind = -1; |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 2544 | AccessType default_accessibility = eAccessNone; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2545 | if (tag == DW_TAG_structure_type) |
| 2546 | { |
| 2547 | tag_decl_kind = clang::TTK_Struct; |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 2548 | default_accessibility = eAccessPublic; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2549 | } |
| 2550 | else if (tag == DW_TAG_union_type) |
| 2551 | { |
| 2552 | tag_decl_kind = clang::TTK_Union; |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 2553 | default_accessibility = eAccessPublic; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2554 | } |
| 2555 | else if (tag == DW_TAG_class_type) |
| 2556 | { |
| 2557 | tag_decl_kind = clang::TTK_Class; |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 2558 | default_accessibility = eAccessPrivate; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2559 | } |
| 2560 | |
| 2561 | assert (tag_decl_kind != -1); |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 2562 | clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2563 | |
| Greg Clayton | 6adffa2 | 2010-09-28 01:04:25 +0000 | [diff] [blame] | 2564 | // Store a forward declaration to this class type in case any |
| 2565 | // parameters in any class methods need it for the clang |
| 2566 | // types for function prototypes. |
| 2567 | m_die_to_clang_type[die] = clang_type; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2568 | m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); |
| 2569 | type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); |
| 2570 | |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2571 | m_die_to_type[die] = type_sp.get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2572 | |
| 2573 | // assert(type_sp.get()); |
| 2574 | // if (accessibility) |
| 2575 | // type_sp->SetAccess(accessibility); |
| 2576 | // |
| 2577 | type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); |
| 2578 | if (die->HasChildren()) |
| 2579 | { |
| 2580 | std::vector<clang::CXXBaseSpecifier *> base_classes; |
| 2581 | std::vector<int> member_accessibilities; |
| 2582 | bool is_a_class = false; |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 2583 | ParseChildMembers (sc, |
| 2584 | type_sp, |
| 2585 | dwarf_cu, |
| 2586 | die, |
| 2587 | clang_type, |
| 2588 | class_language, |
| 2589 | base_classes, |
| 2590 | member_accessibilities, |
| 2591 | default_accessibility, |
| 2592 | is_a_class); |
| 2593 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2594 | // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we |
| 2595 | // need to tell the clang type it is actually a class. |
| Greg Clayton | 9e40956 | 2010-07-28 02:04:09 +0000 | [diff] [blame] | 2596 | if (class_language != eLanguageTypeObjC) |
| 2597 | { |
| 2598 | if (is_a_class && tag_decl_kind != clang::TTK_Class) |
| 2599 | type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class); |
| 2600 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2601 | |
| 2602 | // Since DW_TAG_structure_type gets used for both classes |
| 2603 | // and structures, we may need to set any DW_TAG_member |
| 2604 | // fields to have a "private" access if none was specified. |
| 2605 | // When we parsed the child members we tracked that actual |
| 2606 | // accessibility value for each DW_TAG_member in the |
| 2607 | // "member_accessibilities" array. If the value for the |
| 2608 | // member is zero, then it was set to the "default_accessibility" |
| 2609 | // which for structs was "public". Below we correct this |
| 2610 | // by setting any fields to "private" that weren't correctly |
| 2611 | // set. |
| 2612 | if (is_a_class && !member_accessibilities.empty()) |
| 2613 | { |
| 2614 | // This is a class and all members that didn't have |
| 2615 | // their access specified are private. |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 2616 | type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2617 | } |
| 2618 | |
| 2619 | if (!base_classes.empty()) |
| 2620 | { |
| Greg Clayton | 471b31c | 2010-07-20 22:52:08 +0000 | [diff] [blame] | 2621 | type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size()); |
| 2622 | |
| 2623 | // Clang will copy each CXXBaseSpecifier in "base_classes" |
| 2624 | // so we have to free them all. |
| 2625 | ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2626 | } |
| Greg Clayton | 0b42ac3 | 2010-07-02 01:29:13 +0000 | [diff] [blame] | 2627 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2628 | } |
| 2629 | type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); |
| 2630 | } |
| 2631 | break; |
| 2632 | |
| 2633 | case DW_TAG_enumeration_type: |
| 2634 | { |
| 2635 | //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); |
| 2636 | // Set a bit that lets us know that we are currently parsing this |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2637 | m_die_to_type[die] = DIE_IS_BEING_PARSED; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2638 | |
| 2639 | size_t byte_size = 0; |
| 2640 | lldb::user_id_t encoding_uid = DW_INVALID_OFFSET; |
| 2641 | Declaration decl; |
| 2642 | |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2643 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2644 | if (num_attributes > 0) |
| 2645 | { |
| 2646 | uint32_t i; |
| 2647 | |
| 2648 | for (i=0; i<num_attributes; ++i) |
| 2649 | { |
| 2650 | attr = attributes.AttributeAtIndex(i); |
| 2651 | DWARFFormValue form_value; |
| 2652 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2653 | { |
| 2654 | switch (attr) |
| 2655 | { |
| 2656 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 2657 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 2658 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 2659 | case DW_AT_name: |
| 2660 | type_name_cstr = form_value.AsCString(&get_debug_str_data()); |
| 2661 | type_name_dbstr.SetCString(type_name_cstr); |
| 2662 | break; |
| 2663 | case DW_AT_type: encoding_uid = form_value.Reference(dwarf_cu); break; |
| 2664 | case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; |
| Greg Clayton | 8cf0593 | 2010-07-22 18:30:50 +0000 | [diff] [blame] | 2665 | case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2666 | case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; |
| 2667 | case DW_AT_allocated: |
| 2668 | case DW_AT_associated: |
| 2669 | case DW_AT_bit_stride: |
| 2670 | case DW_AT_byte_stride: |
| 2671 | case DW_AT_data_location: |
| 2672 | case DW_AT_description: |
| 2673 | case DW_AT_start_scope: |
| 2674 | case DW_AT_visibility: |
| 2675 | case DW_AT_specification: |
| 2676 | case DW_AT_abstract_origin: |
| 2677 | case DW_AT_sibling: |
| 2678 | break; |
| 2679 | } |
| 2680 | } |
| 2681 | } |
| Greg Clayton | 83ff389 | 2010-09-12 23:17:56 +0000 | [diff] [blame] | 2682 | |
| 2683 | void *enumerator_qual_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2684 | |
| Greg Clayton | 83ff389 | 2010-09-12 23:17:56 +0000 | [diff] [blame] | 2685 | clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_qual_type); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2686 | m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); |
| 2687 | type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, encoding_uid, Type::eIsTypeWithUID, &decl, clang_type)); |
| 2688 | |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2689 | m_die_to_type[die] = type_sp.get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2690 | |
| 2691 | if (die->HasChildren()) |
| 2692 | { |
| 2693 | type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2694 | ParseChildEnumerators(sc, type_sp, enumerator_qual_type, byte_size, dwarf_cu, die); |
| 2695 | type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); |
| 2696 | } |
| 2697 | } |
| 2698 | } |
| 2699 | break; |
| 2700 | |
| Jim Ingham | b0be442 | 2010-08-12 01:20:14 +0000 | [diff] [blame] | 2701 | case DW_TAG_inlined_subroutine: |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2702 | case DW_TAG_subprogram: |
| 2703 | case DW_TAG_subroutine_type: |
| 2704 | { |
| 2705 | //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); |
| 2706 | // Set a bit that lets us know that we are currently parsing this |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2707 | m_die_to_type[die] = DIE_IS_BEING_PARSED; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2708 | |
| 2709 | const char *mangled = NULL; |
| 2710 | dw_offset_t type_die_offset = DW_INVALID_OFFSET; |
| 2711 | Declaration decl; |
| Greg Clayton | a51ed9b | 2010-09-23 01:09:21 +0000 | [diff] [blame] | 2712 | bool is_variadic = false; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2713 | bool is_inline = false; |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2714 | bool is_static = false; |
| 2715 | bool is_virtual = false; |
| 2716 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2717 | unsigned type_quals = 0; |
| Sean Callanan | e2ef6e3 | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 2718 | clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2719 | |
| 2720 | |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2721 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2722 | if (num_attributes > 0) |
| 2723 | { |
| 2724 | uint32_t i; |
| 2725 | for (i=0; i<num_attributes; ++i) |
| 2726 | { |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2727 | const dw_attr_t attr = attributes.AttributeAtIndex(i); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2728 | DWARFFormValue form_value; |
| 2729 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2730 | { |
| 2731 | switch (attr) |
| 2732 | { |
| 2733 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 2734 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 2735 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 2736 | case DW_AT_name: |
| 2737 | type_name_cstr = form_value.AsCString(&get_debug_str_data()); |
| 2738 | type_name_dbstr.SetCString(type_name_cstr); |
| 2739 | break; |
| 2740 | |
| 2741 | case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; |
| 2742 | case DW_AT_type: type_die_offset = form_value.Reference(dwarf_cu); break; |
| Greg Clayton | 8cf0593 | 2010-07-22 18:30:50 +0000 | [diff] [blame] | 2743 | case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2744 | case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2745 | case DW_AT_inline: is_inline = form_value.Unsigned() != 0; break; |
| 2746 | case DW_AT_virtuality: is_virtual = form_value.Unsigned() != 0; break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2747 | case DW_AT_external: |
| 2748 | if (form_value.Unsigned()) |
| 2749 | { |
| Sean Callanan | e2ef6e3 | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 2750 | if (storage == clang::SC_None) |
| 2751 | storage = clang::SC_Extern; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2752 | else |
| Sean Callanan | e2ef6e3 | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 2753 | storage = clang::SC_PrivateExtern; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2754 | } |
| 2755 | break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2756 | |
| 2757 | case DW_AT_allocated: |
| 2758 | case DW_AT_associated: |
| 2759 | case DW_AT_address_class: |
| 2760 | case DW_AT_artificial: |
| 2761 | case DW_AT_calling_convention: |
| 2762 | case DW_AT_data_location: |
| 2763 | case DW_AT_elemental: |
| 2764 | case DW_AT_entry_pc: |
| 2765 | case DW_AT_explicit: |
| 2766 | case DW_AT_frame_base: |
| 2767 | case DW_AT_high_pc: |
| 2768 | case DW_AT_low_pc: |
| 2769 | case DW_AT_object_pointer: |
| 2770 | case DW_AT_prototyped: |
| 2771 | case DW_AT_pure: |
| 2772 | case DW_AT_ranges: |
| 2773 | case DW_AT_recursive: |
| 2774 | case DW_AT_return_addr: |
| 2775 | case DW_AT_segment: |
| 2776 | case DW_AT_specification: |
| 2777 | case DW_AT_start_scope: |
| 2778 | case DW_AT_static_link: |
| 2779 | case DW_AT_trampoline: |
| 2780 | case DW_AT_visibility: |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2781 | case DW_AT_vtable_elem_location: |
| 2782 | case DW_AT_abstract_origin: |
| 2783 | case DW_AT_description: |
| 2784 | case DW_AT_sibling: |
| 2785 | break; |
| 2786 | } |
| 2787 | } |
| 2788 | } |
| 2789 | |
| 2790 | void *return_clang_type = NULL; |
| 2791 | Type *func_type = ResolveTypeUID(type_die_offset); |
| 2792 | if (func_type) |
| 2793 | return_clang_type = func_type->GetOpaqueClangQualType(); |
| 2794 | else |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 2795 | return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2796 | |
| 2797 | std::vector<void *> function_param_types; |
| 2798 | std::vector<clang::ParmVarDecl*> function_param_decls; |
| 2799 | |
| 2800 | // Parse the function children for the parameters |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2801 | bool skip_artificial = true; |
| 2802 | ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2803 | |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2804 | // clang_type will get the function prototype clang type after this call |
| Greg Clayton | a51ed9b | 2010-09-23 01:09:21 +0000 | [diff] [blame] | 2805 | clang_type = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2806 | if (type_name_cstr) |
| 2807 | { |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 2808 | bool type_handled = false; |
| 2809 | const DWARFDebugInfoEntry *parent_die = die->GetParent(); |
| 2810 | if (tag == DW_TAG_subprogram) |
| 2811 | { |
| 2812 | if (type_name_cstr[1] == '[' && (type_name_cstr[0] == '-' || type_name_cstr[0] == '+')) |
| 2813 | { |
| 2814 | // We need to find the DW_TAG_class_type or |
| 2815 | // DW_TAG_struct_type by name so we can add this |
| 2816 | // as a member function of the class. |
| 2817 | const char *class_name_start = type_name_cstr + 2; |
| 2818 | const char *class_name_end = ::strchr (class_name_start, ' '); |
| 2819 | SymbolContext empty_sc; |
| 2820 | void *class_opaque_type = NULL; |
| 2821 | if (class_name_start < class_name_end) |
| 2822 | { |
| 2823 | ConstString class_name (class_name_start, class_name_end - class_name_start); |
| 2824 | TypeList types; |
| 2825 | const uint32_t match_count = FindTypes (empty_sc, class_name, true, UINT32_MAX, types); |
| 2826 | if (match_count > 0) |
| 2827 | { |
| 2828 | for (uint32_t i=0; i<match_count; ++i) |
| 2829 | { |
| 2830 | Type *type = types.GetTypeAtIndex (i).get(); |
| 2831 | if (ClangASTContext::IsObjCClassType (type->GetOpaqueClangQualType())) |
| 2832 | { |
| 2833 | class_opaque_type = type->GetOpaqueClangQualType(); |
| 2834 | break; |
| 2835 | } |
| 2836 | } |
| 2837 | } |
| 2838 | } |
| 2839 | |
| 2840 | if (class_opaque_type) |
| 2841 | { |
| 2842 | clang::ObjCMethodDecl *objc_method_decl; |
| 2843 | objc_method_decl = type_list->GetClangASTContext().AddMethodToObjCObjectType (class_opaque_type, |
| 2844 | type_name_cstr, |
| 2845 | clang_type, |
| 2846 | accessibility); |
| 2847 | type_handled = objc_method_decl != NULL; |
| 2848 | } |
| 2849 | } |
| 2850 | else if (parent_die->Tag() == DW_TAG_class_type || |
| 2851 | parent_die->Tag() == DW_TAG_structure_type) |
| 2852 | { |
| 2853 | // Look at the parent of this DIE and see if is is |
| 2854 | // a class or struct and see if this is actually a |
| 2855 | // C++ method |
| 2856 | Type *class_type = ResolveType (dwarf_cu, parent_die); |
| 2857 | if (class_type) |
| 2858 | { |
| 2859 | void *class_opaque_type = class_type->GetOpaqueClangQualType (); |
| 2860 | if (ClangASTContext::IsCXXClassType (class_opaque_type)) |
| 2861 | { |
| 2862 | clang::CXXMethodDecl *cxx_method_decl; |
| 2863 | cxx_method_decl = type_list->GetClangASTContext().AddMethodToCXXRecordType (class_opaque_type, |
| 2864 | type_name_cstr, |
| 2865 | clang_type, |
| 2866 | accessibility, |
| 2867 | is_virtual, |
| 2868 | is_static, |
| 2869 | is_inline); |
| 2870 | type_handled = cxx_method_decl != NULL; |
| 2871 | } |
| 2872 | } |
| 2873 | } |
| 2874 | } |
| 2875 | |
| 2876 | if (!type_handled) |
| 2877 | { |
| 2878 | // We just have a function that isn't part of a class |
| 2879 | clang::FunctionDecl *function_decl = type_list->GetClangASTContext().CreateFunctionDeclaration (type_name_cstr, clang_type, storage, is_inline); |
| 2880 | |
| 2881 | // Add the decl to our DIE to decl context map |
| 2882 | assert (function_decl); |
| 2883 | m_die_to_decl_ctx[die] = function_decl; |
| 2884 | if (!function_param_decls.empty()) |
| 2885 | type_list->GetClangASTContext().SetFunctionParameters (function_decl, &function_param_decls.front(), function_param_decls.size()); |
| 2886 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2887 | } |
| 2888 | type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, 0, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); |
| 2889 | |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2890 | m_die_to_type[die] = type_sp.get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2891 | assert(type_sp.get()); |
| 2892 | } |
| 2893 | } |
| 2894 | break; |
| 2895 | |
| 2896 | case DW_TAG_array_type: |
| 2897 | { |
| 2898 | //printf("0x%8.8x: %s (ParesTypes)\n", die->GetOffset(), DW_TAG_value_to_name(tag)); |
| 2899 | // Set a bit that lets us know that we are currently parsing this |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2900 | m_die_to_type[die] = DIE_IS_BEING_PARSED; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2901 | |
| 2902 | size_t byte_size = 0; |
| 2903 | lldb::user_id_t type_die_offset = DW_INVALID_OFFSET; |
| 2904 | Declaration decl; |
| 2905 | int64_t first_index = 0; |
| 2906 | uint32_t byte_stride = 0; |
| 2907 | uint32_t bit_stride = 0; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2908 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2909 | |
| 2910 | if (num_attributes > 0) |
| 2911 | { |
| 2912 | uint32_t i; |
| 2913 | for (i=0; i<num_attributes; ++i) |
| 2914 | { |
| 2915 | attr = attributes.AttributeAtIndex(i); |
| 2916 | DWARFFormValue form_value; |
| 2917 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2918 | { |
| 2919 | switch (attr) |
| 2920 | { |
| 2921 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 2922 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 2923 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 2924 | case DW_AT_name: |
| 2925 | type_name_cstr = form_value.AsCString(&get_debug_str_data()); |
| 2926 | type_name_dbstr.SetCString(type_name_cstr); |
| 2927 | break; |
| 2928 | |
| 2929 | case DW_AT_type: type_die_offset = form_value.Reference(dwarf_cu); break; |
| 2930 | case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; |
| 2931 | case DW_AT_byte_stride: byte_stride = form_value.Unsigned(); break; |
| 2932 | case DW_AT_bit_stride: bit_stride = form_value.Unsigned(); break; |
| Greg Clayton | 8cf0593 | 2010-07-22 18:30:50 +0000 | [diff] [blame] | 2933 | case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2934 | case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; |
| 2935 | case DW_AT_allocated: |
| 2936 | case DW_AT_associated: |
| 2937 | case DW_AT_data_location: |
| 2938 | case DW_AT_description: |
| 2939 | case DW_AT_ordering: |
| 2940 | case DW_AT_start_scope: |
| 2941 | case DW_AT_visibility: |
| 2942 | case DW_AT_specification: |
| 2943 | case DW_AT_abstract_origin: |
| 2944 | case DW_AT_sibling: |
| 2945 | break; |
| 2946 | } |
| 2947 | } |
| 2948 | } |
| 2949 | |
| 2950 | Type *element_type = ResolveTypeUID(type_die_offset); |
| 2951 | |
| 2952 | if (element_type) |
| 2953 | { |
| 2954 | std::vector<uint64_t> element_orders; |
| 2955 | ParseChildArrayInfo(sc, dwarf_cu, die, first_index, element_orders, byte_stride, bit_stride); |
| Greg Clayton | a134cc1 | 2010-09-13 02:37:44 +0000 | [diff] [blame] | 2956 | // We have an array that claims to have no members, lets give it at least one member... |
| 2957 | if (element_orders.empty()) |
| 2958 | element_orders.push_back (1); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2959 | if (byte_stride == 0 && bit_stride == 0) |
| 2960 | byte_stride = element_type->GetByteSize(); |
| 2961 | void *array_element_type = element_type->GetOpaqueClangQualType(); |
| 2962 | uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride; |
| 2963 | uint64_t num_elements = 0; |
| 2964 | std::vector<uint64_t>::const_reverse_iterator pos; |
| 2965 | std::vector<uint64_t>::const_reverse_iterator end = element_orders.rend(); |
| 2966 | for (pos = element_orders.rbegin(); pos != end; ++pos) |
| 2967 | { |
| 2968 | num_elements = *pos; |
| 2969 | clang_type = type_list->GetClangASTContext().CreateArrayType (array_element_type, num_elements, num_elements * array_element_bit_stride); |
| 2970 | array_element_type = clang_type; |
| 2971 | array_element_bit_stride = array_element_bit_stride * num_elements; |
| 2972 | } |
| 2973 | ConstString empty_name; |
| 2974 | type_sp.reset( new Type(die->GetOffset(), this, empty_name, array_element_bit_stride / 8, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 2975 | m_die_to_type[die] = type_sp.get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2976 | } |
| 2977 | } |
| 2978 | } |
| 2979 | break; |
| 2980 | |
| Greg Clayton | 9b81a31 | 2010-06-12 01:20:30 +0000 | [diff] [blame] | 2981 | case DW_TAG_ptr_to_member_type: |
| 2982 | { |
| 2983 | dw_offset_t type_die_offset = DW_INVALID_OFFSET; |
| 2984 | dw_offset_t containing_type_die_offset = DW_INVALID_OFFSET; |
| 2985 | |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 2986 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); |
| Greg Clayton | 9b81a31 | 2010-06-12 01:20:30 +0000 | [diff] [blame] | 2987 | |
| 2988 | if (num_attributes > 0) { |
| 2989 | uint32_t i; |
| 2990 | for (i=0; i<num_attributes; ++i) |
| 2991 | { |
| 2992 | attr = attributes.AttributeAtIndex(i); |
| 2993 | DWARFFormValue form_value; |
| 2994 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 2995 | { |
| 2996 | switch (attr) |
| 2997 | { |
| 2998 | case DW_AT_type: |
| 2999 | type_die_offset = form_value.Reference(dwarf_cu); break; |
| 3000 | case DW_AT_containing_type: |
| 3001 | containing_type_die_offset = form_value.Reference(dwarf_cu); break; |
| 3002 | } |
| 3003 | } |
| 3004 | } |
| 3005 | |
| 3006 | Type *pointee_type = ResolveTypeUID(type_die_offset); |
| 3007 | Type *class_type = ResolveTypeUID(containing_type_die_offset); |
| 3008 | |
| 3009 | void *pointee_clang_type = pointee_type->GetOpaqueClangQualType(); |
| Greg Clayton | 1ba811d | 2010-06-12 15:33:14 +0000 | [diff] [blame] | 3010 | void *class_clang_type = class_type->GetOpaqueClangQualType(); |
| Greg Clayton | 9b81a31 | 2010-06-12 01:20:30 +0000 | [diff] [blame] | 3011 | |
| Greg Clayton | b132097 | 2010-07-14 00:18:15 +0000 | [diff] [blame] | 3012 | clang_type = type_list->GetClangASTContext().CreateMemberPointerType(pointee_clang_type, class_clang_type); |
| Greg Clayton | 9b81a31 | 2010-06-12 01:20:30 +0000 | [diff] [blame] | 3013 | |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 3014 | size_t byte_size = ClangASTType::GetClangTypeBitWidth (type_list->GetClangASTContext().getASTContext(), clang_type) / 8; |
| Greg Clayton | 9b81a31 | 2010-06-12 01:20:30 +0000 | [diff] [blame] | 3015 | |
| 3016 | type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, byte_size, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, NULL, clang_type)); |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 3017 | m_die_to_type[die] = type_sp.get(); |
| Greg Clayton | 9b81a31 | 2010-06-12 01:20:30 +0000 | [diff] [blame] | 3018 | } |
| 3019 | |
| 3020 | break; |
| 3021 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3022 | default: |
| Greg Clayton | 9b81a31 | 2010-06-12 01:20:30 +0000 | [diff] [blame] | 3023 | assert(false && "Unhandled type tag!"); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3024 | break; |
| 3025 | } |
| 3026 | |
| 3027 | if (type_sp.get()) |
| 3028 | { |
| 3029 | const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die); |
| 3030 | dw_tag_t sc_parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; |
| 3031 | |
| 3032 | SymbolContextScope * symbol_context_scope = NULL; |
| 3033 | if (sc_parent_tag == DW_TAG_compile_unit) |
| 3034 | { |
| 3035 | symbol_context_scope = sc.comp_unit; |
| 3036 | } |
| 3037 | else if (sc.function != NULL) |
| 3038 | { |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 3039 | symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3040 | if (symbol_context_scope == NULL) |
| 3041 | symbol_context_scope = sc.function; |
| 3042 | } |
| 3043 | |
| 3044 | if (symbol_context_scope != NULL) |
| 3045 | { |
| 3046 | type_sp->SetSymbolContextScope(symbol_context_scope); |
| 3047 | } |
| 3048 | |
| 3049 | // if (udt_sp.get()) |
| 3050 | // { |
| 3051 | // if (is_forward_declaration) |
| 3052 | // udt_sp->GetFlags().Set(UserDefType::flagIsForwardDefinition); |
| 3053 | // type_sp->SetUserDefinedType(udt_sp); |
| 3054 | // } |
| 3055 | |
| 3056 | if (type_sp.unique()) |
| 3057 | { |
| 3058 | // We are ready to put this type into the uniqued list up at the module level |
| 3059 | TypeSP uniqued_type_sp(m_obj_file->GetModule()->GetTypeList()->InsertUnique(type_sp)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3060 | type_sp = uniqued_type_sp; |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 3061 | m_die_to_type[die] = type_sp.get(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3062 | } |
| 3063 | } |
| 3064 | } |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 3065 | else if (type_ptr != DIE_IS_BEING_PARSED) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3066 | { |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 3067 | type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(type_ptr->GetID()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3068 | } |
| 3069 | } |
| 3070 | return type_sp; |
| 3071 | } |
| 3072 | |
| 3073 | size_t |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 3074 | SymbolFileDWARF::ParseTypes (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3075 | { |
| 3076 | size_t types_added = 0; |
| 3077 | while (die != NULL) |
| 3078 | { |
| 3079 | bool type_is_new = false; |
| 3080 | if (ParseType(sc, dwarf_cu, die, type_is_new).get()) |
| 3081 | { |
| 3082 | if (type_is_new) |
| 3083 | ++types_added; |
| 3084 | } |
| 3085 | |
| 3086 | if (parse_children && die->HasChildren()) |
| 3087 | { |
| 3088 | if (die->Tag() == DW_TAG_subprogram) |
| 3089 | { |
| 3090 | SymbolContext child_sc(sc); |
| 3091 | child_sc.function = sc.comp_unit->FindFunctionByUID(die->GetOffset()).get(); |
| 3092 | types_added += ParseTypes(child_sc, dwarf_cu, die->GetFirstChild(), true, true); |
| 3093 | } |
| 3094 | else |
| 3095 | types_added += ParseTypes(sc, dwarf_cu, die->GetFirstChild(), true, true); |
| 3096 | } |
| 3097 | |
| 3098 | if (parse_siblings) |
| 3099 | die = die->GetSibling(); |
| 3100 | else |
| 3101 | die = NULL; |
| 3102 | } |
| 3103 | return types_added; |
| 3104 | } |
| 3105 | |
| 3106 | |
| 3107 | size_t |
| 3108 | SymbolFileDWARF::ParseFunctionBlocks (const SymbolContext &sc) |
| 3109 | { |
| 3110 | assert(sc.comp_unit && sc.function); |
| 3111 | size_t functions_added = 0; |
| 3112 | DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); |
| 3113 | if (dwarf_cu) |
| 3114 | { |
| 3115 | dw_offset_t function_die_offset = sc.function->GetID(); |
| 3116 | const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(function_die_offset); |
| 3117 | if (function_die) |
| 3118 | { |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 3119 | ParseFunctionBlocks(sc, &sc.function->GetBlock (false), dwarf_cu, function_die, LLDB_INVALID_ADDRESS, false, true); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3120 | } |
| 3121 | } |
| 3122 | |
| 3123 | return functions_added; |
| 3124 | } |
| 3125 | |
| 3126 | |
| 3127 | size_t |
| 3128 | SymbolFileDWARF::ParseTypes (const SymbolContext &sc) |
| 3129 | { |
| 3130 | // At least a compile unit must be valid |
| 3131 | assert(sc.comp_unit); |
| 3132 | size_t types_added = 0; |
| 3133 | DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); |
| 3134 | if (dwarf_cu) |
| 3135 | { |
| 3136 | if (sc.function) |
| 3137 | { |
| 3138 | dw_offset_t function_die_offset = sc.function->GetID(); |
| 3139 | const DWARFDebugInfoEntry *func_die = dwarf_cu->GetDIEPtr(function_die_offset); |
| 3140 | if (func_die && func_die->HasChildren()) |
| 3141 | { |
| 3142 | types_added = ParseTypes(sc, dwarf_cu, func_die->GetFirstChild(), true, true); |
| 3143 | } |
| 3144 | } |
| 3145 | else |
| 3146 | { |
| 3147 | const DWARFDebugInfoEntry *dwarf_cu_die = dwarf_cu->DIE(); |
| 3148 | if (dwarf_cu_die && dwarf_cu_die->HasChildren()) |
| 3149 | { |
| 3150 | types_added = ParseTypes(sc, dwarf_cu, dwarf_cu_die->GetFirstChild(), true, true); |
| 3151 | } |
| 3152 | } |
| 3153 | } |
| 3154 | |
| 3155 | return types_added; |
| 3156 | } |
| 3157 | |
| 3158 | size_t |
| 3159 | SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc) |
| 3160 | { |
| 3161 | if (sc.comp_unit != NULL) |
| 3162 | { |
| 3163 | DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); |
| 3164 | |
| 3165 | if (dwarf_cu == NULL) |
| 3166 | return 0; |
| 3167 | |
| 3168 | if (sc.function) |
| 3169 | { |
| 3170 | const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(sc.function->GetID()); |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 3171 | |
| 3172 | dw_addr_t func_lo_pc = function_die->GetAttributeValueAsUnsigned (this, dwarf_cu, DW_AT_low_pc, DW_INVALID_ADDRESS); |
| 3173 | assert (func_lo_pc != DW_INVALID_ADDRESS); |
| 3174 | |
| 3175 | return ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3176 | } |
| 3177 | else if (sc.comp_unit) |
| 3178 | { |
| 3179 | uint32_t vars_added = 0; |
| 3180 | VariableListSP variables (sc.comp_unit->GetVariableList(false)); |
| 3181 | |
| 3182 | if (variables.get() == NULL) |
| 3183 | { |
| 3184 | variables.reset(new VariableList()); |
| 3185 | sc.comp_unit->SetVariableList(variables); |
| 3186 | |
| 3187 | // Index if we already haven't to make sure the compile units |
| 3188 | // get indexed and make their global DIE index list |
| 3189 | if (!m_indexed) |
| 3190 | Index (); |
| 3191 | |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 3192 | |
| 3193 | std::vector<NameToDIE::Info> global_die_info_array; |
| 3194 | const size_t num_globals = m_global_index.FindAllEntriesForCompileUnitWithIndex (sc.comp_unit->GetID(), global_die_info_array); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3195 | for (size_t idx=0; idx<num_globals; ++idx) |
| 3196 | { |
| Greg Clayton | c685f8e | 2010-09-15 04:15:46 +0000 | [diff] [blame] | 3197 | VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, dwarf_cu->GetDIEAtIndexUnchecked(global_die_info_array[idx].die_idx), LLDB_INVALID_ADDRESS)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3198 | if (var_sp) |
| 3199 | { |
| 3200 | variables->AddVariable(var_sp); |
| 3201 | ++vars_added; |
| 3202 | } |
| 3203 | } |
| 3204 | } |
| 3205 | return vars_added; |
| 3206 | } |
| 3207 | } |
| 3208 | return 0; |
| 3209 | } |
| 3210 | |
| 3211 | |
| 3212 | VariableSP |
| 3213 | SymbolFileDWARF::ParseVariableDIE |
| 3214 | ( |
| 3215 | const SymbolContext& sc, |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 3216 | DWARFCompileUnit* dwarf_cu, |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 3217 | const DWARFDebugInfoEntry *die, |
| 3218 | const lldb::addr_t func_low_pc |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3219 | ) |
| 3220 | { |
| 3221 | |
| 3222 | VariableSP var_sp; |
| 3223 | |
| 3224 | const dw_tag_t tag = die->Tag(); |
| 3225 | DWARFDebugInfoEntry::Attributes attributes; |
| Greg Clayton | d88d759 | 2010-09-15 08:33:30 +0000 | [diff] [blame] | 3226 | const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3227 | if (num_attributes > 0) |
| 3228 | { |
| 3229 | const char *name = NULL; |
| Greg Clayton | a134cc1 | 2010-09-13 02:37:44 +0000 | [diff] [blame] | 3230 | const char *mangled = NULL; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3231 | Declaration decl; |
| 3232 | uint32_t i; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3233 | Type *var_type = NULL; |
| 3234 | DWARFExpression location; |
| 3235 | bool is_external = false; |
| 3236 | bool is_artificial = false; |
| Sean Callanan | c7fbf73 | 2010-08-06 00:32:49 +0000 | [diff] [blame] | 3237 | AccessType accessibility = eAccessNone; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3238 | |
| 3239 | for (i=0; i<num_attributes; ++i) |
| 3240 | { |
| 3241 | dw_attr_t attr = attributes.AttributeAtIndex(i); |
| 3242 | DWARFFormValue form_value; |
| 3243 | if (attributes.ExtractFormValueAtIndex(this, i, form_value)) |
| 3244 | { |
| 3245 | switch (attr) |
| 3246 | { |
| 3247 | case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; |
| 3248 | case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; |
| 3249 | case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; |
| 3250 | case DW_AT_name: name = form_value.AsCString(&get_debug_str_data()); break; |
| Greg Clayton | a134cc1 | 2010-09-13 02:37:44 +0000 | [diff] [blame] | 3251 | case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 3252 | case DW_AT_type: var_type = ResolveTypeUID(form_value.Reference(dwarf_cu)); break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3253 | case DW_AT_external: is_external = form_value.Unsigned() != 0; break; |
| 3254 | case DW_AT_location: |
| 3255 | { |
| 3256 | if (form_value.BlockData()) |
| 3257 | { |
| 3258 | const DataExtractor& debug_info_data = get_debug_info_data(); |
| 3259 | |
| 3260 | uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); |
| 3261 | uint32_t block_length = form_value.Unsigned(); |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 3262 | location.SetOpcodeData(get_debug_info_data(), block_offset, block_length); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3263 | } |
| 3264 | else |
| 3265 | { |
| 3266 | const DataExtractor& debug_loc_data = get_debug_loc_data(); |
| 3267 | const dw_offset_t debug_loc_offset = form_value.Unsigned(); |
| 3268 | |
| 3269 | size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset); |
| 3270 | if (loc_list_length > 0) |
| 3271 | { |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 3272 | location.SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length); |
| 3273 | assert (func_low_pc != LLDB_INVALID_ADDRESS); |
| 3274 | location.SetLocationListSlide (func_low_pc - dwarf_cu->GetBaseAddress()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3275 | } |
| 3276 | } |
| 3277 | } |
| 3278 | break; |
| 3279 | |
| 3280 | case DW_AT_artificial: is_artificial = form_value.Unsigned() != 0; break; |
| Greg Clayton | 8cf0593 | 2010-07-22 18:30:50 +0000 | [diff] [blame] | 3281 | case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3282 | case DW_AT_const_value: |
| 3283 | case DW_AT_declaration: |
| 3284 | case DW_AT_description: |
| 3285 | case DW_AT_endianity: |
| 3286 | case DW_AT_segment: |
| 3287 | case DW_AT_start_scope: |
| 3288 | case DW_AT_visibility: |
| 3289 | default: |
| 3290 | case DW_AT_abstract_origin: |
| 3291 | case DW_AT_sibling: |
| 3292 | case DW_AT_specification: |
| 3293 | break; |
| 3294 | } |
| 3295 | } |
| 3296 | } |
| 3297 | |
| 3298 | if (location.IsValid()) |
| 3299 | { |
| 3300 | assert(var_type != DIE_IS_BEING_PARSED); |
| 3301 | |
| Greg Clayton | a134cc1 | 2010-09-13 02:37:44 +0000 | [diff] [blame] | 3302 | ConstString var_name; |
| 3303 | if (mangled) |
| 3304 | { |
| 3305 | Mangled mangled_var_name (mangled, true); |
| 3306 | var_name = mangled_var_name.GetDemangledName(); |
| 3307 | } |
| 3308 | |
| 3309 | if (!var_name && name) |
| 3310 | { |
| 3311 | var_name.SetCString(name); |
| 3312 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3313 | |
| 3314 | ValueType scope = eValueTypeInvalid; |
| 3315 | |
| 3316 | const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die); |
| 3317 | dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; |
| 3318 | |
| 3319 | if (tag == DW_TAG_formal_parameter) |
| 3320 | scope = eValueTypeVariableArgument; |
| 3321 | else if (is_external || parent_tag == DW_TAG_compile_unit) |
| 3322 | scope = eValueTypeVariableGlobal; |
| 3323 | else |
| 3324 | scope = eValueTypeVariableLocal; |
| 3325 | |
| 3326 | SymbolContextScope * symbol_context_scope = NULL; |
| 3327 | if (parent_tag == DW_TAG_compile_unit) |
| 3328 | { |
| 3329 | symbol_context_scope = sc.comp_unit; |
| 3330 | } |
| 3331 | else if (sc.function != NULL) |
| 3332 | { |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 3333 | symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3334 | if (symbol_context_scope == NULL) |
| 3335 | symbol_context_scope = sc.function; |
| 3336 | } |
| 3337 | |
| 3338 | assert(symbol_context_scope != NULL); |
| 3339 | var_sp.reset (new Variable(die->GetOffset(), |
| 3340 | var_name, |
| 3341 | var_type, |
| 3342 | scope, |
| 3343 | symbol_context_scope, |
| 3344 | &decl, |
| 3345 | location, |
| 3346 | is_external, |
| 3347 | is_artificial)); |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 3348 | |
| 3349 | m_die_to_variable_sp[die] = var_sp; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3350 | } |
| 3351 | } |
| 3352 | return var_sp; |
| 3353 | } |
| 3354 | |
| 3355 | size_t |
| 3356 | SymbolFileDWARF::ParseVariables |
| 3357 | ( |
| 3358 | const SymbolContext& sc, |
| Greg Clayton | 0fffff5 | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 3359 | DWARFCompileUnit* dwarf_cu, |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 3360 | const lldb::addr_t func_low_pc, |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3361 | const DWARFDebugInfoEntry *orig_die, |
| 3362 | bool parse_siblings, |
| 3363 | bool parse_children, |
| 3364 | VariableList* cc_variable_list |
| 3365 | ) |
| 3366 | { |
| 3367 | if (orig_die == NULL) |
| 3368 | return 0; |
| 3369 | |
| 3370 | size_t vars_added = 0; |
| 3371 | const DWARFDebugInfoEntry *die = orig_die; |
| 3372 | const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(orig_die); |
| 3373 | dw_tag_t parent_tag = sc_parent_die ? sc_parent_die->Tag() : 0; |
| 3374 | VariableListSP variables; |
| 3375 | switch (parent_tag) |
| 3376 | { |
| 3377 | case DW_TAG_compile_unit: |
| 3378 | if (sc.comp_unit != NULL) |
| 3379 | { |
| 3380 | variables = sc.comp_unit->GetVariableList(false); |
| 3381 | if (variables.get() == NULL) |
| 3382 | { |
| 3383 | variables.reset(new VariableList()); |
| 3384 | sc.comp_unit->SetVariableList(variables); |
| 3385 | } |
| 3386 | } |
| 3387 | else |
| 3388 | { |
| 3389 | assert(!"Parent DIE was a compile unit, yet we don't have a valid compile unit in the symbol context..."); |
| 3390 | vars_added = 0; |
| 3391 | } |
| 3392 | break; |
| 3393 | |
| 3394 | case DW_TAG_subprogram: |
| 3395 | case DW_TAG_inlined_subroutine: |
| 3396 | case DW_TAG_lexical_block: |
| 3397 | if (sc.function != NULL) |
| 3398 | { |
| 3399 | // Check to see if we already have parsed the variables for the given scope |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 3400 | |
| 3401 | Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); |
| 3402 | assert (block != NULL); |
| 3403 | variables = block->GetVariableList(false, true); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3404 | if (variables.get() == NULL) |
| 3405 | { |
| 3406 | variables.reset(new VariableList()); |
| Greg Clayton | 0b76a2c | 2010-08-21 02:22:51 +0000 | [diff] [blame] | 3407 | block->SetVariableList(variables); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3408 | } |
| 3409 | } |
| 3410 | else |
| 3411 | { |
| 3412 | assert(!"Parent DIE was a function or block, yet we don't have a function in the symbol context..."); |
| 3413 | vars_added = 0; |
| 3414 | } |
| 3415 | break; |
| 3416 | |
| 3417 | default: |
| 3418 | assert(!"Didn't find appropriate parent DIE for variable list..."); |
| 3419 | break; |
| 3420 | } |
| 3421 | |
| 3422 | // We need to have a variable list at this point that we can add variables to |
| 3423 | assert(variables.get()); |
| 3424 | |
| 3425 | while (die != NULL) |
| 3426 | { |
| 3427 | dw_tag_t tag = die->Tag(); |
| 3428 | |
| 3429 | // Check to see if we have already parsed this variable or constant? |
| Greg Clayton | 594e5ed | 2010-09-27 21:07:38 +0000 | [diff] [blame] | 3430 | if (m_die_to_variable_sp[die].get() == NULL) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3431 | { |
| 3432 | // We haven't already parsed it, lets do that now. |
| 3433 | if ((tag == DW_TAG_variable) || |
| 3434 | (tag == DW_TAG_constant) || |
| 3435 | (tag == DW_TAG_formal_parameter && sc.function)) |
| 3436 | { |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 3437 | VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3438 | if (var_sp) |
| 3439 | { |
| 3440 | variables->AddVariable(var_sp); |
| 3441 | ++vars_added; |
| 3442 | } |
| 3443 | } |
| 3444 | } |
| 3445 | |
| 3446 | bool skip_children = (sc.function == NULL && tag == DW_TAG_subprogram); |
| 3447 | |
| 3448 | if (!skip_children && parse_children && die->HasChildren()) |
| 3449 | { |
| Greg Clayton | 016a95e | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 3450 | vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 3451 | //vars_added += ParseVariables(sc, dwarf_cu, die->GetFirstChild(), parse_siblings, parse_children); |
| 3452 | } |
| 3453 | |
| 3454 | if (parse_siblings) |
| 3455 | die = die->GetSibling(); |
| 3456 | else |
| 3457 | die = NULL; |
| 3458 | } |
| 3459 | |
| 3460 | if (cc_variable_list) |
| 3461 | { |
| 3462 | cc_variable_list->AddVariables(variables.get()); |
| 3463 | } |
| 3464 | |
| 3465 | return vars_added; |
| 3466 | } |
| 3467 | |
| 3468 | //------------------------------------------------------------------ |
| 3469 | // PluginInterface protocol |
| 3470 | //------------------------------------------------------------------ |
| 3471 | const char * |
| 3472 | SymbolFileDWARF::GetPluginName() |
| 3473 | { |
| 3474 | return "SymbolFileDWARF"; |
| 3475 | } |
| 3476 | |
| 3477 | const char * |
| 3478 | SymbolFileDWARF::GetShortPluginName() |
| 3479 | { |
| 3480 | return GetPluginNameStatic(); |
| 3481 | } |
| 3482 | |
| 3483 | uint32_t |
| 3484 | SymbolFileDWARF::GetPluginVersion() |
| 3485 | { |
| 3486 | return 1; |
| 3487 | } |
| 3488 | |
| 3489 | void |
| 3490 | SymbolFileDWARF::GetPluginCommandHelp (const char *command, Stream *strm) |
| 3491 | { |
| 3492 | } |
| 3493 | |
| 3494 | Error |
| 3495 | SymbolFileDWARF::ExecutePluginCommand (Args &command, Stream *strm) |
| 3496 | { |
| 3497 | Error error; |
| 3498 | error.SetErrorString("No plug-in command are currently supported."); |
| 3499 | return error; |
| 3500 | } |
| 3501 | |
| 3502 | Log * |
| 3503 | SymbolFileDWARF::EnablePluginLogging (Stream *strm, Args &command) |
| 3504 | { |
| 3505 | return NULL; |
| 3506 | } |
| 3507 | |