From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26357 invoked by alias); 24 Jul 2002 17:29:08 -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 26349 invoked from network); 24 Jul 2002 17:29:06 -0000 Received: from unknown (HELO gash2.peakpeak.com) (207.174.178.17) by sources.redhat.com with SMTP; 24 Jul 2002 17:29:06 -0000 Received: from fleche.redhat.com (ta0207.peakpeak.com [204.144.244.207]) by gash2.peakpeak.com (8.9.3/8.9.3) with ESMTP id LAA31944; Wed, 24 Jul 2002 11:29:00 -0600 Received: by fleche.redhat.com (Postfix, from userid 1000) id C7E614F832D; Wed, 24 Jul 2002 11:34:03 -0600 (MDT) To: Elena Zannoni Cc: gdb-patches@sources.redhat.com Subject: Re: Patch: RFA: operate-and-get-next fix References: <87n0vtc1n2.fsf@creche.redhat.com> <15632.50715.850955.747717@localhost.redhat.com> <87y9c2573v.fsf@fleche.redhat.com> <15678.54268.874096.154108@localhost.redhat.com> <87it35ukud.fsf@fleche.redhat.com> <15678.57929.895918.500305@localhost.redhat.com> From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom X-Zippy: .. My pants just went on a wild rampage through a Long Island Bowling Alley!! Date: Wed, 24 Jul 2002 10:55:00 -0000 In-Reply-To: <15678.57929.895918.500305@localhost.redhat.com> Message-ID: <87fzy9t4hg.fsf@fleche.redhat.com> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-07/txt/msg00483.txt.bz2 >>>>> "Elena" == Elena Zannoni writes: Elena> Hey, just cut-n-paste what you wrote above. Seems pretty clear to me. Ok. How is the appended? Elena> you can commit the changes, however, the testsuite change....is Elena> Fernando's. Ok, I'll wait for his approval too. Tom Index: ChangeLog from Tom Tromey * defs.h (gdb_readline_wrapper): Declare. * utils.c (prompt_for_continue): Use gdb_readline_wrapper. * tracepoint.c (read_actions): Use gdb_readline_wrapper. * top.c (gdb_readline_wrapper): New function. (command_line_input): Use it. Index: defs.h =================================================================== RCS file: /cvs/src/src/gdb/defs.h,v retrieving revision 1.91 diff -u -r1.91 defs.h --- defs.h 21 Jun 2002 23:48:40 -0000 1.91 +++ defs.h 24 Jul 2002 17:27:20 -0000 @@ -535,6 +535,8 @@ extern char *gdb_readline (char *); +extern char *gdb_readline_wrapper (char *); + extern char *command_line_input (char *, int, char *); extern void print_prompt (void); Index: top.c =================================================================== RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.64 diff -u -r1.64 top.c --- top.c 11 Jul 2002 13:50:49 -0000 1.64 +++ top.c 24 Jul 2002 17:27:23 -0000 @@ -947,6 +947,29 @@ static int history_size; static char *history_filename; +/* This is like readline(), but it has some gdb-specific behavior. + gdb can use readline in both the synchronous and async modes during + a single gdb invocation. At the ordinary top-level prompt we might + be using the async readline. That means we can't use + rl_pre_input_hook, since it doesn't work properly in async mode. + However, for a secondary prompt (" >", such as occurs during a + `define'), gdb just calls readline() directly, running it in + synchronous mode. So for operate-and-get-next to work in this + situation, we have to switch the hooks around. That is what + gdb_readline_wrapper is for. */ +char * +gdb_readline_wrapper (char *prompt) +{ + /* Set the hook that works in this case. */ + if (event_loop_p && after_char_processing_hook) + { + rl_pre_input_hook = (Function *) after_char_processing_hook; + after_char_processing_hook = NULL; + } + + return readline (prompt); +} + #ifdef STOP_SIGNAL static void @@ -1174,7 +1197,7 @@ } else if (command_editing_p && instream == stdin && ISATTY (instream)) { - rl = readline (local_prompt); + rl = gdb_readline_wrapper (local_prompt); } else { Index: tracepoint.c =================================================================== RCS file: /cvs/src/src/gdb/tracepoint.c,v retrieving revision 1.39 diff -u -r1.39 tracepoint.c --- tracepoint.c 12 May 2002 04:20:06 -0000 1.39 +++ tracepoint.c 24 Jul 2002 17:27:25 -0000 @@ -854,7 +854,7 @@ line = (*readline_hook) (prompt); else if (instream == stdin && ISATTY (instream)) { - line = readline (prompt); + line = gdb_readline_wrapper (prompt); if (line && *line) /* add it to command history */ add_history (line); } Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/utils.c,v retrieving revision 1.72 diff -u -r1.72 utils.c --- utils.c 5 Apr 2002 16:39:11 -0000 1.72 +++ utils.c 24 Jul 2002 17:27:28 -0000 @@ -1603,7 +1603,7 @@ /* Call readline, not gdb_readline, because GO32 readline handles control-C whereas control-C to gdb_readline will cause the user to get dumped out to DOS. */ - ignore = readline (cont_prompt); + ignore = gdb_readline_wrapper (cont_prompt); if (annotation_level > 1) printf_unfiltered ("\n\032\032post-prompt-for-continue\n"); Index: testsuite/ChangeLog from Tom Tromey * gdb.base/readline.exp: New file. Index: testsuite/gdb.base/readline.exp =================================================================== RCS file: testsuite/gdb.base/readline.exp diff -N testsuite/gdb.base/readline.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/gdb.base/readline.exp 24 Jul 2002 17:27:42 -0000 @@ -0,0 +1,190 @@ +# Copyright 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Tom Tromey + +# This file is part of the gdb testsuite. + +# +# Tests for readline operations. +# + +# This function is used to test operate-and-get-next. +# NAME is the name of the test. +# ARGS is a list of alternating commands and expected results. +proc operate_and_get_next {name args} { + global gdb_prompt + + set my_gdb_prompt "($gdb_prompt| >)" + + set reverse {} + foreach {item result} $args { + verbose "sending $item" + sleep 1 + + # We can't use gdb_test here because we might see a " >" prompt. + set status 0 + send_gdb "$item\n" + gdb_expect { + -re "$item" { + # Ok + } + timeout { + set status 1 + } + } + + if {! $status} { + gdb_expect { + -re "$result" { + # Ok. + } + timeout { + set status 1 + } + } + } + + if {$status} { + fail "$name - send $item" + return 0 + } + pass "$name - send $item" + + set reverse [linsert $reverse 0 $item $result] + } + + # Now use C-p to go back to the start. + foreach {item result} $reverse { + # Actually send C-p followed by C-l. This lets us recognize the + # command when gdb prints it again. + send_gdb "\x10\x0c" + set status 0 + gdb_expect { + -re "$item" { + # Ok + } + timeout { + set status 1 + } + } + if {$status} { + fail "$name - C-p to $item" + return 0 + } + pass "$name - C-p to $item" + } + + # Now C-o through the list. Don't send the command, since it is + # already there. Strip off the first command from the list so we + # can see the next command inside the loop. + set count 0 + foreach {item result} $args { + set status 0 + + # If this isn't the first item, make sure we see the command at + # the prompt. + if {$count > 0} { + gdb_expect { + -re ".*$item" { + # Ok + } + timeout { + set status 1 + } + } + } + + if {! $status} { + # For the last item, send a simple \n instead of C-o. + if {$count == [llength $args] - 2} { + send_gdb "\n" + } else { + # 15 is C-o. + send_gdb [format %c 15] + } + set status 0 + gdb_expect { + -re "$result" { + # Ok + } + timeout { + set status 1 + } + } + } + + if {$status} { + fail "$name - C-o for $item" + return 0 + } + pass "$name - C-o for $item" + + set count [expr {$count + 2}] + } + + return 1 +} + + +if $tracelevel { + strace $tracelevel +} + +# Don't let a .inputrc file or an existing setting of INPUTRC mess up +# the test results. Even if /dev/null doesn't exist on the particular +# platform, the readline library will use the default setting just by +# failing to open the file. OTOH, opening /dev/null successfully will +# also result in the default settings being used since nothing will be +# read from this file. +global env +if [info exists env(INPUTRC)] { + set old_inputrc $env(INPUTRC) +} +set env(INPUTRC) "/dev/null" + +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +set oldtimeout1 $timeout +set timeout 30 + + +# A simple test of operate-and-get-next. +operate_and_get_next "Simple operate-and-get-next" \ + "p 1" ".* = 1" \ + "p 2" ".* = 2"\ + "p 3" ".* = 3" + +# Test operate-and-get-next with a secondary prompt. +operate_and_get_next "operate-and-get-next with secondary prompt" \ + "if 1 > 0" "" \ + "p 5" "" \ + "end" ".* = 5" + + +# Restore globals modified in this test... +if [info exists old_inputrc] { + set env(INPUTRC) $old_inputrc +} else { + unset env(INPUTRC) +} +set timeout $oldtimeout1 + +return 0