summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-08-16 00:32:58 +0000
committerEnrico Granata <egranata@apple.com>2014-08-16 00:32:58 +0000
commitfe7295dcf586a2b4913fec2fd74e03e7ea7c45ec (patch)
tree104ca8f1d42e510d39f80e2cb63a42807dc92728
parentb23bad11e792210b1c8d494941dbd85ca05bd943 (diff)
downloadbcm5719-llvm-fe7295dcf586a2b4913fec2fd74e03e7ea7c45ec.tar.gz
bcm5719-llvm-fe7295dcf586a2b4913fec2fd74e03e7ea7c45ec.zip
In order for the debug script filename to be valid as a module name, LLDB does some textual replacements. However, if one were unaware of this, they might name their script using the 'untampered' file name and they would get no feedback about it. Add logic to LLDB to make sure we tell people about those changes if it turns out they might need to know. Fixes rdar://14310572
llvm-svn: 215798
-rw-r--r--lldb/include/lldb/Target/Platform.h3
-rw-r--r--lldb/source/Core/Module.cpp3
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp33
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h3
-rw-r--r--lldb/source/Target/Platform.cpp2
-rw-r--r--lldb/source/Target/Target.cpp6
6 files changed, 42 insertions, 8 deletions
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 887bf9a2ae6..d9122c38d6f 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -331,7 +331,8 @@ namespace lldb_private {
//----------------------------------------------------------------------
virtual FileSpecList
LocateExecutableScriptingResources (Target *target,
- Module &module);
+ Module &module,
+ Stream* feedback_stream);
virtual Error
GetSharedModule (const ModuleSpec &module_spec,
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index d337a8832b1..e06a458a17f 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1532,7 +1532,8 @@ Module::LoadScriptingResourceInTarget (Target *target, Error& error, Stream* fee
}
FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources (target,
- *this);
+ *this,
+ feedback_stream);
const uint32_t num_specs = file_specs.GetSize();
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 77f6fd9f896..71740c16356 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -56,7 +56,8 @@ PlatformDarwin::~PlatformDarwin()
FileSpecList
PlatformDarwin::LocateExecutableScriptingResources (Target *target,
- Module &module)
+ Module &module,
+ Stream* feedback_stream)
{
FileSpecList file_list;
if (target && target->GetDebugger().GetScriptLanguage() == eScriptLanguagePython)
@@ -84,6 +85,7 @@ PlatformDarwin::LocateExecutableScriptingResources (Target *target,
while (module_spec.GetFilename())
{
std::string module_basename (module_spec.GetFilename().GetCString());
+ std::string original_module_basename (module_basename);
// FIXME: for Python, we cannot allow certain characters in module
// filenames we import. Theoretically, different scripting languages may
@@ -97,10 +99,39 @@ PlatformDarwin::LocateExecutableScriptingResources (Target *target,
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.GetData(), true);
+ FileSpec orig_script_fspec(original_path_string.GetData(), true);
+
+ // 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
+ && orig_script_fspec.Exists())
+ {
+ if (script_fspec.Exists())
+ feedback_stream->Printf("warning: the symbol file '%s' contains a debug script. However, its name"
+ " '%s' contains reserved characters 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(),
+ path_string.GetData());
+ else
+ feedback_stream->Printf("warning: the symbol file '%s' contains a debug script. However, its name"
+ " contains reserved characters 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(),
+ original_path_string.GetData(),
+ path_string.GetData());
+ }
+ }
+
if (script_fspec.Exists())
{
file_list.Append (script_fspec);
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index 21529a8e961..535e38bf76a 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -40,7 +40,8 @@ public:
lldb_private::FileSpecList
LocateExecutableScriptingResources (lldb_private::Target *target,
- lldb_private::Module &module);
+ lldb_private::Module &module,
+ lldb_private::Stream* feedback_stream);
virtual lldb_private::Error
GetSharedModule (const lldb_private::ModuleSpec &module_spec,
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 82185847f3f..f5dd66a3e59 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -92,7 +92,7 @@ Platform::GetFileWithUUID (const FileSpec &platform_file,
}
FileSpecList
-Platform::LocateExecutableScriptingResources (Target *target, Module &module)
+Platform::LocateExecutableScriptingResources (Target *target, Module &module, Stream* feedback_stream)
{
return FileSpecList();
}
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index e3fd790bdaf..d2d0b509855 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1013,10 +1013,10 @@ LoadScriptingResourceForModule (const ModuleSP &module_sp, Target *target)
target->GetDebugger().GetErrorFile()->Printf("unable to load scripting data for module %s - error reported was %s\n",
module_sp->GetFileSpec().GetFileNameStrippingExtension().GetCString(),
error.AsCString());
- if (feedback_stream.GetSize())
- target->GetDebugger().GetErrorFile()->Printf("%s\n",
- feedback_stream.GetData());
}
+ if (feedback_stream.GetSize())
+ target->GetDebugger().GetErrorFile()->Printf("%s\n",
+ feedback_stream.GetData());
}
void
OpenPOWER on IntegriCloud