* [Bug gdb/27156] gdb.tui/tui-missing-src.exp is unstable
2021-01-07 15:33 [Bug gdb/27156] New: gdb.tui/tui-missing-src.exp is unstable simark at simark dot ca
2021-01-07 15:33 ` [Bug gdb/27156] " simark at simark dot ca
2021-01-07 15:33 ` simark at simark dot ca
@ 2021-01-08 23:45 ` simark at simark dot ca
2 siblings, 0 replies; 4+ messages in thread
From: simark at simark dot ca @ 2021-01-08 23:45 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27156
--- Comment #3 from Simon Marchi <simark at simark dot ca> ---
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 figured
out what happens.
Tip: when using the patch above, use "make check-read1", that makes the output
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-missing-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-missing-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-missing-src/
main.c:6
(gdb)
--->8---
If you're wondering what's up with those paths, it's because the issue happens
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-missing-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-missing-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-missing-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-missing-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-missing-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 breakpoint
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 "inferior"
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 <unistd.h>
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 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | [ No Source Available ]
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14
+------------------------------------------------------------------------------+
15 exec No process In: L??
PC: ??
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 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/gdb/tes
22 tsuite/outputs/gdb.tui/tui-missing-src/tui-missing-src
23 next
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread