summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Host/common/FileSpec.cpp29
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp128
2 files changed, 81 insertions, 76 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp
index 5edec81a7d9..4764169a618 100644
--- a/lldb/source/Host/common/FileSpec.cpp
+++ b/lldb/source/Host/common/FileSpec.cpp
@@ -702,6 +702,33 @@ FileSpec::GetPath(char *path, size_t path_max_len) const
return 0;
}
+void
+FileSpec::GetPath (std::string &path) const
+{
+ const char *dirname = m_directory.GetCString();
+ const char *filename = m_filename.GetCString();
+ path.clear();
+ if (dirname)
+ {
+ path.append (dirname);
+ if (filename)
+ path.append ("/");
+ }
+ if (filename)
+ {
+ path.append (filename);
+ }
+}
+
+
+std::string&
+FileSpec::GetPath (void) const
+{
+ std::string path;
+ GetPath (path);
+ return path;
+}
+
ConstString
FileSpec::GetFileNameExtension () const
{
@@ -1032,5 +1059,3 @@ FileSpec::IsRelativeToCurrentWorkingDirectory () const
}
return false;
}
-
-
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index 3ccf78e7831..5cab1335ab5 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -290,11 +290,7 @@ PlatformDarwinKernel::GetStatus (Stream &strm)
for (uint32_t i=0; i<num_kext_dirs; ++i)
{
const FileSpec &kext_dir = m_directories_searched[i];
- char pathbuf[PATH_MAX];
- if (kext_dir.GetPath (pathbuf, sizeof (pathbuf)))
- {
- strm.Printf (" Kext directories: [%2u] \"%s\"\n", i, pathbuf);
- }
+ strm.Printf (" Kext directories: [%2u] \"%s\"\n", i, kext_dir.GetPath().c_str());
}
strm.Printf (" Total number of kexts indexed: %d\n", (int) m_name_to_kext_path_map.size());
}
@@ -347,7 +343,7 @@ PlatformDarwinKernel::GetiOSSDKDirectoriesToSearch (std::vector<lldb_private::Fi
char pathbuf[PATH_MAX];
::snprintf (pathbuf, sizeof (pathbuf), "%s/Platforms/iPhoneOS.platform/Developer/SDKs", developer_dir);
FileSpec ios_sdk(pathbuf, true);
- if (ios_sdk.Exists() && ios_sdk.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (ios_sdk.Exists() && ios_sdk.IsDirectory())
{
directories.push_back (ios_sdk);
}
@@ -364,7 +360,7 @@ PlatformDarwinKernel::GetMacSDKDirectoriesToSearch (std::vector<lldb_private::Fi
char pathbuf[PATH_MAX];
::snprintf (pathbuf, sizeof (pathbuf), "%s/Platforms/MacOSX.platform/Developer/SDKs", developer_dir);
FileSpec mac_sdk(pathbuf, true);
- if (mac_sdk.Exists() && mac_sdk.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (mac_sdk.Exists() && mac_sdk.IsDirectory())
{
directories.push_back (mac_sdk);
}
@@ -374,7 +370,7 @@ void
PlatformDarwinKernel::GetGenericSDKDirectoriesToSearch (std::vector<lldb_private::FileSpec> &directories)
{
FileSpec generic_sdk("/AppleInternal/Developer/KDKs", true);
- if (generic_sdk.Exists() && generic_sdk.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (generic_sdk.Exists() && generic_sdk.IsDirectory())
{
directories.push_back (generic_sdk);
}
@@ -389,19 +385,19 @@ void
PlatformDarwinKernel::GetMacDirectoriesToSearch (std::vector<lldb_private::FileSpec> &directories)
{
FileSpec sle("/System/Library/Extensions", true);
- if (sle.Exists() && sle.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (sle.Exists() && sle.IsDirectory())
{
directories.push_back(sle);
}
FileSpec le("/Library/Extensions", true);
- if (le.Exists() && le.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (le.Exists() && le.IsDirectory())
{
directories.push_back(le);
}
FileSpec kdk("/Volumes/KernelDebugKit", true);
- if (kdk.Exists() && kdk.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (kdk.Exists() && kdk.IsDirectory())
{
directories.push_back(kdk);
}
@@ -418,7 +414,7 @@ PlatformDarwinKernel::GetGenericDirectoriesToSearch (std::vector<lldb_private::F
char pathbuf[PATH_MAX];
::snprintf (pathbuf, sizeof (pathbuf), "%s/../Symbols", developer_dir);
FileSpec symbols_dir (pathbuf, true);
- if (symbols_dir.Exists() && symbols_dir.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (symbols_dir.Exists() && symbols_dir.IsDirectory())
{
directories.push_back (symbols_dir);
}
@@ -435,22 +431,18 @@ PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch (std::vector<lldb_priv
{
FileSpec dir = user_dirs.GetFileSpecAtIndex (i);
dir.ResolvePath();
- if (dir.Exists() && dir.GetFileType() == FileSpec::eFileTypeDirectory)
+ if (dir.Exists() && dir.IsDirectory())
{
directories.push_back (dir);
possible_sdk_dirs.push_back (dir); // does this directory have a *.sdk or *.kdk that we should look in?
- char dir_pathbuf[PATH_MAX];
- if (dir.GetPath (dir_pathbuf, sizeof (dir_pathbuf)))
+ // Is there a "System/Library/Extensions" subdir of this directory?
+ std::string dir_sle_path = dir.GetPath();
+ dir_sle_path.append ("/System/Library/Extensions");
+ FileSpec dir_sle(dir_sle_path.c_str(), true);
+ if (dir_sle.Exists() && dir_sle.IsDirectory())
{
- // Is there a "System/Library/Extensions" subdir of this directory?
- char pathbuf[PATH_MAX];
- ::snprintf (pathbuf, sizeof (pathbuf), "%s/System/Library/Extensions", dir_pathbuf);
- FileSpec dir_sle(pathbuf, true);
- if (dir_sle.Exists() && dir_sle.GetFileType() == FileSpec::eFileTypeDirectory)
- {
- directories.push_back (dir_sle);
- }
+ directories.push_back (dir_sle);
}
}
}
@@ -467,13 +459,13 @@ PlatformDarwinKernel::SearchSDKsForKextDirectories (std::vector<lldb_private::Fi
for (uint32_t i = 0; i < num_sdks; i++)
{
const FileSpec &sdk_dir = sdk_dirs[i];
- char pathbuf[PATH_MAX];
- if (sdk_dir.GetPath (pathbuf, sizeof (pathbuf)))
+ std::string sdk_dir_path = sdk_dir.GetPath();
+ if (!sdk_dir_path.empty())
{
const bool find_directories = true;
const bool find_files = false;
const bool find_other = false;
- FileSpec::EnumerateDirectory (pathbuf,
+ FileSpec::EnumerateDirectory (sdk_dir_path.c_str(),
find_directories,
find_files,
find_other,
@@ -498,16 +490,12 @@ PlatformDarwinKernel::GetKextDirectoriesInSDK (void *baton,
&& (file_spec.GetFileNameExtension() == ConstString("sdk")
|| file_spec.GetFileNameExtension() == ConstString("kdk")))
{
- char pathbuf[PATH_MAX];
- if (file_spec.GetPath (pathbuf, PATH_MAX))
+ std::string kext_directory_path = file_spec.GetPath();
+ kext_directory_path.append ("/System/Library/Extensions");
+ FileSpec kext_directory (kext_directory_path.c_str(), true);
+ if (kext_directory.Exists() && kext_directory.IsDirectory())
{
- char kext_directory_str[PATH_MAX];
- ::snprintf (kext_directory_str, sizeof (kext_directory_str), "%s/%s", pathbuf, "System/Library/Extensions");
- FileSpec kext_directory (kext_directory_str, true);
- if (kext_directory.Exists() && kext_directory.GetFileType() == FileSpec::eFileTypeDirectory)
- {
- ((std::vector<lldb_private::FileSpec> *)baton)->push_back(kext_directory);
- }
+ ((std::vector<lldb_private::FileSpec> *)baton)->push_back(kext_directory);
}
}
return FileSpec::eEnumerateDirectoryResultNext;
@@ -522,38 +510,30 @@ PlatformDarwinKernel::IndexKextsInDirectories (std::vector<lldb_private::FileSpe
for (uint32_t i = 0; i < num_dirs; i++)
{
const FileSpec &dir = kext_dirs[i];
- char pathbuf[PATH_MAX];
- if (dir.GetPath (pathbuf, sizeof(pathbuf)))
- {
- const bool find_directories = true;
- const bool find_files = false;
- const bool find_other = false;
- FileSpec::EnumerateDirectory (pathbuf,
- find_directories,
- find_files,
- find_other,
- GetKextsInDirectory,
- &kext_bundles);
- }
+ const bool find_directories = true;
+ const bool find_files = false;
+ const bool find_other = false;
+ FileSpec::EnumerateDirectory (dir.GetPath().c_str(),
+ find_directories,
+ find_files,
+ find_other,
+ GetKextsInDirectory,
+ &kext_bundles);
}
const uint32_t num_kexts = kext_bundles.size();
for (uint32_t i = 0; i < num_kexts; i++)
{
const FileSpec &kext = kext_bundles[i];
- char pathbuf[PATH_MAX];
- if (kext.GetPath (pathbuf, sizeof (pathbuf)))
+ CFCBundle bundle (kext.GetPath().c_str());
+ CFStringRef bundle_id (bundle.GetIdentifier());
+ if (bundle_id && CFGetTypeID (bundle_id) == CFStringGetTypeID ())
{
- CFCBundle bundle (pathbuf);
- CFStringRef bundle_id (bundle.GetIdentifier());
- if (bundle_id && CFGetTypeID (bundle_id) == CFStringGetTypeID ())
+ char bundle_id_buf[PATH_MAX];
+ if (CFStringGetCString (bundle_id, bundle_id_buf, sizeof (bundle_id_buf), kCFStringEncodingUTF8))
{
- char bundle_id_buf[PATH_MAX];
- if (CFStringGetCString (bundle_id, bundle_id_buf, sizeof (bundle_id_buf), kCFStringEncodingUTF8))
- {
- ConstString bundle_conststr(bundle_id_buf);
- m_name_to_kext_path_map.insert(std::pair<ConstString, FileSpec>(bundle_conststr, kext));
- }
+ ConstString bundle_conststr(bundle_id_buf);
+ m_name_to_kext_path_map.insert(std::pair<ConstString, FileSpec>(bundle_conststr, kext));
}
}
}
@@ -572,30 +552,30 @@ PlatformDarwinKernel::GetKextsInDirectory (void *baton,
if (file_type == FileSpec::eFileTypeDirectory && file_spec.GetFileNameExtension() == ConstString("kext"))
{
((std::vector<lldb_private::FileSpec> *)baton)->push_back(file_spec);
- bool search_inside = false;
- char pathbuf[PATH_MAX];
- ::snprintf (pathbuf, sizeof (pathbuf), "%s/%s/Contents/PlugIns", file_spec.GetDirectory().GetCString(), file_spec.GetFilename().GetCString());
- FileSpec contents_plugins (pathbuf, false);
- if (contents_plugins.Exists() && contents_plugins.GetFileType() == FileSpec::eFileTypeDirectory)
+ std::string kext_bundle_path = file_spec.GetPath();
+ std::string search_here_too;
+ std::string contents_plugins_path = kext_bundle_path + "/Contents/PlugIns";
+ FileSpec contents_plugins (contents_plugins_path.c_str(), false);
+ if (contents_plugins.Exists() && contents_plugins.IsDirectory())
{
- search_inside = true;
+ search_here_too = contents_plugins_path;
}
else
{
- ::snprintf (pathbuf, sizeof (pathbuf), "%s/%s/PlugIns", file_spec.GetDirectory().GetCString(), file_spec.GetFilename().GetCString());
- FileSpec plugins (pathbuf, false);
- if (plugins.Exists() && plugins.GetFileType() == FileSpec::eFileTypeDirectory)
+ std::string plugins_path = kext_bundle_path + "/PlugIns";
+ FileSpec plugins (plugins_path.c_str(), false);
+ if (plugins.Exists() && plugins.IsDirectory())
{
- search_inside = true;
+ search_here_too = plugins_path;
}
}
- if (search_inside)
+ if (!search_here_too.empty())
{
const bool find_directories = true;
const bool find_files = false;
const bool find_other = false;
- FileSpec::EnumerateDirectory (pathbuf,
+ FileSpec::EnumerateDirectory (search_here_too.c_str(),
find_directories,
find_files,
find_other,
@@ -616,10 +596,10 @@ PlatformDarwinKernel::GetSharedModule (const ModuleSpec &module_spec,
Error error;
module_sp.reset();
const FileSpec &platform_file = module_spec.GetFileSpec();
- char kext_bundle_id[PATH_MAX];
- if (platform_file.GetPath (kext_bundle_id, sizeof (kext_bundle_id)))
+ std::string kext_bundle_id = platform_file.GetPath();
+ if (!kext_bundle_id.empty())
{
- ConstString kext_bundle_cs(kext_bundle_id);
+ ConstString kext_bundle_cs(kext_bundle_id.c_str());
if (m_name_to_kext_path_map.count(kext_bundle_cs) > 0)
{
for (BundleIDToKextIterator it = m_name_to_kext_path_map.begin (); it != m_name_to_kext_path_map.end (); ++it)
OpenPOWER on IntegriCloud