This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

Re: [patch] python prompt additions at first prompt.


Matt Rice <ratmice@gmail.com> writes:

> little bug with the new python prompt stuff, the prompt_hook doesn't
> take effect until the second prompt.

Thanks for doing this.  This looks fine to me, apart from one question.

For tests, there are prompt tests in the python.exp file for prompt
substitutions.  For passing arguments to GDB at start-up, see usage of
$GDBFLAGS in the testsuite.


> -     prompt, otherwise just print the prompt.  */
> -  if (async_command_editing_p)
> -    {
> -      int length;
> -      char *a_prompt;
> -      char *gdb_prompt = get_prompt (0);
> -
> -      /* Tell readline what the prompt to display is and what function
> -         it will need to call after a whole line is read.  This also
> -         displays the first prompt.  */
> -      length = strlen (get_prefix (0))
> -	+ strlen (gdb_prompt) + strlen (get_suffix(0)) + 1;
> -      a_prompt = (char *) alloca (length);
> -      strcpy (a_prompt, get_prefix (0));
> -      strcat (a_prompt, gdb_prompt);
> -      strcat (a_prompt, get_suffix (0));
> -      rl_callback_handler_install (a_prompt, input_handler);
> -    }
> -  else
> -    display_gdb_prompt (0);
> +  display_gdb_prompt (0);


display_gdb_prompt removes any handler that is present, and then
installs a handler.  As this is the first prompt, the above code does
not (because there could not have been a handler installed).  I think
attempting to remove a handler that does not exist just results in a
NOOP, but it is worth checking.  I know very little about readline,
however.  So my question is: with GDB's copy of readline, is this okay?
  
Cheers

Phil


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