[Lldb-commits] [lldb] r172291 - /lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
Greg Clayton
gclayton at apple.com
Fri Jan 11 17:36:05 PST 2013
Author: gclayton
Date: Fri Jan 11 19:36:05 2013
New Revision: 172291
URL: http://llvm.org/viewvc/llvm-project?rev=172291&view=rev
Log:
Don't always strip the first extension from the module basename when looking for python scripts. Now we take a name like "a.b.c" and look for scripts that are "a_b_c.py", "a_b.py" and "a.py" inside the dSYM.
Modified:
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=172291&r1=172290&r2=172291&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Fri Jan 11 19:36:05 2013
@@ -63,19 +63,10 @@
// should not lose ".file" but GetFileNameStrippingExtension() will do 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.
- std::string module_basename (module.GetFileSpec().GetFileNameStrippingExtension().AsCString(""));
- if (!module_basename.empty())
- {
- // 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(), '-', '_');
+ FileSpec module_spec = module.GetFileSpec();
+ if (module_spec)
+ {
SymbolVendor *symbols = module.GetSymbolVendor ();
if (symbols)
{
@@ -88,13 +79,40 @@
FileSpec symfile_spec (objfile->GetFileSpec());
if (symfile_spec && symfile_spec.Exists())
{
- StreamString 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());
- FileSpec script_fspec(path_string.GetData(), true);
- if (script_fspec.Exists())
- file_list.Append (script_fspec);
+ while (module_spec.GetFilename())
+ {
+ std::string module_basename (module_spec.GetFilename().GetCString());
+
+ // 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(), '-', '_');
+
+
+ StreamString 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());
+ FileSpec script_fspec(path_string.GetData(), true);
+ if (script_fspec.Exists())
+ {
+ 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;
+
+ module_spec.GetFilename() = filename_no_extension;
+ }
}
}
}
More information about the lldb-commits
mailing list