From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10516 invoked by alias); 19 Jun 2002 17:58:36 -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 10402 invoked from network); 19 Jun 2002 17:58:33 -0000 Received: from unknown (HELO cygnus.com) (205.180.83.203) by sources.redhat.com with SMTP; 19 Jun 2002 17:58:33 -0000 Received: from localhost.redhat.com (remus.sfbay.redhat.com [172.16.27.252]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id KAA05457; Wed, 19 Jun 2002 10:58:31 -0700 (PDT) Received: by localhost.redhat.com (Postfix, from userid 469) id 49276107D4; Wed, 19 Jun 2002 13:57:48 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15632.50715.850955.747717@localhost.redhat.com> Date: Wed, 19 Jun 2002 10:58:00 -0000 To: tromey@redhat.com Cc: gdb-patches@sources.redhat.com Subject: Re: Patch: RFA: operate-and-get-next fix In-Reply-To: <87n0vtc1n2.fsf@creche.redhat.com> References: <87n0vtc1n2.fsf@creche.redhat.com> X-SW-Source: 2002-06/txt/msg00373.txt.bz2 Tom Tromey writes: > This patch fixes a recently-discovered problem with operate-and-get-next. > > The problem is that C-o doesn't work when entering breakpoint > commands. The user expects this to work, since such commands are > entered into the readline history. Also, this is a very useful place > for C-o to work. > > Unfortunately, this patch is a bit ugly. The problem here is that we > need to use one of two different hooks, depending on the way that > readline is called. But we can't know that in advance, since some > commands will call readline() even when event_loop_p is true. > > So we route all calls to readline() through a wrapper function that > rearranges the hook values if required. > > A better fix would be to change readline so that rl_pre_input_hook > works correctly even in the event-loop mode. I believe I mentioned > this during the discussions of the original operate-and-get-next patch. > (I definitely don't have the time to investigate doing that. Last > time I looked at it but it seemed like a real quagmire.) > > Built and tested on x86 Red Hat Linux 6.2. > I tried it using things like: > > if 2 > 1 > p 5 > end > > Any comments? > Is this ok to commit? > > 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.88 > diff -u -r1.88 defs.h > --- defs.h 18 Apr 2002 18:08:59 -0000 1.88 > +++ defs.h 24 Apr 2002 01:28:05 -0000 > @@ -525,6 +525,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.61 > diff -u -r1.61 top.c > --- top.c 28 Mar 2002 01:35:55 -0000 1.61 > +++ top.c 24 Apr 2002 01:28:12 -0000 > @@ -947,6 +947,28 @@ > static int history_size; > static char *history_filename; > > +/* This is like readline(), but it has some gdb-specific behavior. In > + particular, if the user is in the middle of an > + operate-and-get-next, we shuffle the hooks around so that the > + expected result occurs. This is ugly, but it is inevitable given > + that gdb switches between the two modes (async and not) of using > + readline and that rl_pre_input_hook doesn't work properly in async > + mode. */ > +char * > +gdb_readline_wrapper (char *prompt) > +{ > + char *result; > + > + /* Set the hook that works in this case. */ > + if (event_loop_p && after_char_processing_hook) > + { > + rl_pre_input_hook = after_char_processing_hook; > + after_char_processing_hook = NULL; > + } > + > + result = readline (prompt); > +} > + Sorry for the delay in looking at this. Shouldn't gdb_readline_wrapper return the result? This stuff is getting impossibly convoluted. :-( Could you come up with a testcase to add to the testsuite? Elena > > #ifdef STOP_SIGNAL > static void > @@ -1174,7 +1196,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.36 > diff -u -r1.36 tracepoint.c > --- tracepoint.c 27 Mar 2002 21:35:35 -0000 1.36 > +++ tracepoint.c 24 Apr 2002 01:28:14 -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 Apr 2002 01:28:15 -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");