[Lldb-commits] [lldb] [lldb][gdb-remote] Forward client terminal size to lldb-server (PR #201141)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 9 06:13:17 PDT 2026
charles-zablit wrote:
> > On Windows, the ConPTY emulates a PTY. The client's terminal (the one the user is running lldb from) has to match the dimensions of the ConPTY so that the debuggee (which is attached to the ConPTY) gets proper terminal emulation. If there is a mismatch, lines will not wrap at the right column and VT sequences will be out of place. In practice, in lldb, this results in the (lldb) prompt being overwritten by the stdout of the debuggee.
>
> How do you recreate this? I guess:
>
> * Launch a terminal at default size.
> * Resize it to non-default size.
> * Launch lldb, launch the debugee
> * See corrupted output
>
> Which would mean the tests for this are anything that expected `(lldb)`, when run from a non-default terminal size.
>
> Anyway it's good to include reproduction steps in case this PR does not fix the issue, or only partially fixes it.
The steps you gave are correct. I would replace `default size` with `current terminal size`. If the terminal lldb is running in is `X,Y` then the ConPTY's size also has to be `X,Y.
We used to not properly size the ConPTY at all before and any debuggee which writes 1 or 2 lines to stdout would immediatly corrupt the output.
I never figuredo out to write proper tests for it however.
>
> > QSetSTDIOWindowSize:cols=N;rows=N, to send the dimension of the terminal to the debuggee.
>
> Maybe this is a silly question, but above the docs for this packet are [lldb.llvm.org/resources/lldbgdbremote.html#qsetstdin-ascii-hex-path-qsetstdout-ascii-hex-path-qsetstderr-ascii-hex-path](https://lldb.llvm.org/resources/lldbgdbremote.html#qsetstdin-ascii-hex-path-qsetstdout-ascii-hex-path-qsetstderr-ascii-hex-path).
>
> So here STDIO means stdout + stderr, right? stdin you don't have dimensions.
>
> So if some application presented two different TUIs on stdout and stderr, in theory, both would have the correct size. (ofc for such an application you'd want to split it into different terminals anyway, but it's the only example I can think of)
That's correct, STDIO really means stdout+stderr, stdin does not need to have dimensions.
https://github.com/llvm/llvm-project/pull/201141
More information about the lldb-commits
mailing list