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

Finding terminal size for remote debugging #485

Open
rh-jelabarre opened this issue Nov 12, 2021 · 4 comments
Open

Finding terminal size for remote debugging #485

rh-jelabarre opened this issue Nov 12, 2021 · 4 comments

Comments

@rh-jelabarre
Copy link

Back a few months ago (March/April 2021 time frame) I used to use PUDB debugger, and it would fit itself to the size of my terminal window. Now I am finding it will only display 25 lines by 80 columns. I have tried different $TERM values, but it doesn't change what I get.

This is a remote connection (ssh to remote system). I have tried this in a "tmux" session as well as a regular ssh session under Gnome-terminal and xterm. Tested with $TERM unset, as well as xterm-256color, xterm, gnome, linux, and screen-256color (tmux automatically sets $TERM=screen).

I don't have a simplified script to sun as a test, so the only option I have to try this is a full Tempest testcase, and I have to just close the terminal window so that I don't have to wait for the full testcase to run.

I'm presuming pudb must have a preferred terminal type. I also uninstalled pudb along with it's dependencies and reinstalled.

@inducer
Copy link
Owner

inducer commented Nov 12, 2021

I should preface this by saying that getting terminal sizes for remote pudb is not an actually solvable problem, AFAICT. All that we have is heuristics. This is the current edition of that heuristic:

pudb/pudb/remote.py

Lines 208 to 214 in 9c8a140

if term_size is None:
try:
# Getting terminal size
s = struct.unpack("hh", fcntl.ioctl(1, termios.TIOCGWINSZ, "1234"))
term_size = (s[1], s[0])
except Exception:
term_size = (80, 24)

At the very least, you can simply pass in the terminal size, and it'll use that. Or maybe you'll be able to help determine why the heuristic fails in your use case and what about it could be improved.

@mvanderkamp
Copy link
Contributor

I'm actually a bit confused about this heuristic. It looks like it will grab the size of the terminal in which the program is executing, but if we're using remote debugging won't the pudb instance show up in a completely different terminal? So this would only be correct if the new terminal happened to be the same size. I just tried it out and that does seem to be the case- if I use a smaller terminal to telnet into pudb than I used to run the program, it does not render correctly.

@inducer
Copy link
Owner

inducer commented Nov 14, 2021

Yep, that's the assumption. The idea behind the heuristic is that you have both running in two tabs of the same terminal.

@mvanderkamp
Copy link
Contributor

ahhh okay thank you.

inducer added a commit that referenced this issue Dec 29, 2021
* Move management of current debuggers into Debugger class

* Move term_size heuristic to RemoteDebugger constructor, document better (gh-485)

* Fix post-mortem debugging for Py3

* Remove unexplained stack-eating loop from post_mortem

* add debug_remote_on_single_rank

* flake8

* better doc

* a bit more text

* add an mpi4py example

* allow arguments to func, better doc, simplify

* clarify comment

* more doc

* clarify comment

* add missing args

Co-authored-by: Andreas Kloeckner <[email protected]>
@inducer inducer changed the title pudb will only display in 25x80 text resolution Finding terminal size for remote debugging Jul 19, 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

No branches or pull requests

3 participants