sublimelsp / LSP-pyright

Python support for Sublime's LSP plugin provided through microsoft/pyright.
MIT License
126 stars 13 forks source link

Add "gdb" dev environment (Linux only?) #353

Closed rwols closed 3 weeks ago

rwols commented 3 weeks ago

The gdb debugger can be scripted with python scripts. I would like to use LSP-pyright to get autocompletion for these gdb scripts.

The gdb program has an option to run a file with commands at startup and then exit. We can use this to determine the additional search paths we need to set for this "gdb" dev environment:

~/Desktop $ gdb --batch --command=print_sys_path.commands | jq
[
  "/home/raoul",
  "/usr/share/gdb/python",
  "/usr/lib/python310.zip",
  "/usr/lib/python3.10",
  "/usr/lib/python3.10/lib-dynload",
  "/home/raoul/.local/lib/python3.10/site-packages",
  "/usr/local/lib/python3.10/dist-packages",
  "/usr/lib/python3/dist-packages",
  "/usr/lib/python3.10/dist-packages"
]

The print_sys_path.commands file is very simple:

~/Desktop $ cat print_sys_path.commands
python
import sys
import json
json.dump(sys.path, sys.stdout)
end
exit

So from this output, we can see that we need to add the additional search paths

/home/raoul
/usr/share/gdb/python