summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-08-02 08:16:35 +0000
committerPavel Labath <pavel@labath.sk>2019-08-02 08:16:35 +0000
commit23f70e83594f650830764cca446fdfcba7368460 (patch)
tree59d0f7142156dceb4cb4af1d2fe8d9a18fedf8ab /lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
parent9eedbc4f266d1e49d335d48c4c0f717401d927d2 (diff)
downloadbcm5719-llvm-23f70e83594f650830764cca446fdfcba7368460.tar.gz
bcm5719-llvm-23f70e83594f650830764cca446fdfcba7368460.zip
SymbolVendor: Introduce Module::GetSymbolFile
Summary: This is the next step in avoiding funneling all SymbolFile calls through the SymbolVendor. Right now, it is just a convenience function, but it allows us to update all calls to SymbolVendor functions to access the SymbolFile directly. Once all call sites have been updated, we can remove the GetSymbolVendor member function. This patch just updates the calls to GetSymbolVendor, which were calling it just so they could fetch the underlying symbol file. Other calls will be done in follow-ups. Reviewers: JDevlieghere, clayborg, jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D65435 llvm-svn: 367664
Diffstat (limited to 'lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp')
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp196
1 files changed, 95 insertions, 101 deletions
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 266af0935b6..e497424de57 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -72,112 +72,106 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
FileSpec module_spec = module.GetFileSpec();
if (module_spec) {
- SymbolVendor *symbols = module.GetSymbolVendor();
- if (symbols) {
- SymbolFile *symfile = symbols->GetSymbolFile();
- if (symfile) {
- ObjectFile *objfile = symfile->GetObjectFile();
- if (objfile) {
- FileSpec symfile_spec(objfile->GetFileSpec());
- if (symfile_spec &&
- strcasestr (symfile_spec.GetPath().c_str(),
- ".dSYM/Contents/Resources/DWARF") != nullptr &&
- FileSystem::Instance().Exists(symfile_spec)) {
- while (module_spec.GetFilename()) {
- std::string module_basename(
- module_spec.GetFilename().GetCString());
- std::string original_module_basename(module_basename);
-
- bool was_keyword = false;
-
- // FIXME: for Python, we cannot allow certain characters in
- // module
- // filenames we import. Theoretically, different scripting
- // languages may have different sets of forbidden tokens in
- // filenames, and that should be dealt with by each
- // ScriptInterpreter. For now, we just replace dots with
- // underscores, but if we ever support anything other than
- // Python we will need to rework this
- std::replace(module_basename.begin(), module_basename.end(),
- '.', '_');
- std::replace(module_basename.begin(), module_basename.end(),
- ' ', '_');
- std::replace(module_basename.begin(), module_basename.end(),
- '-', '_');
- ScriptInterpreter *script_interpreter =
- target->GetDebugger().GetScriptInterpreter();
- if (script_interpreter &&
- script_interpreter->IsReservedWord(
- module_basename.c_str())) {
- module_basename.insert(module_basename.begin(), '_');
- was_keyword = true;
- }
+ if (SymbolFile *symfile = module.GetSymbolFile()) {
+ ObjectFile *objfile = symfile->GetObjectFile();
+ if (objfile) {
+ FileSpec symfile_spec(objfile->GetFileSpec());
+ if (symfile_spec &&
+ strcasestr(symfile_spec.GetPath().c_str(),
+ ".dSYM/Contents/Resources/DWARF") != nullptr &&
+ FileSystem::Instance().Exists(symfile_spec)) {
+ while (module_spec.GetFilename()) {
+ std::string module_basename(
+ module_spec.GetFilename().GetCString());
+ std::string original_module_basename(module_basename);
+
+ bool was_keyword = false;
+
+ // FIXME: for Python, we cannot allow certain characters in
+ // module
+ // filenames we import. Theoretically, different scripting
+ // languages may have different sets of forbidden tokens in
+ // filenames, and that should be dealt with by each
+ // ScriptInterpreter. For now, we just replace dots with
+ // underscores, but if we ever support anything other than
+ // Python we will need to rework this
+ std::replace(module_basename.begin(), module_basename.end(), '.',
+ '_');
+ std::replace(module_basename.begin(), module_basename.end(), ' ',
+ '_');
+ std::replace(module_basename.begin(), module_basename.end(), '-',
+ '_');
+ ScriptInterpreter *script_interpreter =
+ target->GetDebugger().GetScriptInterpreter();
+ if (script_interpreter &&
+ script_interpreter->IsReservedWord(module_basename.c_str())) {
+ module_basename.insert(module_basename.begin(), '_');
+ was_keyword = true;
+ }
- StreamString path_string;
- StreamString original_path_string;
- // for OSX we are going to be in
- // .dSYM/Contents/Resources/DWARF/<basename> let us go to
- // .dSYM/Contents/Resources/Python/<basename>.py and see if the
- // file exists
- path_string.Printf("%s/../Python/%s.py",
- symfile_spec.GetDirectory().GetCString(),
- module_basename.c_str());
- original_path_string.Printf(
- "%s/../Python/%s.py",
- symfile_spec.GetDirectory().GetCString(),
- original_module_basename.c_str());
- FileSpec script_fspec(path_string.GetString());
- FileSystem::Instance().Resolve(script_fspec);
- FileSpec orig_script_fspec(original_path_string.GetString());
- FileSystem::Instance().Resolve(orig_script_fspec);
-
- // if we did some replacements of reserved characters, and a
- // file with the untampered name exists, then warn the user
- // that the file as-is shall not be loaded
- if (feedback_stream) {
- if (module_basename != original_module_basename &&
- FileSystem::Instance().Exists(orig_script_fspec)) {
- const char *reason_for_complaint =
- was_keyword ? "conflicts with a keyword"
- : "contains reserved characters";
- if (FileSystem::Instance().Exists(script_fspec))
- feedback_stream->Printf(
- "warning: the symbol file '%s' contains a debug "
- "script. However, its name"
- " '%s' %s and as such cannot be loaded. LLDB will"
- " load '%s' instead. Consider removing the file with "
- "the malformed name to"
- " eliminate this warning.\n",
- symfile_spec.GetPath().c_str(),
- original_path_string.GetData(), reason_for_complaint,
- path_string.GetData());
- else
- feedback_stream->Printf(
- "warning: the symbol file '%s' contains a debug "
- "script. However, its name"
- " %s and as such cannot be loaded. If you intend"
- " to have this script loaded, please rename '%s' to "
- "'%s' and retry.\n",
- symfile_spec.GetPath().c_str(), reason_for_complaint,
- original_path_string.GetData(),
- path_string.GetData());
- }
+ StreamString path_string;
+ StreamString original_path_string;
+ // for OSX we are going to be in
+ // .dSYM/Contents/Resources/DWARF/<basename> let us go to
+ // .dSYM/Contents/Resources/Python/<basename>.py and see if the
+ // file exists
+ path_string.Printf("%s/../Python/%s.py",
+ symfile_spec.GetDirectory().GetCString(),
+ module_basename.c_str());
+ original_path_string.Printf(
+ "%s/../Python/%s.py",
+ symfile_spec.GetDirectory().GetCString(),
+ original_module_basename.c_str());
+ FileSpec script_fspec(path_string.GetString());
+ FileSystem::Instance().Resolve(script_fspec);
+ FileSpec orig_script_fspec(original_path_string.GetString());
+ FileSystem::Instance().Resolve(orig_script_fspec);
+
+ // if we did some replacements of reserved characters, and a
+ // file with the untampered name exists, then warn the user
+ // that the file as-is shall not be loaded
+ if (feedback_stream) {
+ if (module_basename != original_module_basename &&
+ FileSystem::Instance().Exists(orig_script_fspec)) {
+ const char *reason_for_complaint =
+ was_keyword ? "conflicts with a keyword"
+ : "contains reserved characters";
+ if (FileSystem::Instance().Exists(script_fspec))
+ feedback_stream->Printf(
+ "warning: the symbol file '%s' contains a debug "
+ "script. However, its name"
+ " '%s' %s and as such cannot be loaded. LLDB will"
+ " load '%s' instead. Consider removing the file with "
+ "the malformed name to"
+ " eliminate this warning.\n",
+ symfile_spec.GetPath().c_str(),
+ original_path_string.GetData(), reason_for_complaint,
+ path_string.GetData());
+ else
+ feedback_stream->Printf(
+ "warning: the symbol file '%s' contains a debug "
+ "script. However, its name"
+ " %s and as such cannot be loaded. If you intend"
+ " to have this script loaded, please rename '%s' to "
+ "'%s' and retry.\n",
+ symfile_spec.GetPath().c_str(), reason_for_complaint,
+ original_path_string.GetData(), path_string.GetData());
}
+ }
- if (FileSystem::Instance().Exists(script_fspec)) {
- file_list.Append(script_fspec);
- break;
- }
+ if (FileSystem::Instance().Exists(script_fspec)) {
+ file_list.Append(script_fspec);
+ break;
+ }
- // If we didn't find the python file, then keep stripping the
- // extensions and try again
- ConstString filename_no_extension(
- module_spec.GetFileNameStrippingExtension());
- if (module_spec.GetFilename() == filename_no_extension)
- break;
+ // If we didn't find the python file, then keep stripping the
+ // extensions and try again
+ ConstString filename_no_extension(
+ module_spec.GetFileNameStrippingExtension());
+ if (module_spec.GetFilename() == filename_no_extension)
+ break;
- module_spec.GetFilename() = filename_no_extension;
- }
+ module_spec.GetFilename() = filename_no_extension;
}
}
}
OpenPOWER on IntegriCloud