From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id BAE85385DC14; Thu, 4 Jun 2020 14:33:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BAE85385DC14 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Fix error handling in gdb_file_cmd X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: d8740be15930b820ab51d7a76695194022a83551 X-Git-Newrev: 95146b5da22532c6688e457adb48fecbceb194b3 Message-Id: <20200604143357.BAE85385DC14@sourceware.org> Date: Thu, 4 Jun 2020 14:33:57 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2020 14:33:57 -0000 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=95146b5da22532c6688e457adb48fecbceb194b3 commit 95146b5da22532c6688e457adb48fecbceb194b3 Author: Tom de Vries Date: Thu Jun 4 16:33:55 2020 +0200 [gdb/testsuite] Fix error handling in gdb_file_cmd Consider a gdb_load patch to call the gdb_file_cmd twice: ... proc gdb_load { arg } { if { $arg != "" } { + set res [gdb_file_cmd $arg] + if { $res != 0 } { + return $res + } return [gdb_file_cmd $arg] } return 0 } ... When running test-case gdb.base/index-cache.exp, we run into: ... ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache, other program \ already loaded (timeout). FAIL: gdb.base/index-cache.exp: test_cache_enabled_miss: check index-cache \ stats (GDB internal error) ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache, other program \ already loaded (timeout). ... The first timeout in more detail: ... (gdb) file outputs/gdb.base/index-cache/index-cache^M Load new symbol table from "index-cache"? (y or n) y^M Reading symbols from index-cache...^M src/gdb/dwarf2/read.c:2540: internal-error: \ void create_cus_from_index(dwarf2_per_bfd*, const gdb_byte*, offset_type, \ const gdb_byte*, offset_type): \ Assertion `per_bfd->all_comp_units.empty ()' failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) ERROR: Couldn't load index-cache, \ other program already loaded (timeout). ... Proc gdb_file_cmd has a gdb_expect handling the result of the file command, and if the result is a "Load new symbol table from index-cache? (y or n) " prompt, it sends a "y" and enters in a nested gdb_expect to handle the result. The first gdb_expect contains code to handle "A problem internal to GDB has been detected", but the second one doesn't, which causes the timeout. Fix this by removing the nested gdb_expect, and using exp_continue instead, such that we have instead: ... ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache -- with new \ symbol table into gdb (GDB internal error). ERROR: Couldn't load outputs/gdb.base/index-cache/index-cache -- with new \ symbol table into gdb (GDB internal error). ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-06-04 Tom de Vries * lib/gdb.exp (gdb_file_cmd): Replace incomplete gdb_expect by exp_continue. Diff: --- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/lib/gdb.exp | 23 ++++++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ab9443eceb7..9d979382c36 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-06-04 Tom de Vries + + * lib/gdb.exp (gdb_file_cmd): Replace incomplete gdb_expect by + exp_continue. + 2020-06-04 Tom de Vries * lib/gdb.exp (gdb_file_cmd): Use perror instead of fail. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 63a9e3da535..3cdaefaa9cd 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1761,6 +1761,7 @@ proc gdb_file_cmd { arg } { } send_gdb "file $arg\n" + set new_symbol_table 0 gdb_expect 120 { -re "Reading symbols from.*LZMA support was disabled.*$gdb_prompt $" { verbose "\t\tLoaded $arg into $GDB; .gnu_debugdata found but no LZMA available" @@ -1778,22 +1779,14 @@ proc gdb_file_cmd { arg } { return 0 } -re "Load new symbol table from \".*\".*y or n. $" { + if { $new_symbol_table > 0 } { + perror "Couldn't load $arg, interactive prompt loop detected." + return -1 + } send_gdb "y\n" answer - gdb_expect 120 { - -re "Reading symbols from.*$gdb_prompt $" { - verbose "\t\tLoaded $arg with new symbol table into $GDB" - set gdb_file_cmd_debug_info "debug" - return 0 - } - timeout { - perror "Couldn't load $arg, other program already loaded (timeout)." - return -1 - } - eof { - perror "Couldn't load $arg, other program already loaded (eof)." - return -1 - } - } + incr new_symbol_table + set arg "$arg -- with new symbol table" + exp_continue } -re "No such file or directory.*$gdb_prompt $" { perror "($arg) No such file or directory"