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 /lldb/source/Commands/CommandObjectTarget.cpp | |
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
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 49 |
1 files changed, 48 insertions, 1 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) |