From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 889ED3857426; Fri, 23 Sep 2022 14:23:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 889ED3857426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663942987; bh=7FDWDwCWcxJYZ5vZ+0dAX914Xy+kGfvBvBeCElNoaY4=; h=From:To:Subject:Date:From; b=vgVouh9q6ZyQ0pUlSZDJ6pGCvmosX67sYIJuNa+Ly2lRb8mV1AeC+JFmxPNdlVIYg l3ulZVmyRUKRwgyS7BvYw44WgVAyh1XPUJrNxrqyQ9JnuZnyB+HB9NbgwcP2fhptZD +InJen0h6Y1WX6HXo0m5dr+dNqVVR+0kZuejiUtg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite/tui: start GDB with "set filename-display basename" X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 8e037eae6823caf5b9cb5b4feb3de838abb25956 X-Git-Newrev: 618ba27878a2c6f155eb5e1235c0484a55786a15 Message-Id: <20220923142307.889ED3857426@sourceware.org> Date: Fri, 23 Sep 2022 14:23:07 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D618ba27878a2= c6f155eb5e1235c0484a55786a15 commit 618ba27878a2c6f155eb5e1235c0484a55786a15 Author: Simon Marchi Date: Thu Sep 22 12:02:15 2022 -0400 gdb/testsuite/tui: start GDB with "set filename-display basename" =20 The test gdb.tui/tui-missing-src.exp fails on my CI machine, and I concluded that it is caused by the long source directory name: =20 /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy= -amd64/target_board/unix/src/binutils-gdb =20 The long name causes some particular redrawing that doesn't happen for shorter directories, and causes a Term::command call to return too early. =20 This can be reproduced by cloning the binutils-gdb repo in a directory with a name similar to the one shown above. =20 $ pwd /home/simark/workspace/binutils-gdb_master_linuxbuild/platform/jamm= y-amd64/target_board/unix/src/binutils-gdb/build/gdb $ make check-read1 TESTS=3D"gdb.tui/tui-missing-src.exp" FAIL: gdb.tui/tui-missing-src.exp: checking if inside f2 () FAIL: gdb.tui/tui-missing-src.exp: f2.c must be displayed in source= window FAIL: gdb.tui/tui-missing-src.exp: check source box is empty after = return FAIL: gdb.tui/tui-missing-src.exp: Back in main =20 Note that using "make check" instead of "make check-read1" only shows the last 2 failures for me. =20 When running gdb.tui/tui-missing-src.exp in a directory with a shorter name, the terminal looks like this by the time the "checking if inside f2" test runs: =20 Screen Dump (size 80 columns x 24 rows, cursor at column 6, row 23): 0 +-...ld/binutils-gdb-noasan/gdb/testsuite/outputs/gdb.tui/tui= -missing-src/f2.c-+ 1 | 1 = | 2 | 2 int = | 3 | 3 f2 (int x) = | 4 | 4 { = | 5 | > 5 x <<=3D 1; = | 6 | 6 return x+5; = | 7 | 7 } = | 8 | 8 = | 9 | 9 = | 10 | 10 = | 11 | 11 = | 12 | 12 = | 13 | 13 = | 14 +------------------------------------------------------------= ------------------+ 15 multi-thre Thread 0x7ffff7cc07 In: f2 L5 = PC: 0x555555555143 16 at /home/simark/build/binutils-gdb-noasan/gdb/testsuite/o= utputs/gdb.tui/tui- 17 missing-src/main.c:6 18 (gdb) next 19 (gdb) step 20 f2 (x=3D4) 21 at /home/simark/build/binutils-gdb-noasan/gdb/testsuite/o= utputs/gdb.tui/tui- 22 missing-src/f2.c:5 23 (gdb) PASS: gdb.tui/tui-missing-src.exp: checking if inside f2 () =20 When running the `Term::command "step"` just before, GDB writes the "step", which makes the `wait_for` proc go in the "looking for the prompt" mode, to know when the command's execution is complete. As some new output appears, lines that must disappear are deleted using the "Delete Line" operation [1] and some new ones are drawn. The source window gets redrawn with the contents of the f2.c file. Then, GDB writes the prompt (at line 23 above), which satisfies `wait_for`, which then returns. The state of the terminal is therefore correct for the "check if inside f2" and "f2.c must be displayed in the source window" tests. =20 In the non-working case, the terminal looks like this by the time the "check if inside f2" test runs: =20 Screen Dump (size 80 columns x 24 rows, cursor at column 6, row 17= ): 0 +------------------------------------------------------------= ------------------+ 1 | = | 2 | = | 3 | = | 4 | = | 5 | = | 6 | = | 7 | [ No Source Available ] = | 8 | = | 9 | = | 10 | = | 11 | = | 12 | = | 13 | = | 14 +------------------------------------------------------------= ------------------+ 15 multi-thre Thread 0x7ffff7cc1b In: main L7 = PC: 0x555555555128 16 sing-src/main.c:6 17 (gdb) ary breakpoint 1, main () 18 at /home/simark/workspace/binutils-gdb_master_linuxbuild/= platform/jammy-amd6 19 4/target_board/unix/src/binutils-gdb/build/gdb/testsuite/outp= uts/gdb.tui/tui-mis 20 sing-src/main.c:6 21 (gdb) next 22 (gdb) step 23 FAIL: gdb.tui/tui-missing-src.exp: checking if inside f2 () =20 What happened is: GDB wrote the "step" command, which make the `wait_for` proc go in its "looking for the prompt" mode. However, curses decided to redraw whatever scrolled up to line 17 using some standard character insertion operations: =20 +++ Cursor Down (1), cursor: (16, 0) -> (17, 0) +++ Inserting string '(' +++ Inserted char '(', cursor: (17, 0) -> (17, 1) +++ Inserted string '(', cursor: (17, 0) -> (17, 1) +++ Inserting string 'g' +++ Inserted char 'g', cursor: (17, 1) -> (17, 2) +++ Inserted string 'g', cursor: (17, 1) -> (17, 2) +++ Inserting string 'd' +++ Inserted char 'd', cursor: (17, 2) -> (17, 3) +++ Inserted string 'd', cursor: (17, 2) -> (17, 3) +++ Inserting string 'b' +++ Inserted char 'b', cursor: (17, 3) -> (17, 4) +++ Inserted string 'b', cursor: (17, 3) -> (17, 4) +++ Inserting string ')' +++ Inserted char ')', cursor: (17, 4) -> (17, 5) +++ Inserted string ')', cursor: (17, 4) -> (17, 5) +++ Inserting string ' ' +++ Inserted char ' ', cursor: (17, 5) -> (17, 6) +++ Inserted string ' ', cursor: (17, 5) -> (17, 6) =20 And that causes `wait_for` to think the "step" command is complete. This is wrong, as the prompt at line 17 isn't the prompt drawn after the completion of the "step" command. The subsequent tests now run with a partially updated screen (what is shown above) and obviously fail. =20 The ideal way to fix this would be for `wait_for` to be smarter, to avoid it confusing the different prompts drawn. =20 However, I would also like to reduce the variations in TUI test results due to the directories (source and build) in which tests are ran. TUI tests are more prone to differences in test results due to variations in directory names than other tests, as it makes curses take different redrawing decisions. So in this patch, I propose to make TUI tests use "set filename-display basename", which makes GDB omit directory names when it prints file names. This way, regardless of where you run the tests, you should get the same results (all other things being equal). =20 Doing this happens to fix my failures and makes my CI happy (which in turns makes me happy). To be clear, I understand that this does not fix the root issue of `proc wait_for` being confused. However, it makes TUI test runs be more similar for everyone, such that there's less chance of TUI tests randomly failing for somebody. If some other change triggers the `wait_for` problem again in the future, hopefully everybody will see the problem and we can work on getting it fixed more easily than if just one unlucky person sees the problem. =20 Note that there are other reasons why TUI tests could vary, like different curses library versions taking different re-drawing decisions. However, I think my change is a good step towards more stable test results. =20 [1] https://vt100.net/docs/vt510-rm/DL.html =20 Change-Id: Ib18da83317e7b78a46f77892af0d2e39bd261bf5 Diff: --- gdb/testsuite/lib/tuiterm.exp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index bf094131eac..6ca113fdd8e 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -757,9 +757,15 @@ namespace eval Term { # clean_restart. proc clean_restart {rows cols {executable {}}} { global env stty_init - save_vars {env(TERM) stty_init} { + save_vars {env(TERM) stty_init ::GDBFLAGS} { setenv TERM ansi _setup $rows $cols + + # Make GDB not print the directory names. Use this setting to + # remove the differences in test runs due to varying directory + # names. + append ::GDBFLAGS " -ex \"set filename-display basename\"" + if {$executable =3D=3D ""} { ::clean_restart } else {