You can pipe commands to gdb, but how to have auto-complete on those commands?
A initial little try is promising, we can pipe commands to gdb:
~$ echo "show endian" | gdb -q (gdb) The target endianness is set automatically (currently little endian) (gdb) quit
The command show endian was executed by gdb just like if we typed it.
Now let us simulate a completion (-e makes echo interpret the special characters such as \t for TAB):
~$ echo -e "show en\t" | gdb -q (gdb) Ambiguous show command "en ": endian, environment. (gdb) quit
It did not work as wanted. The TAB was not read as a request for completion.
~$ cat | gdb -q (gdb) show en
No better result. Completion via TAB is not possible. gdb simply does not expect terminal commands via pipe. Some people have tried the same with other interactive tools .
Note: it is actually not impossible with bash -i (i.e., interactive bash) .
The solution is to simulate a pseudo-terminal as suggested in :
$ echo -e "show en\t\t\nquit" | python ptypipe.py "" "gdb -q" show en quit (gdb) show en endian environment (gdb) show en Ambiguous show command "en": endian, environment. (gdb) quit
Note that gdb is executed as a sub-process of python.
|||Stackoverflow question, http://stackoverflow.com/questions/5843741/how-can-i-pipe-initial-input-into-process-which-will-then-be-interactive|
|||Stackoverflow answer, http://stackoverflow.com/a/24514947|
|||Stackoverflow question, http://stackoverflow.com/questions/26659595/difference-between-pty-and-a-pipe|