[lldb] make it easier to find LLDB's pythonIt is surprisingly difficult to write a simple python script thatcan reliably `import lldb` without failing, or crashing. I'mcurrently resorting to co
[lldb] make it easier to find LLDB's pythonIt is surprisingly difficult to write a simple python script thatcan reliably `import lldb` without failing, or crashing. I'mcurrently 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.pathThis 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: JDevlieghereDifferential Revision: https://reviews.llvm.org/D112973
show more ...
[lldb] fix --source-quietlyJim says:lldb has a -Q or --source-quietly option, which supposedly does: --source-quietly Tells the debugger to execute this one-line lldb command before any
[lldb] fix --source-quietlyJim says:lldb has a -Q or --source-quietly option, which supposedly does: --source-quietly Tells the debugger to execute this one-line lldb command before any file has been loaded.That seems like a weird description, since we don't generally use source for one line entries, but anyway, let's try it: > $LLDB_LLVM/clean-mono/build/Debug/bin/lldb -Q "script print('I should be quiet')" a.out -O "script print('I should be before')" -o "script print('I should be after')" (lldb) script print('I should be before') I should be before (lldb) target create "script print('I should be quiet')" error: unable to find executable for 'script print('I should be quiet')'That was weird. The first real -O gets sourced but not quietly, then the argument to the -Q gets treated as the target. > $LLDB_LLVM/clean-mono/build/Debug/bin/lldb -Q a.out -O "script print('I should be before')" -o "script print('I should be after')" (lldb) script print('I should be before') I should be before (lldb) target create "a.out" Current executable set to '/tmp/a.out' (x86_64). (lldb) script print('I should be after') I should be afterWell, that's a little better, but the -Q option seems to have done nothing.---This fixes the description of --source-quietly, as well as causing itto actually suppress echoing while executing the initializationcommands.Reviewed By: jinghamDifferential Revision: https://reviews.llvm.org/D112988
Fix typo, arvm7 -> armv7
[lldb][docs] Use inline literals for code/paths instead of rendering it with the default roleRight now we're using the 'content' role as default which will just renderthese things as cursive (whic
[lldb][docs] Use inline literals for code/paths instead of rendering it with the default roleRight now we're using the 'content' role as default which will just renderthese things as cursive (which isn't really useful for code examples). It alsoprevents us from assigning a more useful default role in the future.
[lldb] [docs] Add a manpage for lldb-serverDifferential Revision: https://reviews.llvm.org/D92872
[lldb/interpreter] Improve REPL init file compatibilityThis patch changes the command interpreter sourcing logic for the REPLinit file. Instead of looking for a arbitrary file name, it standardize
[lldb/interpreter] Improve REPL init file compatibilityThis patch changes the command interpreter sourcing logic for the REPLinit file. Instead of looking for a arbitrary file name, it standardizesthe REPL init file name to match to following scheme: `.lldbinit-<language>-repl`This will make the naming more homogenous and the sourcing logic future-proof.rdar://65836048Differential Revision: https://reviews.llvm.org/D86987Signed-off-by: Med Ismail Bennani <[email protected]>
[lldb/interpreter] Add REPL-specific init fileThis patch adds the infrastructure to have language specific REPL initfiles. It's the foundation work to a following patch that will introduceSwift R
[lldb/interpreter] Add REPL-specific init fileThis patch adds the infrastructure to have language specific REPL initfiles. It's the foundation work to a following patch that will introduceSwift REPL init file.When lldb is launched with the `--repl` option, it will look for a REPLinit file in the home directory and source it. This overrides thedefault `~/.lldbinit`, which content might make the REPL behaveunexpectedly. If the REPL init file doesn't exists, lldb will fall backto the default init file.rdar://65836048Differential Revision: https://reviews.llvm.org/D86242Signed-off-by: Med Ismail Bennani <[email protected]>
[Docs] Correct description of lldbinit behaviorJim pointed out that "every time somebody has touched the documentationon startup files they have stated that we source the application one andthen
[Docs] Correct description of lldbinit behaviorJim pointed out that "every time somebody has touched the documentationon startup files they have stated that we source the application one andthen the global one, even though in actual fact we’ve never done that."Indeed, when we read the application specific .lldbinit file, the globalone is not read. This patch updates the man page to reflect that.
[lldb/Docs] Add the application speicfic lldbinit to the man pageThis used to be part of the man page but got lost when we moved togenerating it with Sphinx.
[lldb/Driver] Fix handling on positional argumentsBefore the transition to libOption it was possible to specify argumentsfor the inferior without -- as long as they didn't start with a dash.For
[lldb/Driver] Fix handling on positional argumentsBefore the transition to libOption it was possible to specify argumentsfor the inferior without -- as long as they didn't start with a dash.For example, the following invocations should all behave the same: $ lldb inferior inferior-arg $ lldb inferior -- inferior-arg $ lldb -- inferior inferior-argThis patch fixes that behavior, documents it and adds a test to coverthe different combinations.Differential revision: https://reviews.llvm.org/D80165
[lldb/Docs] Extend description section of the main pageThe current description is a bit terse. I've copy/pasted theintroduction form the website.
[Docs] Generate the LLDB man page with SphinxThis patch replaces the existing out-of-date man page for lldb andreplaces it with an RST file from which sphinx generates the actualtroff file. This
[Docs] Generate the LLDB man page with SphinxThis patch replaces the existing out-of-date man page for lldb andreplaces it with an RST file from which sphinx generates the actualtroff file. This is similar to how man pages are generated for the restof the LLVM utilities.The man page is generated by building the `docs-lldb-man` target.Differential revision: https://reviews.llvm.org/D70514