diff options
| author | Greg Clayton <gclayton@apple.com> | 2012-06-27 22:22:28 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2012-06-27 22:22:28 +0000 |
| commit | fed39aa653441238382bedfb1ad2bfcd09a1962f (patch) | |
| tree | f257d43c7e526e9214f40ebd8e45355474db915e /lldb/source | |
| parent | 0b9d158a7c8966ecac59c79a6d506ad7c28299ca (diff) | |
| download | bcm5719-llvm-fed39aa653441238382bedfb1ad2bfcd09a1962f.tar.gz bcm5719-llvm-fed39aa653441238382bedfb1ad2bfcd09a1962f.zip | |
Added the ability to read the dSYM plist file with source remappings even when DebugSymbols isn't used to find the dSYM. We now parse the plist as XML in the MacOSX symbol vendor.
Added the ability to get a section load address given a target which is needed for a previous checking which saves crashlogs.
llvm-svn: 159298
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/API/SBSection.cpp | 17 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp | 98 |
2 files changed, 115 insertions, 0 deletions
diff --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp index 24b94a7a53a..06a08d865f4 100644 --- a/lldb/source/API/SBSection.cpp +++ b/lldb/source/API/SBSection.cpp @@ -9,6 +9,7 @@ #include "lldb/API/SBSection.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBTarget.h" #include "lldb/Core/DataBuffer.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Log.h" @@ -126,6 +127,22 @@ SBSection::GetFileAddress () } lldb::addr_t +SBSection::GetLoadAddress (lldb::SBTarget &sb_target) +{ + TargetSP target_sp(sb_target.GetSP()); + if (target_sp) + { + SectionSP section_sp (GetSP()); + if (section_sp) + return section_sp->GetLoadBaseAddress(target_sp.get()); + } + return LLDB_INVALID_ADDRESS; + +} + + + +lldb::addr_t SBSection::GetByteSize () { SectionSP section_sp (GetSP()); diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp index 0b42bfbbebb..1d057f0cbf4 100644 --- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp +++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp @@ -9,6 +9,10 @@ #include "SymbolVendorMacOSX.h" +#include <libxml/parser.h> +#include <libxml/tree.h> +#include <string.h> + #include <AvailabilityMacros.h> #include "lldb/Core/Module.h" @@ -172,6 +176,100 @@ SymbolVendorMacOSX::CreateInstance (const lldb::ModuleSP &module_sp) dsym_objfile_sp = ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(), dsym_file_data_sp); if (UUIDsMatch(module_sp.get(), dsym_objfile_sp.get())) { + char dsym_path[PATH_MAX]; + if (module_sp->GetSourceMappingList().IsEmpty() && dsym_fspec.GetPath(dsym_path, sizeof(dsym_path))) + { + lldb_private::UUID dsym_uuid; + if (dsym_objfile_sp->GetUUID(&dsym_uuid)) + { + char uuid_cstr_buf[64]; + const char *uuid_cstr = dsym_uuid.GetAsCString (uuid_cstr_buf, sizeof(uuid_cstr_buf)); + if (uuid_cstr) + { + char *resources = strstr (dsym_path, "/Contents/Resources/"); + if (resources) + { + char dsym_uuid_plist_path[PATH_MAX]; + resources[strlen("/Contents/Resources/")] = '\0'; + snprintf(dsym_uuid_plist_path, sizeof(dsym_uuid_plist_path), "%s%s.plist", dsym_path, uuid_cstr); + FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path, false); + if (dsym_uuid_plist_spec.Exists()) + { + xmlDoc *doc = ::xmlReadFile (dsym_uuid_plist_path, NULL, 0); + if (doc) + { + char DBGBuildSourcePath[PATH_MAX]; + char DBGSourcePath[PATH_MAX]; + DBGBuildSourcePath[0] = '\0'; + DBGSourcePath[0] = '\0'; + for (xmlNode *node = doc->children; node; node = node ? node->next : NULL) + { + if (node->type == XML_ELEMENT_NODE) + { + if (node->name && strcmp((const char*)node->name, "plist") == 0) + { + xmlNode *dict_node = node->children; + while (dict_node && dict_node->type != XML_ELEMENT_NODE) + dict_node = dict_node->next; + if (dict_node && dict_node->name && strcmp((const char *)dict_node->name, "dict") == 0) + { + for (xmlNode *key_node = dict_node->children; key_node; key_node = key_node->next) + { + if (key_node && key_node->type == XML_ELEMENT_NODE && key_node->name) + { + if (strcmp((const char *)key_node->name, "key") == 0) + { + const char *key_name = (const char *)::xmlNodeGetContent(key_node); + if (strcmp(key_name, "DBGBuildSourcePath") == 0) + { + xmlNode *value_node = key_node->next; + while (value_node && value_node->type != XML_ELEMENT_NODE) + value_node = value_node->next; + if (strcmp((const char *)value_node->name, "string") == 0) + { + const char *node_content = (const char *)::xmlNodeGetContent(value_node); + if (node_content) + { + strncpy(DBGBuildSourcePath, node_content, sizeof(DBGBuildSourcePath)); + } + } + key_node = value_node; + } + else if (strcmp(key_name, "DBGSourcePath") == 0) + { + xmlNode *value_node = key_node->next; + while (value_node && value_node->type != XML_ELEMENT_NODE) + value_node = value_node->next; + if (strcmp((const char *)value_node->name, "string") == 0) + { + const char *node_content = (const char *)::xmlNodeGetContent(value_node); + if (node_content) + { + strncpy(DBGSourcePath, node_content, sizeof(DBGSourcePath)); + } + } + key_node = value_node; + } + } + } + } + } + } + } + } + ::xmlFreeDoc (doc); + + if (DBGBuildSourcePath[0] && DBGSourcePath[0]) + { + module_sp->GetSourceMappingList().Append (ConstString(DBGBuildSourcePath), ConstString(DBGSourcePath), true); + } + } + } + } + } + } + } + ReplaceDSYMSectionsWithExecutableSections (obj_file, dsym_objfile_sp.get()); symbol_vendor->AddSymbolFileRepresentation(dsym_objfile_sp); return symbol_vendor; |

