+ 1. When the user enters a command line which is ended by '\'
+ indicating that the command will continue on the next line. In
+ that case the prompt that is displayed is the empty string.
+
+ 2. When the user is entering 'commands' for a breakpoint, or
+ actions for a tracepoint. In this case the prompt will be '>'
+
+ 3. On prompting for pagination. */
+
+void
+display_gdb_prompt (const char *new_prompt)
+{
+ char *actual_gdb_prompt = NULL;
+ struct cleanup *old_chain;
+
+ annotate_display_prompt ();
+
+ /* Reset the nesting depth used when trace-commands is set. */
+ reset_command_nest_depth ();
+
+ old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
+
+ /* Do not call the python hook on an explicit prompt change as
+ passed to this function, as this forms a secondary/local prompt,
+ IE, displayed but not set. */
+ if (! new_prompt)
+ {
+ 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. */
+
+ gdb_rl_callback_handler_remove ();
+ do_cleanups (old_chain);
+ return;
+ }
+ else
+ {
+ /* Display the top level prompt. */
+ actual_gdb_prompt = top_level_prompt ();
+ }