Changeset View
Changeset View
Standalone View
Standalone View
source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | if (target && | ||||
// should not lose ".file" but GetFileNameStrippingExtension() will do | // should not lose ".file" but GetFileNameStrippingExtension() will do | ||||
// precisely that. Ideally, we should have a per-platform list of | // precisely that. Ideally, we should have a per-platform list of | ||||
// extensions (".exe", ".app", ".dSYM", ".framework") which should be | // extensions (".exe", ".app", ".dSYM", ".framework") which should be | ||||
// stripped while leaving "this.binary.file" as-is. | // stripped while leaving "this.binary.file" as-is. | ||||
FileSpec module_spec = module.GetFileSpec(); | FileSpec module_spec = module.GetFileSpec(); | ||||
if (module_spec) { | if (module_spec) { | ||||
SymbolVendor *symbols = module.GetSymbolVendor(); | if (SymbolFile *symfile = module.GetSymbolFile()) { | ||||
if (symbols) { | |||||
SymbolFile *symfile = symbols->GetSymbolFile(); | |||||
if (symfile) { | |||||
ObjectFile *objfile = symfile->GetObjectFile(); | ObjectFile *objfile = symfile->GetObjectFile(); | ||||
if (objfile) { | if (objfile) { | ||||
FileSpec symfile_spec(objfile->GetFileSpec()); | FileSpec symfile_spec(objfile->GetFileSpec()); | ||||
if (symfile_spec && | if (symfile_spec && | ||||
strcasestr (symfile_spec.GetPath().c_str(), | strcasestr(symfile_spec.GetPath().c_str(), | ||||
".dSYM/Contents/Resources/DWARF") != nullptr && | ".dSYM/Contents/Resources/DWARF") != nullptr && | ||||
FileSystem::Instance().Exists(symfile_spec)) { | FileSystem::Instance().Exists(symfile_spec)) { | ||||
while (module_spec.GetFilename()) { | while (module_spec.GetFilename()) { | ||||
std::string module_basename( | std::string module_basename( | ||||
module_spec.GetFilename().GetCString()); | module_spec.GetFilename().GetCString()); | ||||
std::string original_module_basename(module_basename); | std::string original_module_basename(module_basename); | ||||
bool was_keyword = false; | bool was_keyword = false; | ||||
// FIXME: for Python, we cannot allow certain characters in | // FIXME: for Python, we cannot allow certain characters in | ||||
// module | // module | ||||
// filenames we import. Theoretically, different scripting | // filenames we import. Theoretically, different scripting | ||||
// languages may have different sets of forbidden tokens in | // languages may have different sets of forbidden tokens in | ||||
// filenames, and that should be dealt with by each | // filenames, and that should be dealt with by each | ||||
// ScriptInterpreter. For now, we just replace dots with | // ScriptInterpreter. For now, we just replace dots with | ||||
// underscores, but if we ever support anything other than | // underscores, but if we ever support anything other than | ||||
// Python we will need to rework this | // 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(), | 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 = | ScriptInterpreter *script_interpreter = | ||||
target->GetDebugger().GetScriptInterpreter(); | target->GetDebugger().GetScriptInterpreter(); | ||||
if (script_interpreter && | if (script_interpreter && | ||||
script_interpreter->IsReservedWord( | script_interpreter->IsReservedWord(module_basename.c_str())) { | ||||
module_basename.c_str())) { | |||||
module_basename.insert(module_basename.begin(), '_'); | module_basename.insert(module_basename.begin(), '_'); | ||||
was_keyword = true; | was_keyword = true; | ||||
} | } | ||||
StreamString path_string; | StreamString path_string; | ||||
StreamString original_path_string; | StreamString original_path_string; | ||||
// for OSX we are going to be in | // for OSX we are going to be in | ||||
// .dSYM/Contents/Resources/DWARF/<basename> let us go to | // .dSYM/Contents/Resources/DWARF/<basename> let us go to | ||||
// .dSYM/Contents/Resources/Python/<basename>.py and see if the | // .dSYM/Contents/Resources/Python/<basename>.py and see if the | ||||
// file exists | // file exists | ||||
path_string.Printf("%s/../Python/%s.py", | path_string.Printf("%s/../Python/%s.py", | ||||
symfile_spec.GetDirectory().GetCString(), | symfile_spec.GetDirectory().GetCString(), | ||||
module_basename.c_str()); | module_basename.c_str()); | ||||
original_path_string.Printf( | original_path_string.Printf( | ||||
"%s/../Python/%s.py", | "%s/../Python/%s.py", | ||||
symfile_spec.GetDirectory().GetCString(), | symfile_spec.GetDirectory().GetCString(), | ||||
original_module_basename.c_str()); | original_module_basename.c_str()); | ||||
FileSpec script_fspec(path_string.GetString()); | FileSpec script_fspec(path_string.GetString()); | ||||
FileSystem::Instance().Resolve(script_fspec); | FileSystem::Instance().Resolve(script_fspec); | ||||
FileSpec orig_script_fspec(original_path_string.GetString()); | FileSpec orig_script_fspec(original_path_string.GetString()); | ||||
FileSystem::Instance().Resolve(orig_script_fspec); | FileSystem::Instance().Resolve(orig_script_fspec); | ||||
// if we did some replacements of reserved characters, and a | // if we did some replacements of reserved characters, and a | ||||
// file with the untampered name exists, then warn the user | // file with the untampered name exists, then warn the user | ||||
// that the file as-is shall not be loaded | // that the file as-is shall not be loaded | ||||
if (feedback_stream) { | if (feedback_stream) { | ||||
if (module_basename != original_module_basename && | if (module_basename != original_module_basename && | ||||
FileSystem::Instance().Exists(orig_script_fspec)) { | FileSystem::Instance().Exists(orig_script_fspec)) { | ||||
const char *reason_for_complaint = | const char *reason_for_complaint = | ||||
was_keyword ? "conflicts with a keyword" | was_keyword ? "conflicts with a keyword" | ||||
: "contains reserved characters"; | : "contains reserved characters"; | ||||
if (FileSystem::Instance().Exists(script_fspec)) | if (FileSystem::Instance().Exists(script_fspec)) | ||||
feedback_stream->Printf( | feedback_stream->Printf( | ||||
"warning: the symbol file '%s' contains a debug " | "warning: the symbol file '%s' contains a debug " | ||||
"script. However, its name" | "script. However, its name" | ||||
" '%s' %s and as such cannot be loaded. LLDB will" | " '%s' %s and as such cannot be loaded. LLDB will" | ||||
" load '%s' instead. Consider removing the file with " | " load '%s' instead. Consider removing the file with " | ||||
"the malformed name to" | "the malformed name to" | ||||
" eliminate this warning.\n", | " eliminate this warning.\n", | ||||
symfile_spec.GetPath().c_str(), | symfile_spec.GetPath().c_str(), | ||||
original_path_string.GetData(), reason_for_complaint, | original_path_string.GetData(), reason_for_complaint, | ||||
path_string.GetData()); | path_string.GetData()); | ||||
else | else | ||||
feedback_stream->Printf( | feedback_stream->Printf( | ||||
"warning: the symbol file '%s' contains a debug " | "warning: the symbol file '%s' contains a debug " | ||||
"script. However, its name" | "script. However, its name" | ||||
" %s and as such cannot be loaded. If you intend" | " %s and as such cannot be loaded. If you intend" | ||||
" to have this script loaded, please rename '%s' to " | " to have this script loaded, please rename '%s' to " | ||||
"'%s' and retry.\n", | "'%s' and retry.\n", | ||||
symfile_spec.GetPath().c_str(), reason_for_complaint, | symfile_spec.GetPath().c_str(), reason_for_complaint, | ||||
original_path_string.GetData(), | original_path_string.GetData(), path_string.GetData()); | ||||
path_string.GetData()); | |||||
} | } | ||||
} | } | ||||
if (FileSystem::Instance().Exists(script_fspec)) { | if (FileSystem::Instance().Exists(script_fspec)) { | ||||
file_list.Append(script_fspec); | file_list.Append(script_fspec); | ||||
break; | break; | ||||
} | } | ||||
// If we didn't find the python file, then keep stripping the | // If we didn't find the python file, then keep stripping the | ||||
// extensions and try again | // extensions and try again | ||||
ConstString filename_no_extension( | ConstString filename_no_extension( | ||||
module_spec.GetFileNameStrippingExtension()); | module_spec.GetFileNameStrippingExtension()); | ||||
if (module_spec.GetFilename() == filename_no_extension) | if (module_spec.GetFilename() == filename_no_extension) | ||||
break; | break; | ||||
module_spec.GetFilename() = filename_no_extension; | module_spec.GetFilename() = filename_no_extension; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
return file_list; | return file_list; | ||||
} | } | ||||
Status PlatformDarwin::ResolveSymbolFile(Target &target, | Status PlatformDarwin::ResolveSymbolFile(Target &target, | ||||
const ModuleSpec &sym_spec, | const ModuleSpec &sym_spec, | ||||
FileSpec &sym_file) { | FileSpec &sym_file) { | ||||
sym_file = sym_spec.GetSymbolFileSpec(); | sym_file = sym_spec.GetSymbolFileSpec(); | ||||
if (FileSystem::Instance().IsDirectory(sym_file)) { | if (FileSystem::Instance().IsDirectory(sym_file)) { | ||||
▲ Show 20 Lines • Show All 1,582 Lines • Show Last 20 Lines |