From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DF95E3973065; Fri, 8 Jan 2021 23:45:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF95E3973065 From: "simark at simark dot ca" To: gdb-prs@sourceware.org Subject: [Bug gdb/27156] gdb.tui/tui-missing-src.exp is unstable Date: Fri, 08 Jan 2021 23:45:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simark at simark dot ca X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2021 23:45:51 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27156 --- Comment #3 from Simon Marchi --- After comparing two runs, one where the test passed and one where it failed, with this patch applied: https://sourceware.org/pipermail/gdb-patches/2021-January/174827.html which adds some logging about what happens with the cursor, I think I figur= ed out what happens. Tip: when using the patch above, use "make check-read1", that makes the out= put easier to read, because we read and handle one character at a time. When we do "start", this is expected to appear: ---8<--- (gdb) start Temporary breakpoint 1 at 0x1135: file /tmp/blah/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/= allo/allo/allo/allo/allo/allo/allo/src/gdb/testsuite/outputs/gdb.tui/tui-mi= ssing-src/main.c, line 6. Starting program: /tmp/blah/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/= allo/allo/allo/allo/allo/allo/allo/src/gdb/testsuite/outputs/gdb.tui/tui-mi= ssing-src/tui-missing-src Temporary breakpoint 1, main () at /tmp/blah/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/= allo/allo/allo/allo/allo/allo/allo/src/gdb/testsuite/outputs/gdb.tui/tui-mi= ssing-src/ main.c:6 (gdb) --->8--- If you're wondering what's up with those paths, it's because the issue happ= ens when the path is long enough. In the working case, we see that this is first drawn: Temporary breakpoint 1 at 0x1135: file /tmp/blah/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/= allo/allo/allo/allo/allo/allo/allo/src/gdb/testsuite/outputs/gdb.tui/tui-mi= ssing-src/main.c, line 6. Starting program: /tmp/blah/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/= allo/allo/allo/allo/allo/allo/allo/src/gdb/testsuite/outputs/gdb.tui/tui-mi= ssing-src/tui-missing-src and then the cursor is moved to redraw the locator window: +++ Vertical Line Position Absolute (16), cursor: (23, 0) -> (15, 0) Then, the breakpoint is hit and this is drawn: Temporary breakpoint 1, main () at /tmp/blah/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/= allo/allo/allo/allo/allo/allo/allo/src/gdb/testsuite/outputs/gdb.tui/tui-mi= ssing-src/main.c:6 (gdb) and then we see "next", the following command. In the failing case, GDB draws: Temporary breakpoint 1 at 0x1135: file /tmp/blah/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/= allo/allo/allo/allo/allo/allo/allo/src/gdb/testsuite/outputs/gdb.tui/tui-mi= ssing-src/main.c, line 6. Starting program: /tmp/blah/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/allo/= allo/allo/allo/allo/allo/allo/allo/src/gdb/testsuite/outputs/gdb.tui/tui-mi= ssing-src/tui-missing-src But then it looks like GDB immediatly draws "next\n". I think this is happening: 1. GDB executes the start command 2. As part of this, the pty is given to the inferior and put in its original state, that means "echo" mode is on 3. The testsuite sends "next\n", which gets echo'ed back, before the breakp= oint has hit and GDB has taken back control of the terminal. 4. If the path printed in the previous message was long enough, the cursor = is at the last line of the terminal, so "next\n" goes beyond the last line and= we hit a situation where scrolling would be needed. To make the issue happen all the time: 1. Build GDB in a directory with a long name 2. Apply this little patch to the test case, which makes "start" take a bit= of time, and guarantees that "next\n" will be sent while terminal is in "infer= ior" mode. diff --git a/gdb/testsuite/gdb.tui/tui-missing-src.exp b/gdb/testsuite/gdb.tui/tui-missing-src.exp index 3116864ec801..031b8c003703 100644 --- a/gdb/testsuite/gdb.tui/tui-missing-src.exp +++ b/gdb/testsuite/gdb.tui/tui-missing-src.exp @@ -37,7 +37,12 @@ set srcfiles [list $mainfile $f2file] # This file will be removed after compilation. set fd [open "$mainfile" w] puts $fd { +#include extern int f2(int); +__attribute__((constructor)) +static void add_a_delay() { + sleep (3); +} int main () { I've taken a screen dump when that "FIXME scroll" is hit, we can see that "next" is at the last line: Screen Dump (80 x 24): 0 +--------------------------------------------------------------------------= ----+ 1 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 2 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 3 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 4 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 5 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 6 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 7 | [ No Source Available ]=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 8 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 9 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 10 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 11 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 12 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 13 |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 | 14 +--------------------------------------------------------------------------= ----+ 15 exec No process In: L?= ?=20=20 PC: ??=20 16 (gdb) startTemporary breakpoint 1 at 0x1152: file /tmp/blah/blah/blah/blah/blah/ 17 blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/= blah/ 18 blah/blah/blah/blah/blah/gdb/testsuite/outputs/gdb.tui/tui-missing-src/main= .c, l 19 ine 11.=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 20 Starting program: /tmp/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/bl 21 ah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/blah/gd= b/tes 22 tsuite/outputs/gdb.tui/tui-missing-src/tui-missing-src=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 23 next --=20 You are receiving this mail because: You are on the CC list for the bug.=