From 9270a201b9d1ba735f5364d70318dc8bfea792b1 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Tue, 23 Apr 2019 01:02:51 +0000 Subject: [PATCH] Add a small check to PlatformDarwin::LoadScriptingResourceForModule which reads the python files in a dSYM bundle, to check that the SymbolFile is actually a dSYM bundle filepath; delay any fetching of the ScriptInterpreter until after we've done that check. When debugging a binary without a dSYM on darwin systems, the SymbolFile we fetch is actually the ObjectFile -- so we would do an unnecessary trip into Python land and stat around the filesystem looking for a python file to read in. There's no reason to do any of this unless the SymbolFile's file path includes the .dSYM bundle telltale path components. llvm-svn: 358938 --- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 8e07095..c14cd1c 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -68,8 +68,6 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( // precisely that. Ideally, we should have a per-platform list of // extensions (".exe", ".app", ".dSYM", ".framework") which should be // stripped while leaving "this.binary.file" as-is. - ScriptInterpreter *script_interpreter = - target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); FileSpec module_spec = module.GetFileSpec(); @@ -81,7 +79,10 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( ObjectFile *objfile = symfile->GetObjectFile(); if (objfile) { FileSpec symfile_spec(objfile->GetFileSpec()); - if (symfile_spec && FileSystem::Instance().Exists(symfile_spec)) { + if (symfile_spec && + FileSystem::Instance().Exists(symfile_spec) && + strcasestr (symfile_spec.GetPath().c_str(), + ".dSYM/Contents/Resources/DWARF") != nullptr) { while (module_spec.GetFilename()) { std::string module_basename( module_spec.GetFilename().GetCString()); @@ -103,6 +104,8 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( ' ', '_'); std::replace(module_basename.begin(), module_basename.end(), '-', '_'); + ScriptInterpreter *script_interpreter = + target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); if (script_interpreter && script_interpreter->IsReservedWord( module_basename.c_str())) { -- 2.7.4