- /* Just use the top of the prompt stack. */
- prompt_length = strlen (PREFIX (0)) +
- strlen (SUFFIX (0)) +
- strlen (gdb_prompt) + 1;
-
- new_prompt = (char *) alloca (prompt_length);
-
- /* Prefix needs to have new line at end. */
- strcpy (new_prompt, PREFIX (0));
- strcat (new_prompt, gdb_prompt);
- /* Suffix needs to have a new line at end and \032 \032 at
- beginning. */
- strcat (new_prompt, SUFFIX (0));
+ if (sync_execution)
+ {
+ /* This is to trick readline into not trying to display the
+ prompt. Even though we display the prompt using this
+ function, readline still tries to do its own display if
+ we don't call rl_callback_handler_install and
+ rl_callback_handler_remove (which readline detects
+ because a global variable is not set). If readline did
+ that, it could mess up gdb signal handlers for SIGINT.
+ Readline assumes that between calls to rl_set_signals and
+ rl_clear_signals gdb doesn't do anything with the signal
+ handlers. Well, that's not the case, because when the
+ target executes we change the SIGINT signal handler. If
+ we allowed readline to display the prompt, the signal
+ handler change would happen exactly between the calls to
+ the above two functions. Calling
+ rl_callback_handler_remove(), does the job. */
+
+ rl_callback_handler_remove ();
+ do_cleanups (old_chain);
+ return;
+ }
+ else
+ {
+ /* Display the top level prompt. */
+ actual_gdb_prompt = top_level_prompt ();
+ }