Normally, in Python shells I can press Tab twice to get a list of prompts.
On the other hand, in gdb's Python shell (pi
or python-interactive
command), there's only gdb-style completion.
Example session:
$ gdb -q
(gdb) pi
>>> gdb
<module 'gdb' from '/usr/share/gdb/python/gdb/__init__.py'>
>>> gdb.TabTab
... nothing ...
>>> show TabTab
Display all 148 possibilities? (y or n)
ada exec-direction record
agent exec-done-display remote
annotate exec-file-mismatch remoteaddresssize
[...]
Python auto complete should be at least like this.
$ python
Python 3.X.Y ...
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.TabTab
sys.abiflags sys.hash_info
sys.addaudithook( sys.hexversion
sys.api_version sys.implementation
[...]
How can I get the same/similar thing in gdb? in particular IPython shell with tab completion is fine.
Failed attempts:
-
import readline import rlcompleter readline.parse_and_bind("tab: complete")
makes the shell output a literal tab when Tab is pressed after
sys.
or similar.At least it does work for identifier tab completion (
aTabTab
) does list some entries)Looks like this is because of some interaction with gdb --
get_completer_delims
get reset to some value every time, and if the code above is run then the tab completion outside gdb switches to "Python mode" as well. Use
background_zmq_ipython
causes segmentation fault, because some gdb API (such asgdb.Value
) cannot be read from outside the main thread.Use
IPython.embed()
also make Tab output a literal tab character.The official gdb documentation https://sourceware.org/gdb/current/onlinedocs/gdb/Completion.html doesn't mention anything about Python.