From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27440 invoked by alias); 4 Feb 2003 22:33:58 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 27433 invoked from network); 4 Feb 2003 22:33:57 -0000 Received: from unknown (HELO zenia.red-bean.com) (66.244.67.22) by 172.16.49.205 with SMTP; 4 Feb 2003 22:33:57 -0000 Received: from zenia.red-bean.com (localhost.localdomain [127.0.0.1]) by zenia.red-bean.com (8.12.5/8.12.5) with ESMTP id h14MOv8A012949; Tue, 4 Feb 2003 17:24:58 -0500 Received: (from jimb@localhost) by zenia.red-bean.com (8.12.5/8.12.5/Submit) id h14MOuTI012945; Tue, 4 Feb 2003 17:24:56 -0500 To: Fernando Nasser Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: add testsuite function for answering internal error questions References: <3DECE5AB.8020400@redhat.com> <3E245BC9.6020302@redhat.com> From: Jim Blandy Date: Tue, 04 Feb 2003 22:33:00 -0000 In-Reply-To: <3E245BC9.6020302@redhat.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.92 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-02/txt/msg00152.txt.bz2 Fernando Nasser writes: > > The idea is excellent, we should have thought of this before. > > I need you to make a couple of changes before checking it in, if you > > don't mind: > > 1) > > fail "$testname (internal error resync timeout)" > > should actually be > > perror "Could not resync from internal error (timeout)" > > It is a test harness failure if we were not able to resync and GDB > > cannot be no lonmger used for testing. This will properly make all > > tests to be unresolved until gdb is restarted. > > Note that I've also got ridden of the TESTNAME argument as well. > > The test itself has been marked as failed already since an internal > > error was raised. We we fail to resynch we can just issue a > > constant message like: > > ERROR: Could not resync from internal error (timeout) Okay, I've made that change. > > 2) Please get rid of the global variable. You can just do: > > > + -re ".*A problem internal to GDB has been detected" { > > > + # The pattern above must be set up to match the > > > + # internal error message, but none of the questions > > > + # that follow it > > > + fail "$message" > > > + gdb_internal_error_resync > > > + } The reason I put the global variable there is that people may want to use gdb_internal_error_resync in their own gdb_expect constructs, when they're not using gdb_test or gdb_test_multiple. If GDB changes the way it reports internal errors, the regexp will need to change, too, so I thought it was worthwhile to define it in one place, and then have everyone use it. The comments for gdb_internal_error_resync explain this. Here's the patch, adapted to the current sources (esp. the introduction of gdb_test_multiple): 2003-02-04 Jim Blandy * lib/gdb.exp (gdb_internal_error_regexp): New variable. (gdb_internal_error_resync): New procedure. (gdb_test_multiple): If the command results in an internal error, answer GDB's questions until we get back to a prompt. Index: gdb/testsuite/lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.34 diff -c -r1.34 gdb.exp *** gdb/testsuite/lib/gdb.exp 31 Jan 2003 00:38:33 -0000 1.34 --- gdb/testsuite/lib/gdb.exp 4 Feb 2003 22:31:28 -0000 *************** *** 360,365 **** --- 360,416 ---- } + # A regular expression matching the output GDB produces when it + # reports an internal error. + set gdb_internal_error_regexp ".*A problem internal to GDB has been detected" + + + # gdb_internal_error_resync + # + # Answer the questions GDB asks after it reports an internal error + # until we get back to a GDB prompt. Decline to quit the debugging + # session, and decline to create a core file. If we're unable to + # resync, then report an error using 'perror', to abort the rest of + # the test script. + # + # This procedure just answers whatever questions come up until it sees + # a GDB prompt; it doesn't require you to have matched the input up to + # any specific point. However, it only answers questions it sees in + # the output itself, so if you've matched a question, you had better + # answer it yourself before calling this. + # + # The variable `gdb_internal_error_regexp' is set up to match the + # internal error message, but none of the questions that follow it, so + # you can write code like this: + # + # gdb_expect { + # ... + # -re $gdb_internal_error_regexp { + # gdb_internal_error_resync "$message (internal error)" + # } + # ... + # } + proc gdb_internal_error_resync {} { + global gdb_prompt + + gdb_expect { + -re "Quit this debugging session\\? \\(y or n\\) $" { + send_gdb "n\n" + exp_continue + } + -re "Create a core file of GDB\\? \\(y or n\\) $" { + send_gdb "n\n" + exp_continue + } + -re "$gdb_prompt $" { + # We're resynchronized. + } + timeout { + perror "Could not resync from internal error (timeout)" + } + } + } + # gdb_test_multiple COMMAND MESSAGE EXPECT_ARGUMENTS # Send a command to gdb; test the result. *************** *** 383,388 **** --- 434,440 ---- global verbose global gdb_prompt global GDB + global gdb_internal_error_regexp upvar timeout timeout if { $message == "" } { *************** *** 511,516 **** --- 563,572 ---- } set code { + -re $gdb_internal_error_regexp { + fail "$message (GDB internal error)" + gdb_internal_error_resync + } -re "\\*\\*\\* DOSEXIT code.*" { if { $message != "" } { fail "$message";