[Lldb-commits] [lldb] r159298 - in /lldb/trunk: include/lldb/API/SBSection.h include/lldb/API/SBTarget.h include/lldb/Target/PathMappingList.h lldb.xcodeproj/project.pbxproj scripts/Python/interface/SBSection.i source/API/SBSection.cpp source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
Greg Clayton
gclayton at apple.com
Wed Jun 27 15:22:29 PDT 2012
Author: gclayton
Date: Wed Jun 27 17:22:28 2012
New Revision: 159298
URL: http://llvm.org/viewvc/llvm-project?rev=159298&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/API/SBSection.h
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/include/lldb/Target/PathMappingList.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/scripts/Python/interface/SBSection.i
lldb/trunk/source/API/SBSection.cpp
lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
Modified: lldb/trunk/include/lldb/API/SBSection.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSection.h?rev=159298&r1=159297&r2=159298&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSection.h (original)
+++ lldb/trunk/include/lldb/API/SBSection.h Wed Jun 27 17:22:28 2012
@@ -47,6 +47,9 @@
GetFileAddress ();
lldb::addr_t
+ GetLoadAddress (lldb::SBTarget &target);
+
+ lldb::addr_t
GetByteSize ();
uint64_t
Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=159298&r1=159297&r2=159298&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Wed Jun 27 17:22:28 2012
@@ -741,6 +741,7 @@
friend class SBInstruction;
friend class SBModule;
friend class SBProcess;
+ friend class SBSection;
friend class SBSourceManager;
friend class SBSymbol;
friend class SBValue;
Modified: lldb/trunk/include/lldb/Target/PathMappingList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/PathMappingList.h?rev=159298&r1=159297&r2=159298&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/PathMappingList.h (original)
+++ lldb/trunk/include/lldb/Target/PathMappingList.h Wed Jun 27 17:22:28 2012
@@ -57,6 +57,12 @@
void
Dump (Stream *s, int pair_index=-1);
+ bool
+ IsEmpty() const
+ {
+ return m_pairs.empty();
+ }
+
size_t
GetSize () const
{
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=159298&r1=159297&r2=159298&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Jun 27 17:22:28 2012
@@ -401,6 +401,7 @@
26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; };
26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; };
26D265BC136B4269002EEE45 /* lldb-public.h in Headers */ = {isa = PBXBuildFile; fileRef = 26651A14133BEC76005B64B7 /* lldb-public.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 26D55235159A7DB100708D8D /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26D55234159A7DB100708D8D /* libxml2.dylib */; };
26D5E15F135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */; };
26D5E163135BB054006EA0A7 /* OptionGroupPlatform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E162135BB054006EA0A7 /* OptionGroupPlatform.cpp */; };
26D7E45D13D5E30A007FD12B /* SocketAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D7E45C13D5E30A007FD12B /* SocketAddress.cpp */; };
@@ -1207,6 +1208,7 @@
26D0DD5510FE555900271C65 /* BreakpointResolverName.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BreakpointResolverName.cpp; path = source/Breakpoint/BreakpointResolverName.cpp; sourceTree = "<group>"; };
26D27C9D11ED3A4E0024D721 /* ELFHeader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ELFHeader.cpp; sourceTree = "<group>"; };
26D27C9E11ED3A4E0024D721 /* ELFHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ELFHeader.h; sourceTree = "<group>"; };
+ 26D55234159A7DB100708D8D /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = ../../../../../../usr/lib/libxml2.dylib; sourceTree = "<group>"; };
26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupArchitecture.cpp; path = source/Interpreter/OptionGroupArchitecture.cpp; sourceTree = "<group>"; };
26D5E160135BAEB0006EA0A7 /* OptionGroupArchitecture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupArchitecture.h; path = include/lldb/Interpreter/OptionGroupArchitecture.h; sourceTree = "<group>"; };
26D5E161135BB040006EA0A7 /* OptionGroupPlatform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupPlatform.h; path = include/lldb/Interpreter/OptionGroupPlatform.h; sourceTree = "<group>"; };
@@ -1564,6 +1566,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 26D55235159A7DB100708D8D /* libxml2.dylib in Frameworks */,
268901161335BBC300698AC0 /* liblldb-core.a in Frameworks */,
2668022F115FD19D008E1FE4 /* CoreFoundation.framework in Frameworks */,
26680233115FD1A7008E1FE4 /* libobjc.dylib in Frameworks */,
@@ -1620,6 +1623,7 @@
08FB7794FE84155DC02AAC07 /* lldb */ = {
isa = PBXGroup;
children = (
+ 26D55234159A7DB100708D8D /* libxml2.dylib */,
AFF87C8E150FF688000E1742 /* com.apple.debugserver.applist.plist */,
AFF87C8C150FF680000E1742 /* com.apple.debugserver.applist.plist */,
AFF87C8A150FF677000E1742 /* com.apple.debugserver.applist.plist */,
@@ -4367,6 +4371,7 @@
);
GCC_ENABLE_OBJC_GC = supported;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
+ HEADER_SEARCH_PATHS = /usr/include/libxml2;
LD_DYLIB_INSTALL_NAME = "$(DEVELOPER_DIR)/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a";
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 10.6;
@@ -4396,6 +4401,7 @@
);
GCC_ENABLE_OBJC_GC = supported;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
+ HEADER_SEARCH_PATHS = /usr/include/libxml2;
LD_DYLIB_INSTALL_NAME = "$(DEVELOPER_DIR)/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a";
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 10.6;
@@ -4425,6 +4431,7 @@
);
GCC_ENABLE_OBJC_GC = supported;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
+ HEADER_SEARCH_PATHS = /usr/include/libxml2;
LD_DYLIB_INSTALL_NAME = "$(DEVELOPER_DIR)/Library/PrivateFrameworks/LLDB.framework/Resources/lldb-core.a";
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 10.6;
Modified: lldb/trunk/scripts/Python/interface/SBSection.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSection.i?rev=159298&r1=159297&r2=159298&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBSection.i (original)
+++ lldb/trunk/scripts/Python/interface/SBSection.i Wed Jun 27 17:22:28 2012
@@ -66,6 +66,9 @@
GetFileAddress ();
lldb::addr_t
+ GetLoadAddress (lldb::SBTarget &target);
+
+ lldb::addr_t
GetByteSize ();
uint64_t
Modified: lldb/trunk/source/API/SBSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSection.cpp?rev=159298&r1=159297&r2=159298&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSection.cpp (original)
+++ lldb/trunk/source/API/SBSection.cpp Wed Jun 27 17:22:28 2012
@@ -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 @@
}
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());
Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=159298&r1=159297&r2=159298&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Wed Jun 27 17:22:28 2012
@@ -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 @@
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;
More information about the lldb-commits
mailing list