2020-06-02 04:04:32 +08:00
|
|
|
UNSUPPORTED: lldb-repro
|
|
|
|
|
|
|
|
RUN: %lldb --help | FileCheck %s
|
|
|
|
RUN: cat %S/../../../docs/man/lldb.rst | FileCheck %s
|
|
|
|
|
|
|
|
CHECK: ATTACHING
|
|
|
|
CHECK: --attach-name
|
|
|
|
CHECK: --attach-pid
|
|
|
|
CHECK: -n <value>
|
|
|
|
CHECK: -p <value>
|
|
|
|
CHECK: --wait-for
|
|
|
|
CHECK: -w
|
|
|
|
|
|
|
|
CHECK: COMMANDS
|
|
|
|
CHECK: --batch
|
|
|
|
CHECK: -b
|
|
|
|
CHECK: -K <value>
|
|
|
|
CHECK: -k <value>
|
|
|
|
CHECK: --local-lldbinit
|
|
|
|
CHECK: --no-lldbinit
|
|
|
|
CHECK: --one-line-before-file
|
|
|
|
CHECK: --one-line-on-crash
|
|
|
|
CHECK: --one-line
|
|
|
|
CHECK: -O
|
|
|
|
CHECK: -o
|
|
|
|
CHECK: -Q
|
|
|
|
CHECK: --source-before-file
|
|
|
|
CHECK: --source-on-crash
|
|
|
|
CHECK: --source-quietly
|
|
|
|
CHECK: --source
|
|
|
|
CHECK: -S
|
|
|
|
CHECK: -s
|
|
|
|
CHECK: -x
|
|
|
|
|
|
|
|
CHECK: OPTIONS
|
|
|
|
CHECK: --arch
|
|
|
|
CHECK: -a
|
|
|
|
CHECK: --capture-path
|
|
|
|
CHECK: --capture
|
|
|
|
CHECK: --core
|
|
|
|
CHECK: -c
|
|
|
|
CHECK: --debug
|
|
|
|
CHECK: -d
|
|
|
|
CHECK: --editor
|
|
|
|
CHECK: -e
|
|
|
|
CHECK: --file
|
|
|
|
CHECK: -f
|
|
|
|
CHECK: --help
|
|
|
|
CHECK: -h
|
|
|
|
CHECK: --no-use-colors
|
|
|
|
CHECK: --version
|
|
|
|
CHECK: -v
|
|
|
|
CHECK: -X
|
|
|
|
|
|
|
|
CHECK: REPL
|
|
|
|
CHECK: -r
|
|
|
|
CHECK: --repl-language
|
|
|
|
CHECK: --repl
|
|
|
|
CHECK: -R
|
|
|
|
CHECK: -r
|
|
|
|
|
|
|
|
CHECK: SCRIPTING
|
|
|
|
CHECK: -l
|
[lldb] make it easier to find LLDB's python
It is surprisingly difficult to write a simple python script that
can reliably `import lldb` without failing, or crashing. I'm
currently resorting to convolutions like this:
def find_lldb(may_reexec=False):
if prefix := os.environ.get('LLDB_PYTHON_PREFIX'):
if os.path.realpath(prefix) != os.path.realpath(sys.prefix):
raise Exception("cannot import lldb.\n"
f" sys.prefix should be: {prefix}\n"
f" but it is: {sys.prefix}")
else:
line1, line2 = subprocess.run(
['lldb', '-x', '-b', '-o', 'script print(sys.prefix)'],
encoding='utf8', stdout=subprocess.PIPE,
check=True).stdout.strip().splitlines()
assert line1.strip() == '(lldb) script print(sys.prefix)'
prefix = line2.strip()
os.environ['LLDB_PYTHON_PREFIX'] = prefix
if sys.prefix != prefix:
if not may_reexec:
raise Exception(
"cannot import lldb.\n" +
f" This python, at {sys.prefix}\n"
f" does not math LLDB's python at {prefix}")
os.environ['LLDB_PYTHON_PREFIX'] = prefix
python_exe = os.path.join(prefix, 'bin', 'python3')
os.execl(python_exe, python_exe, *sys.argv)
lldb_path = subprocess.run(['lldb', '-P'],
check=True, stdout=subprocess.PIPE,
encoding='utf8').stdout.strip()
sys.path = [lldb_path] + sys.path
This patch aims to replace all that with:
#!/usr/bin/env lldb-python
import lldb
...
... by adding the following features:
* new command line option: --print-script-interpreter-info. This
prints language-specific information about the script interpreter
in JSON format.
* new tool (unix only): lldb-python which finds python and exec's it.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D112973
2021-11-11 02:33:33 +08:00
|
|
|
CHECK: --print-script-interpreter-info
|
2020-06-02 04:04:32 +08:00
|
|
|
CHECK: --python-path
|
|
|
|
CHECK: -P
|
|
|
|
CHECK: --script-language
|