Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Jan Kratochvil <jkratoch@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [pushed] Fix PR tui/21216: TUI line breaks regression
Date: Fri, 10 Mar 2017 17:20:00 -0000	[thread overview]
Message-ID: <4593d5aa-00c7-75a9-9fc6-b65bddad0c0a@redhat.com> (raw)
In-Reply-To: <20170310140450.GA5206@host1.jankratochvil.net>

Fixing this properly is turning out to be much trickier than
I expected.

The main issue is that the TUI/ncurses updates/refreshes to
the command window are done by drawing only what changed,
using cursor movement.

For example, with a small enough screen, we see:

 (gdb) PASS: gdb.tui/tui-nl-filtered-output.exp: set pagination on
 set height 2000

 (gdb) PASS: gdb.tui/tui-nl-filtered-output.exp: set height 2000
 printf "hello\nworld\n"^[[2A^[[23Dprintf "hello\nworld\n"

 hello                

 world^[[K

 (gdb) FAIL: gdb.tui/tui-nl-filtered-output.exp: correct line breaks

"2A" is move up two lines, "23D" is move left 23 lines, then
print "printf "hello\nworld\n"", then "hello\nworld"
then "K" to clear the line, and finally print the prompt.

I tried to work around it by forcing empty commands in between
commands, to force the screen to clear, but the "smart" refresh makes
the output of that even harder to match.

What you were seeing:

 (gdb) set pagination on^[[17D^[[K


 (gdb) set height 2000^[[15D^[[K


... that's moving the cursor to the start of the line, and then
clearing it, making room for the next command.  I.e., both commands
appeared on the same vertical coordinate on the screen, presumably
because the command window only fitted one line or two.

So in general, we can't just strip escape sequences.  

Maybe we could pull it off by implementing a virtual terminal
that is aware of the escape sequences, understands the cursor
movement, line clearing, etc., something like the
un_ansi_vt procedure here:

 [handling of ANSI terminals using Expect]
 http://wiki.tcl.tk/9673

We'd send the test command to gdb, and feed gdb's output to that
procedure in a loop, which builds an array of lines, and then check
if the rendered command "screen" (an array of lines) had the
command result we wanted.

We'd need to match the virtual terminal's "bounding" with
the command window's size.  Ideally, we'd be able to force
the exact size of command window we want, instead of inheriting
that from the terminal dejagnu is running on.

Or maybe do something different.  Maybe dump the screen using scr_dump
and compare to a dump previously saved.  I'd need to investigate
further.

So while I think it'd be neat to do any of this, it's a lot more work
and investigation than this new test is worth it.  So for now, I'm
going to simply remove it.

Thanks,
Pedro Alves


  reply	other threads:[~2017-03-10 17:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08  0:19 Pedro Alves
2017-03-09 23:04 ` Jan Kratochvil
2017-03-10 12:59   ` Jan Kratochvil
2017-03-10 13:33     ` Pedro Alves
2017-03-10 14:04       ` Jan Kratochvil
2017-03-10 17:20         ` Pedro Alves [this message]
2017-03-10 17:27           ` Jan Kratochvil
2017-03-10 18:17             ` Pedro Alves
2017-03-10 18:46               ` Jan Kratochvil
2017-03-10 18:55                 ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4593d5aa-00c7-75a9-9fc6-b65bddad0c0a@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jkratoch@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox