summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/API/SBHostOS.h3
-rw-r--r--lldb/source/API/SBHostOS.cpp12
-rwxr-xr-xlldb/test/dotest.py74
-rw-r--r--lldb/tools/driver/Driver.cpp26
-rw-r--r--lldb/tools/driver/Driver.h1
5 files changed, 90 insertions, 26 deletions
diff --git a/lldb/include/lldb/API/SBHostOS.h b/lldb/include/lldb/API/SBHostOS.h
index b3165777260..52754ea4e82 100644
--- a/lldb/include/lldb/API/SBHostOS.h
+++ b/lldb/include/lldb/API/SBHostOS.h
@@ -21,6 +21,9 @@ public:
static lldb::SBFileSpec
GetProgramFileSpec ();
+
+ static lldb::SBFileSpec
+ GetLLDBPythonPath ();
static void
ThreadCreated (const char *name);
diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp
index 573e0557aa8..e088c29d4aa 100644
--- a/lldb/source/API/SBHostOS.cpp
+++ b/lldb/source/API/SBHostOS.cpp
@@ -26,6 +26,18 @@ SBHostOS::GetProgramFileSpec ()
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
(
diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py
index 5d604f4bc87..5e2a1071925 100755
--- a/lldb/test/dotest.py
+++ b/lldb/test/dotest.py
@@ -834,38 +834,60 @@ def setupSysPath():
# 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))
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 623eddf773a..8bbc212c717 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -105,6 +105,8 @@ static OptionDefinition g_options[] =
"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 @@ Driver::OptionData::OptionData () :
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 @@ Driver::OptionData::Clear ()
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 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
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 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
::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
diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h
index 16558e013dc..2366854dd11 100644
--- a/lldb/tools/driver/Driver.h
+++ b/lldb/tools/driver/Driver.h
@@ -111,6 +111,7 @@ public:
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;
OpenPOWER on IntegriCloud