This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gdb patch to suppress empty lines



Per, 

I would prefer to hold off on these, because of the changes I am
making to accomodate asynchronous behaviour for gdb. The command_loop
function in top.c is about to become obsolete, and it would be better
to think about a mechanism that works with the new event-loop and the
asynchronous interface to readline.  Take a look at event-top.c.

Thanks
Elena

Per Bothner writes:
 > Here is a simple patch which improves the command line interface of gdb.
 > If you repeat a command, by submitting an empty line, then normally
 > will show a lot of useless lines containing only the command prompt.
 > After an x/i followed by two empty lines, we get:
 > 
 > (gdb) x/i $pc
 > 0xe1038 <main+8>:       call  0x138818 <get_run_time>
 > (gdb) 
 > 0xe103c <main+12>:      st  %i1, [ %fp + 0x48 ]
 > (gdb) 
 > 0xe1040 <main+16>:      st  %o0, [ %fp + -464 ]
 > (gdb) 
 > 
 > This wastes a lot of screen real estate, and is harder to read.
 > *With* my patches, we instead get:
 > 
 > (gdb) x/i $pc
 > 0xe1038 <main+8>:       call  0x138818 <get_run_time>
 > 0xe103c <main+12>:      st  %i1, [ %fp + 0x48 ]
 > 0xe1040 <main+16>:      st  %o0, [ %fp + -464 ]
 > (gdb)
 > 
 > If you type another empty line (<Enter> only), then the "(gdb) " prompt
 > is erased, and replaced by the dis-assembled following line.
 > 
 > Index: top.c
 > ===================================================================
 > RCS file: /cvs/cvsfiles/devo/gdb/top.c,v
 > retrieving revision 2.109
 > diff -u -p -r2.109 top.c
 > --- top.c	1999/05/06 16:42:34	2.109
 > +++ top.c	1999/05/13 20:30:59
 > @@ -2122,7 +2122,12 @@ command_line_input (prrompt, repeat, ann
 >  	}
 >        else if (command_editing_p && instream == stdin && ISATTY (instream))
 >  	{
 > +	  int can_repeat = *line != 0;
 > +	  if (can_repeat)
 > +	    rl_erase_empty_line++;
 >  	  rl = readline (local_prompt);
 > +	  if (can_repeat)
 > +	    rl_erase_empty_line--;
 >  	}
 >        else
 >  	{
 > 
 > The patches does require that reeadline be updated.  Either update
 > to the current version, or apply the following patch.
 > 
 > Index: display.c
 > ===================================================================
 > RCS file: /cvs/cvsfiles/devo/readline/display.c,v
 > retrieving revision 1.15
 > diff -u -p -r1.15 display.c
 > --- display.c	1999/03/23 15:57:41	1.15
 > +++ display.c	1999/05/13 20:30:08
 > @@ -1564,3 +1564,12 @@ _rl_clean_up_for_exit ()
 >        rl_restart_output ();
 >      }
 >  }
 > +
 > +void
 > +_rl_erase_entire_line ()
 > +{
 > +  cr ();
 > +  _rl_clear_to_eol (0);
 > +  cr ();
 > +  fflush (rl_outstream);
 > +}
 > Index: readline.c
 > ===================================================================
 > RCS file: /cvs/cvsfiles/devo/readline/readline.c,v
 > retrieving revision 1.47
 > diff -u -p -r1.47 readline.c
 > --- readline.c	1998/12/22 21:53:32	1.47
 > +++ readline.c	1999/05/13 20:30:09
 > @@ -286,6 +286,9 @@ char *_rl_comment_begin;
 >  /* Keymap holding the function currently being executed. */
 >  Keymap rl_executing_keymap;
 >  
 > +/* Non-zero means to erase entire line, including prompt, on empty input lines. */
 > +int rl_erase_empty_line = 0;
 > +
 >  /* Line buffer and maintenence. */
 >  char *rl_line_buffer = (char *)NULL;
 >  int rl_line_buffer_len = 0;
 > @@ -488,6 +491,12 @@ readline_internal_charloop ()
 >        if (rl_done == 0)
 >  	(*rl_redisplay_function) ();
 >  
 > +      /* If the application writer has told us to erase the entire line if
 > +	  the only character typed was something bound to rl_newline, do so. */
 > +      if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
 > +	  rl_point == 0 && rl_end == 0)
 > +	_rl_erase_entire_line ();
 > +
 >  #if defined (READLINE_CALLBACKS)
 >        return 0;
 >  #else
 > @@ -1427,6 +1436,11 @@ rl_newline (count, key)
 >        _rl_vi_reset_last ();
 >      }
 >  #endif /* VI_MODE */
 > +
 > +  /* If we've been asked to erase empty lines, suppress the final update,
 > +     since _rl_update_final calls crlf(). */
 > +  if (rl_erase_empty_line && rl_point == 0 && rl_end == 0)
 > +    return 0;
 >  
 >    if (readline_echoing_p)
 >      _rl_update_final ();
 > Index: readline.h
 > ===================================================================
 > RCS file: /cvs/cvsfiles/devo/readline/readline.h,v
 > retrieving revision 1.12
 > diff -u -p -r1.12 readline.h
 > --- readline.h	1998/12/22 21:53:33	1.12
 > +++ readline.h	1999/05/13 20:30:09
 > @@ -288,6 +288,12 @@ extern VFunction *rl_deprep_term_functio
 >  extern Keymap rl_executing_keymap;
 >  extern Keymap rl_binding_keymap;
 >  
 > +/* Display variables. */
 > +/* If non-zero, readline will erase the entire line, including any prompt,
 > +   if the only thing typed on an otherwise-blank line is something bound to
 > +   rl_newline. */
 > +extern int rl_erase_empty_line;
 > +
 >  /* Completion variables. */
 >  /* Pointer to the generator function for completion_matches ().
 >     NULL means to use filename_entry_function (), the default filename
 > 
 > I can install these, if there are no objections.
 > 
 > 	--Per Bothner
 > bothner@cygnus.com     http://www.cygnus.com/~bothner
 > 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]