[gdb/testsuite] Simplify gdb.dwarf2/locexpr-data-member-location.exp

Message ID 20210905063948.GA22464@delia
State New
Headers show
Series
  • [gdb/testsuite] Simplify gdb.dwarf2/locexpr-data-member-location.exp
Related show

Commit Message

Tom de Vries via Gdb-patches Sept. 5, 2021, 6:39 a.m.
Hi,

The test-case gdb.dwarf2/locexpr-data-member-location.exp currently fails like
this:
...
FAIL: gdb.dwarf2/locexpr-data-member-location.exp: running to bar in runto \
  (GDB internal error)
ERROR: : spawn id exp9 not open
    while executing
"expect {
-i exp9 -timeout 10
            -re "Quit this debugging session\\? \\(y or n\\) $" {
                send_gdb "n\n" answer
                incr count
            }
            -re "Create ..."
    ("uplevel" body line 1)
    invoked from within
"uplevel $body" NONE : spawn id exp9 not open
ERROR: Could not resync from internal error (timeout)
...
and takes 1 minute to run.

The long running time is caused by the timeout of 60 in gdb_run_cmd.

Avoid this by simplify the test-case to trigger the same assert using the file
command instead.

Then fix the:
...
ERROR: : spawn id exp9 not open
...
by handling eof in gdb_internal_error_resync.

Finally, mark the FAIL as KFAIL, such that we end up with:
...
KFAIL: gdb.dwarf2/locexpr-data-member-location.exp: Discard file \
  (GDB internal error) (PRMS: gdb/28030)
ERROR: Could not resync from internal error (eof)
...
and a running time of 2 seconds.

Tested on x86_64-linux.

Any comments?

Thanks,
- Tom

[gdb/testsuite] Simplify gdb.dwarf2/locexpr-data-member-location.exp

---
 .../gdb.dwarf2/locexpr-data-member-location.exp    | 23 ++++++++++++++++------
 gdb/testsuite/lib/gdb.exp                          |  4 ++++
 2 files changed, 21 insertions(+), 6 deletions(-)

Comments

Tom de Vries via Gdb-patches Sept. 7, 2021, 8:52 a.m. | #1
On 9/5/21 8:39 AM, Tom de Vries wrote:
> Avoid this by simplify the test-case to trigger the same assert using the file

> command instead.


FTR, after the other commits this is what remains.

At this point, I don't see a pressing reason for why this should be
committed.  But perhaps somebody else does.

Thanks,
- Tom
[gdb/testsuite] Simplify gdb.dwarf2/locexpr-data-member-location.exp

When reverting commit 5a20fadc841 the test-case
gdb.dwarf2/locexpr-data-member-location.exp runs into an internal-error.

Simplify the test-case by triggering the internal-error using gdb_unload
instead of runto "bar".

Tested on x86_64-linux.

---
 gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
index 1f70e6a34bd..98f9270d7bb 100644
--- a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
+++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
@@ -40,7 +40,7 @@
 #    purging of shared objects.
 #
 # 3) After performing some simple gdb commands, the program is
-#    run again.  In the course of running the objfile destructor
+#    discarded.  In the course of running the objfile destructor
 #    associated with the shared object, values are preserved
 #    along with their types.  As noted earlier, it was during
 #    the recursive type copy that the bug was observed.
@@ -342,8 +342,7 @@ gdb_test "step" "bar \\(.*" "step into bar"
 
 # We don't want a clean restart here since that will be too clean.
 # The original reproducer for PR28030 set a breakpoint in the shared
-# library and then restarted via "run".  The command below does roughly
-# the same thing.  It's at this step that an internal error would
-# occur for PR28030.  The "message" argument tells runto to turn on
-# the printing of PASSes while runto is doing its job.
-runto "bar" message
+# library and then restarted via "run".  The command below is more minimal:
+# it discards executable file and symbol table.  It's at the latter step
+# that an internal error would occur for PR28030.
+gdb_unload
Tom de Vries via Gdb-patches Sept. 8, 2021, 12:34 a.m. | #2
On 2021-09-07 4:52 a.m., Tom de Vries wrote:
> On 9/5/21 8:39 AM, Tom de Vries wrote:

>> Avoid this by simplify the test-case to trigger the same assert using the file

>> command instead.

> 

> FTR, after the other commits this is what remains.

> 

> At this point, I don't see a pressing reason for why this should be

> committed.  But perhaps somebody else does.

> 

> Thanks,

> - Tom

> 


Well, we shouldn't have to add a kfail, the problem is that the test has
been pushed without the fix:

  https://sourceware.org/pipermail/gdb-patches/2021-August/181771.html

Simon

Patch

diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
index 1f70e6a34bd..9423132e775 100644
--- a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
+++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
@@ -40,7 +40,7 @@ 
 #    purging of shared objects.
 #
 # 3) After performing some simple gdb commands, the program is
-#    run again.  In the course of running the objfile destructor
+#    discarded.  In the course of running the objfile destructor
 #    associated with the shared object, values are preserved
 #    along with their types.  As noted earlier, it was during
 #    the recursive type copy that the bug was observed.
@@ -342,8 +342,19 @@  gdb_test "step" "bar \\(.*" "step into bar"
 
 # We don't want a clean restart here since that will be too clean.
 # The original reproducer for PR28030 set a breakpoint in the shared
-# library and then restarted via "run".  The command below does roughly
-# the same thing.  It's at this step that an internal error would
-# occur for PR28030.  The "message" argument tells runto to turn on
-# the printing of PASSes while runto is doing its job.
-runto "bar" message
+# library and then restarted via "run".  The command below is more minimal:
+# it discards executable file and symbol table.  It's at the latter step
+# that an internal error would occur for PR28030.
+
+# Avoid questions from the file command about:
+# - Are you sure you want to change the file (y or n) ?
+# - Discard symbol table from <file> (y or n) ?
+gdb_test_no_output "set confirm off"
+
+# Tell internal-error how to behave, otherwise "set confirm off" will trigger
+# generation of core file.
+gdb_test_no_output "maint set internal-error quit no"
+gdb_test_no_output "maint set internal-error corefile no"
+
+setup_kfail gdb/28030 *-*-*
+gdb_test "file" "No executable file now\\." "Discard file"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 00336bd588e..cdda51529fb 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -770,6 +770,10 @@  proc gdb_internal_error_resync {} {
 		perror "Could not resync from internal error (timeout)"
 		return 0
 	    }
+	    eof {
+		perror "Could not resync from internal error (eof)"
+		return 0
+	    }
 	}
     }
     perror "Could not resync from internal error (resync count exceeded)"