summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/SymbolVendor
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-05-26 18:00:51 +0000
committerGreg Clayton <gclayton@apple.com>2015-05-26 18:00:51 +0000
commit59ef9341a629144d4e3ae211ee6df7d914f305a3 (patch)
tree28b17d3caed19e53f2969200fea92d5c988b0914 /lldb/source/Plugins/SymbolVendor
parentc07e581b8128d30d6493dc6a925b0d966c3fecb2 (diff)
Added XML to the host layer.
We know have on API we should use for all XML within LLDB in XML.h. This API will be easy back the XML parsing by different libraries in case libxml2 doesn't work on all platforms. It also allows the only place for #ifdef ...XML... to be in XML.h and XML.cpp. The API is designed so it will still compile with or without XML support and there is a static function "bool XMLDocument::XMLEnabled()" that can be called to see if XML is currently supported. All APIs will return errors, false, or nothing when XML isn't enabled. Converted all locations that used XML over to using the host XML implementation. Added target.xml support to debugserver. Extended the XML register format to work for LLDB by including extra attributes and elements where needed. This allows the target.xml to replace the qRegisterInfo packets and allows us to fetch all register info in a single packet. <rdar://problem/21090173>
Diffstat (limited to 'lldb/source/Plugins/SymbolVendor')
-rw-r--r--lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp119
1 files changed, 25 insertions, 94 deletions
diff --git a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index 1e99dcf4599..15e31c1774e 100644
--- a/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -9,11 +9,6 @@
#include "SymbolVendorMacOSX.h"
-#if defined( LIBXML2_DEFINED )
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#endif // #if defined( LIBXML2_DEFINED )
-
#include <string.h>
#include "lldb/Core/Module.h"
@@ -24,6 +19,7 @@
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
+#include "lldb/Host/XML.h"
#include "lldb/Symbol/ObjectFile.h"
using namespace lldb;
@@ -177,111 +173,46 @@ SymbolVendorMacOSX::CreateInstance (const lldb::ModuleSP &module_sp, lldb_privat
dsym_objfile_sp = ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(), dsym_file_data_sp, dsym_file_data_offset);
if (UUIDsMatch(module_sp.get(), dsym_objfile_sp.get(), feedback_strm))
{
-#if defined( LIBXML2_DEFINED )
- char dsym_path[PATH_MAX];
- if (module_sp->GetSourceMappingList().IsEmpty() && dsym_fspec.GetPath(dsym_path, sizeof(dsym_path)))
+ // We need a XML parser if we hope to parse a plist...
+ if (XMLDocument::XMLEnabled())
{
- lldb_private::UUID dsym_uuid;
- if (dsym_objfile_sp->GetUUID(&dsym_uuid))
+ char dsym_path[PATH_MAX];
+ if (module_sp->GetSourceMappingList().IsEmpty() && dsym_fspec.GetPath(dsym_path, sizeof(dsym_path)))
{
- std::string uuid_str = dsym_uuid.GetAsString ();
- if (!uuid_str.empty())
+ lldb_private::UUID dsym_uuid;
+ if (dsym_objfile_sp->GetUUID(&dsym_uuid))
{
- char *resources = strstr (dsym_path, "/Contents/Resources/");
- if (resources)
+ std::string uuid_str = dsym_uuid.GetAsString ();
+ if (!uuid_str.empty())
{
- 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_str.c_str());
- FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path, false);
- if (dsym_uuid_plist_spec.Exists())
+ char *resources = strstr (dsym_path, "/Contents/Resources/");
+ if (resources)
{
- xmlDoc *doc = ::xmlReadFile (dsym_uuid_plist_path, NULL, 0);
- if (doc)
+ 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_str.c_str());
+ FileSpec dsym_uuid_plist_spec(dsym_uuid_plist_path, false);
+ if (dsym_uuid_plist_spec.Exists())
{
- 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)
+ ApplePropertyList plist(dsym_uuid_plist_path);
+ if (plist)
{
- if (node->type == XML_ELEMENT_NODE)
+ std::string DBGBuildSourcePath;
+ std::string DBGSourcePath;
+
+ plist.GetValueAsString("DBGBuildSourcePath", DBGBuildSourcePath);
+ plist.GetValueAsString("DBGSourcePath", DBGSourcePath);
+ if (DBGBuildSourcePath[0] && DBGSourcePath[0])
{
- 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 (value_node && value_node->name)
- {
- if (strcmp((const char *)value_node->name, "string") == 0)
- {
- const char *node_content = (const char *)::xmlNodeGetContent(value_node);
- if (node_content)
- {
- ::snprintf(DBGBuildSourcePath, sizeof(DBGBuildSourcePath), "%s", node_content);
- xmlFree((void *) node_content);
- }
- }
- 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 (value_node && value_node->name)
- {
- if (strcmp((const char *)value_node->name, "string") == 0)
- {
- const char *node_content = (const char *)::xmlNodeGetContent(value_node);
- if (node_content)
- {
- FileSpec resolved_source_path(node_content, true);
- resolved_source_path.GetPath(DBGSourcePath, sizeof(DBGSourcePath));
- xmlFree ((void *) node_content);
- }
- }
- key_node = value_node;
- }
- }
- if (key_name != NULL)
- xmlFree((void *) key_name);
- }
- }
- }
- }
- }
+ module_sp->GetSourceMappingList().Append (ConstString(DBGBuildSourcePath), ConstString(DBGSourcePath), true);
}
}
- ::xmlFreeDoc (doc);
-
- if (DBGBuildSourcePath[0] && DBGSourcePath[0])
- {
- module_sp->GetSourceMappingList().Append (ConstString(DBGBuildSourcePath), ConstString(DBGSourcePath), true);
- }
}
}
}
}
}
}
-#endif // #if defined( LIBXML2_DEFINED )
symbol_vendor->AddSymbolFileRepresentation(dsym_objfile_sp);
return symbol_vendor;