forked from OSchip/llvm-project
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
This commit is contained in:
parent
b23bad11e7
commit
fe7295dcf5
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue