diff options
| author | Greg Clayton <gclayton@apple.com> | 2013-05-15 19:52:08 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2013-05-15 19:52:08 +0000 |
| commit | 9aae0a13bfdfb37c6ae236c4b499a027c3a5c59d (patch) | |
| tree | e4788230091ba6e6a642b961162d6c9c8fb846aa | |
| parent | a76d8cd05b18becbff488fe6864561088221ae62 (diff) | |
| download | bcm5719-llvm-9aae0a13bfdfb37c6ae236c4b499a027c3a5c59d.tar.gz bcm5719-llvm-9aae0a13bfdfb37c6ae236c4b499a027c3a5c59d.zip | |
<rdar://problem/13128331>
Fixed "target symbols add" to correctly extract all module specifications from a dSYM file that is supplied and match the symbol file to a current target module using the UUID values if they are available.
This fixes the case where you add a dSYM file (like "foo.dSYM") which is for a renamed executable (like "bar"). In our case it was "mach_kernel.dSYM" which didn't match "mach_kernel.sys".
llvm-svn: 181916
| -rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 49 | ||||
| -rw-r--r-- | lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 45 |
2 files changed, 69 insertions, 25 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 5d3de8df991..7765352922a 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -4272,7 +4272,53 @@ protected: // current target, so we need to find that module in the // target ModuleList matching_module_list; - size_t num_matches = target->GetImages().FindModules (module_spec, matching_module_list); + + size_t num_matches = 0; + // First extract all module specs from the symbol file + lldb_private::ModuleSpecList symfile_module_specs; + if (ObjectFile::GetModuleSpecifications(module_spec.GetSymbolFileSpec(), 0, symfile_module_specs)) + { + // Now extract the module spec that matches the target architecture + ModuleSpec target_arch_module_spec; + ModuleSpec symfile_module_spec; + target_arch_module_spec.GetArchitecture() = target->GetArchitecture(); + if (symfile_module_specs.FindMatchingModuleSpec(target_arch_module_spec, symfile_module_spec)) + { + // See if it has a UUID? + if (symfile_module_spec.GetUUID().IsValid()) + { + // It has a UUID, look for this UUID in the target modules + ModuleSpec symfile_uuid_module_spec; + symfile_uuid_module_spec.GetUUID() = symfile_module_spec.GetUUID(); + num_matches = target->GetImages().FindModules (symfile_uuid_module_spec, matching_module_list); + } + } + + if (num_matches == 0) + { + // No matches yet, iterate through the module specs to find a UUID value that + // we can match up to an image in our target + const size_t num_symfile_module_specs = symfile_module_specs.GetSize(); + for (size_t i=0; i<num_symfile_module_specs && num_matches == 0; ++i) + { + if (symfile_module_specs.GetModuleSpecAtIndex(i, symfile_module_spec)) + { + if (symfile_module_spec.GetUUID().IsValid()) + { + // It has a UUID, look for this UUID in the target modules + ModuleSpec symfile_uuid_module_spec; + symfile_uuid_module_spec.GetUUID() = symfile_module_spec.GetUUID(); + num_matches = target->GetImages().FindModules (symfile_uuid_module_spec, matching_module_list); + } + } + } + } + } + + // Just try to match up the file by basename if we have no matches at this point + if (num_matches == 0) + num_matches = target->GetImages().FindModules (module_spec, matching_module_list); + while (num_matches == 0) { ConstString filename_no_extension(module_spec.GetFileSpec().GetFileNameStrippingExtension()); @@ -4288,6 +4334,7 @@ protected: module_spec.GetFileSpec().GetFilename() = filename_no_extension; num_matches = target->GetImages().FindModules (module_spec, matching_module_list); + } if (num_matches > 1) diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index cfa54387b37..140272e0912 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -397,6 +397,26 @@ protected: } }; +static uint32_t +MachHeaderSizeFromMagic(uint32_t magic) +{ + switch (magic) + { + case HeaderMagic32: + case HeaderMagic32Swapped: + return sizeof(struct mach_header); + + case HeaderMagic64: + case HeaderMagic64Swapped: + return sizeof(struct mach_header_64); + break; + + default: + break; + } + return 0; +} + #define MACHO_NLIST_ARM_SYMBOL_IS_THUMB 0x0008 void @@ -493,7 +513,7 @@ ObjectFileMachO::GetModuleSpecifications (const lldb_private::FileSpec& file, if (header.sizeofcmds >= data_sp->GetByteSize()) { data_sp = file.ReadFileContents(file_offset, header.sizeofcmds); - data_offset = 0; + data_offset = MachHeaderSizeFromMagic(header.magic) + file_offset; } if (data_sp) { @@ -550,29 +570,6 @@ ObjectFileMachO::GetSectionNameEHFrame() return g_section_name_eh_frame; } - - -static uint32_t -MachHeaderSizeFromMagic(uint32_t magic) -{ - switch (magic) - { - case HeaderMagic32: - case HeaderMagic32Swapped: - return sizeof(struct mach_header); - - case HeaderMagic64: - case HeaderMagic64Swapped: - return sizeof(struct mach_header_64); - break; - - default: - break; - } - return 0; -} - - bool ObjectFileMachO::MagicBytesMatch (DataBufferSP& data_sp, lldb::addr_t data_offset, |

