Skip to content

Commit

Permalink
get pty by tmux command and close pane when gdb exit (#881)
Browse files Browse the repository at this point in the history
* get pty by tmux command and close pane when gdb exit

Signed-off-by: roderick <ch22166@163.com>

* Minor edit of pane_info

Co-authored-by: crazy hugsy <hugsy@users.noreply.github.com>

Signed-off-by: roderick <ch22166@163.com>
Co-authored-by: crazy hugsy <hugsy@users.noreply.github.com>
  • Loading branch information
RoderickChan and hugsy committed Sep 30, 2022
1 parent 8406460 commit 2b52a43
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gef.py
Expand Up @@ -52,6 +52,7 @@
import abc
import argparse
import ast
import atexit
import binascii
import codecs
import collections
Expand Down Expand Up @@ -9962,12 +9963,13 @@ def tmux_setup(self) -> None:
forcing the context to be redirected there."""
tmux = which("tmux")
ok("tmux session found, splitting window...")
old_ptses = set(os.listdir("/dev/pts"))
gdb.execute(f"! {tmux} split-window -h 'clear ; cat'")

pane, pty = subprocess.check_output([tmux, "splitw", "-h", '-F#{session_name}:#{window_index}.#{pane_index}-#{pane_tty}', "-P"]).decode().strip().split("-")
atexit.register(lambda : subprocess.run([tmux, "kill-pane", "-t", pane]))
# clear the screen and let it wait for input forever
gdb.execute(f"! {tmux} send-keys -t {pane} 'clear ; cat' C-m")
gdb.execute(f"! {tmux} select-pane -L")
new_ptses = set(os.listdir("/dev/pts"))
pty = list(new_ptses - old_ptses)[0]
pty = f"/dev/pts/{pty}"

ok(f"Setting `context.redirect` to '{pty}'...")
gdb.execute(f"gef config context.redirect {pty}")
ok("Done!")
Expand Down

0 comments on commit 2b52a43

Please sign in to comment.