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

Conversation

RoderickChan
Copy link
Contributor

@RoderickChan RoderickChan commented Aug 5, 2022

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

Description/Motivation/Screenshots

Sometimes, the old method list(new_ptses - old_ptses)[0] cannot get the right pty while meeting other tmux-pty operations at the same time. And it's better to kill the pane generated by tmux after quitting gdb.

Against which architecture was this tested ?

"Tested" indicates that the PR works and the unit test (i.e. make test) run passes without issue.

  • x86-32
  • x86-64
  • ARM
  • AARCH64
  • MIPS
  • POWERPC
  • SPARC
  • RISC-V

Checklist

  • My PR was done against the dev branch, not main.
  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • If my change adds new code, adequate tests have been added.
  • I have read and agree to the CONTRIBUTING document.

gef.py Outdated
old_ptses = set(os.listdir("/dev/pts"))
gdb.execute(f"! {tmux} split-window -h 'clear ; cat'")

pane_info = subprocess.check_output(["tmux", "splitw", "-h",'-F#{session_name}:#{window_index}.#{pane_index}-#{pane_tty}', "-P"]).decode().strip().split("-")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be tmux not "tmux", and double quotes around the long arg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double quotes will not work here

gef.py Outdated
pane_info = subprocess.check_output(["tmux", "splitw", "-h",'-F#{session_name}:#{window_index}.#{pane_index}-#{pane_tty}', "-P"]).decode().strip().split("-")
pane = pane_info[0]
pty = pane_info[1]
atexit.register(lambda : os.system(f"{tmux} kill-pane -t {pane}"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use subprocess here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use subprocess.run now

gef.py Outdated
pty = pane_info[1]
atexit.register(lambda : subprocess.run([tmux, "kill-pane", "-t", pane]))

gdb.execute(f"! {tmux} send-keys -t {pane} 'clear;sleep infinity' C-m")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why you need these keys to be sent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaining why you need these keys to be sent?

okay, I add a comment and still use cat.

Signed-off-by: roderick <ch22166@163.com>
gef.py Outdated Show resolved Hide resolved
Co-authored-by: crazy hugsy <hugsy@users.noreply.github.com>
@hugsy hugsy merged commit 2b52a43 into hugsy:dev Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants