tty command in gdb can direct output to another terminal.
Like https://stackoverflow.com/questions/8963208/gdb-display-output-of-target-application-in-a-separate-window
But I want it to be set automatically.
Method
Create a script ~/.gdbtty.sh
Its content
#!/bin/bash
gnome-terminal -- bash -c "tty > ~/.gdbtty.txt; exec bash" &
sleep 0.5 # Give it time to open
TTY=$(cat ~/.gdbtty.txt)
echo "set inferior-tty $TTY" > ~/.gdbtty.txt
And edit ~/.gdbinit
as
shell ~/.gdbtty.sh
source ~/.gdbtty.txt
Some shortcomings
It's good but with some tiny shortcomings that I currently can't solve.
- I cannot control where the output terminal would popup. (But even I can control, I have no idea where is the ideal position for me)
- The output terminal may show a harmless warning "warning: GDB: Failed to set controlling terminal: Operation not permitted"
Top comments (0)