Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get pty by tmux command and close pane when gdb exit #881

Merged
merged 2 commits into from
Sep 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions gef.py
Original file line number Diff line number Diff line change
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