[Lldb-commits] [lldb] r170932 - in /lldb/trunk: include/lldb/API/SBHostOS.h source/API/SBHostOS.cpp test/dotest.py tools/driver/Driver.cpp tools/driver/Driver.h
Jim Ingham
jingham at apple.com
Fri Dec 21 14:22:26 PST 2012
Author: jingham
Date: Fri Dec 21 16:22:26 2012
New Revision: 170932
URL: http://llvm.org/viewvc/llvm-project?rev=170932&view=rev
Log:
Added an SBAPI to get the PythonPath (if the Host knows how to do that). And a -P option to the Driver
to print it out. Changed dotest.py to use that to find the PythonPath it should use given the lldb binary
it was told to run.
Modified:
lldb/trunk/include/lldb/API/SBHostOS.h
lldb/trunk/source/API/SBHostOS.cpp
lldb/trunk/test/dotest.py
lldb/trunk/tools/driver/Driver.cpp
lldb/trunk/tools/driver/Driver.h
Modified: lldb/trunk/include/lldb/API/SBHostOS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBHostOS.h?rev=170932&r1=170931&r2=170932&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBHostOS.h (original)
+++ lldb/trunk/include/lldb/API/SBHostOS.h Fri Dec 21 16:22:26 2012
@@ -21,6 +21,9 @@
static lldb::SBFileSpec
GetProgramFileSpec ();
+
+ static lldb::SBFileSpec
+ GetLLDBPythonPath ();
static void
ThreadCreated (const char *name);
Modified: lldb/trunk/source/API/SBHostOS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBHostOS.cpp?rev=170932&r1=170931&r2=170932&view=diff
==============================================================================
--- lldb/trunk/source/API/SBHostOS.cpp (original)
+++ lldb/trunk/source/API/SBHostOS.cpp Fri Dec 21 16:22:26 2012
@@ -26,6 +26,18 @@
return sb_filespec;
}
+SBFileSpec
+SBHostOS::GetLLDBPythonPath ()
+{
+ SBFileSpec sb_lldb_python_filespec;
+ FileSpec lldb_python_spec;
+ if (Host::GetLLDBPath (ePathTypePythonDir, lldb_python_spec))
+ {
+ sb_lldb_python_filespec.SetFileSpec (lldb_python_spec);
+ }
+ return sb_lldb_python_filespec;
+}
+
lldb::thread_t
SBHostOS::ThreadCreate
(
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=170932&r1=170931&r2=170932&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Fri Dec 21 16:22:26 2012
@@ -834,38 +834,60 @@
# The '-i' option is used to skip looking for lldb.py in the build tree.
if ignore:
return
+
+ # If our lldb supports the -P option, use it to find the python path:
+ init_in_python_dir = 'lldb/__init__.py'
+ import pexpect
+ lldb_dash_p_result = None
+
+ if lldbHere:
+ lldb_dash_p_result = pexpect.run("%s -P"%(lldbHere))
+ elif lldbExec:
+ lldb_dash_p_result = pexpect.run("%s -P"%(lldbExec))
+
+ if lldb_dash_p_result and not lldb_dash_p_result.startswith(("<", "lldb: invalid option:")):
+ lines = lldb_dash_p_result.splitlines()
+ if len(lines) == 1 and os.path.isfile(os.path.join(lines[0], init_in_python_dir)):
+ lldbPath = lines[0]
+
+ if not lldbPath:
+ dbgPath = os.path.join(base, *(xcode3_build_dir + dbg + python_resource_dir))
+ dbgPath2 = os.path.join(base, *(xcode4_build_dir + dbg + python_resource_dir))
+ dbcPath = os.path.join(base, *(xcode3_build_dir + dbc + python_resource_dir))
+ dbcPath2 = os.path.join(base, *(xcode4_build_dir + dbc + python_resource_dir))
+ relPath = os.path.join(base, *(xcode3_build_dir + rel + python_resource_dir))
+ relPath2 = os.path.join(base, *(xcode4_build_dir + rel + python_resource_dir))
+ baiPath = os.path.join(base, *(xcode3_build_dir + bai + python_resource_dir))
+ baiPath2 = os.path.join(base, *(xcode4_build_dir + bai + python_resource_dir))
- dbgPath = os.path.join(base, *(xcode3_build_dir + dbg + python_resource_dir))
- dbgPath2 = os.path.join(base, *(xcode4_build_dir + dbg + python_resource_dir))
- dbcPath = os.path.join(base, *(xcode3_build_dir + dbc + python_resource_dir))
- dbcPath2 = os.path.join(base, *(xcode4_build_dir + dbc + python_resource_dir))
- relPath = os.path.join(base, *(xcode3_build_dir + rel + python_resource_dir))
- relPath2 = os.path.join(base, *(xcode4_build_dir + rel + python_resource_dir))
- baiPath = os.path.join(base, *(xcode3_build_dir + bai + python_resource_dir))
- baiPath2 = os.path.join(base, *(xcode4_build_dir + bai + python_resource_dir))
-
- if os.path.isfile(os.path.join(dbgPath, 'lldb/__init__.py')):
- lldbPath = dbgPath
- elif os.path.isfile(os.path.join(dbgPath2, 'lldb/__init__.py')):
- lldbPath = dbgPath2
- elif os.path.isfile(os.path.join(dbcPath, 'lldb/__init__.py')):
- lldbPath = dbcPath
- elif os.path.isfile(os.path.join(dbcPath2, 'lldb/__init__.py')):
- lldbPath = dbcPath2
- elif os.path.isfile(os.path.join(relPath, 'lldb/__init__.py')):
- lldbPath = relPath
- elif os.path.isfile(os.path.join(relPath2, 'lldb/__init__.py')):
- lldbPath = relPath2
- elif os.path.isfile(os.path.join(baiPath, 'lldb/__init__.py')):
- lldbPath = baiPath
- elif os.path.isfile(os.path.join(baiPath2, 'lldb/__init__.py')):
- lldbPath = baiPath2
-
+ if os.path.isfile(os.path.join(dbgPath, init_in_python_dir)):
+ lldbPath = dbgPath
+ elif os.path.isfile(os.path.join(dbgPath2, init_in_python_dir)):
+ lldbPath = dbgPath2
+ elif os.path.isfile(os.path.join(dbcPath, init_in_python_dir)):
+ lldbPath = dbcPath
+ elif os.path.isfile(os.path.join(dbcPath2, init_in_python_dir)):
+ lldbPath = dbcPath2
+ elif os.path.isfile(os.path.join(relPath, init_in_python_dir)):
+ lldbPath = relPath
+ elif os.path.isfile(os.path.join(relPath2, init_in_python_dir)):
+ lldbPath = relPath2
+ elif os.path.isfile(os.path.join(baiPath, init_in_python_dir)):
+ lldbPath = baiPath
+ elif os.path.isfile(os.path.join(baiPath2, init_in_python_dir)):
+ lldbPath = baiPath2
+
if not lldbPath:
print 'This script requires lldb.py to be in either ' + dbgPath + ',',
print relPath + ', or ' + baiPath
sys.exit(-1)
+ # Some of the code that uses this path assumes it hasn't resolved the Versions... link.
+ # If the path we've constructed looks like that, then we'll strip out the Versions/A part.
+ (before, frameWithVersion, after) = lldbPath.rpartition("LLDB.framework/Versions/A")
+ if frameWithVersion != "" :
+ lldbPath = before + "LLDB.framework" + after
+
# If tests need to find LLDB_FRAMEWORK, now they can do it
os.environ["LLDB_FRAMEWORK"] = os.path.dirname(os.path.dirname(lldbPath))
Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=170932&r1=170931&r2=170932&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Fri Dec 21 16:22:26 2012
@@ -105,6 +105,8 @@
"Tells the debugger to open source files using the host's \"external editor\" mechanism." },
{ LLDB_3_TO_5, false, "no-lldbinit" , 'x', no_argument , 0, eArgTypeNone,
"Do not automatically parse any '.lldbinit' files." },
+ { LLDB_OPT_SET_6, true , "python-path" , 'P', no_argument , 0, eArgTypeNone,
+ "Prints out the path to the lldb.py file for this version of lldb." },
{ 0, false, NULL , 0 , 0 , 0, eArgTypeNone, NULL }
};
@@ -388,6 +390,7 @@
m_source_command_files (),
m_debug_mode (false),
m_print_version (false),
+ m_print_python_path (false),
m_print_help (false),
m_wait_for(false),
m_process_name(),
@@ -410,6 +413,7 @@
m_debug_mode = false;
m_print_help = false;
m_print_version = false;
+ m_print_python_path = false;
m_use_external_editor = false;
m_wait_for = false;
m_process_name.erase();
@@ -591,6 +595,10 @@
m_option_data.m_print_version = true;
break;
+ case 'P':
+ m_option_data.m_print_python_path = true;
+ break;
+
case 'c':
{
SBFileSpec file(optarg);
@@ -704,6 +712,24 @@
::fprintf (out_fh, "%s\n", m_debugger.GetVersionString());
exit = true;
}
+ else if (m_option_data.m_print_python_path)
+ {
+ SBFileSpec python_file_spec = SBHostOS::GetLLDBPythonPath();
+ if (python_file_spec.IsValid())
+ {
+ char python_path[PATH_MAX];
+ size_t num_chars = python_file_spec.GetPath(python_path, PATH_MAX);
+ if (num_chars < PATH_MAX)
+ {
+ ::fprintf (out_fh, "%s\n", python_path);
+ }
+ else
+ ::fprintf (out_fh, "<PATH TOO LONG>\n");
+ }
+ else
+ ::fprintf (out_fh, "<COULD NOT FIND PATH>\n");
+ exit = true;
+ }
else if (m_option_data.m_process_name.empty() && m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID)
{
// Any arguments that are left over after option parsing are for
Modified: lldb/trunk/tools/driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.h?rev=170932&r1=170931&r2=170932&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.h (original)
+++ lldb/trunk/tools/driver/Driver.h Fri Dec 21 16:22:26 2012
@@ -111,6 +111,7 @@
std::vector<std::string> m_source_command_files;
bool m_debug_mode;
bool m_print_version;
+ bool m_print_python_path;
bool m_print_help;
bool m_wait_for;
std::string m_process_name;
More information about the lldb-commits
mailing list