[PATCH]: TUI, secondary prompts do not work

Ton van Overbeek v-overbeek@cistron.nl
Tue Oct 1 07:03:00 GMT 2002


I have been following the TUI developments on the gdb-5.3 branch.
My interest is in using TUI for a cross debugger (m68k-palmos, see
http://prc-tools.sourceforge.net).
I found some problems with the current state of the TUI.

This post is concerned with secondary prompts.
When tui is active, secondary prompts do not work.
Try to do a command with many lines of output, i.e. 'show copying'.
You will not get the '---Type <return> to continue, or q <return> to quit---'
prompt, but just the normal (gdb) prompt.
Same is true when prompting for commands in the 'commands' command
for commands to be executed at a breakpoint.
Tui relies on the prompt stack. However this stack is not used
for these cases. I 'fixed' it by adding a push_prompt/pop_prompt
pair around the readline() call in gdb_readline_wrapper.
Also had to fix the pop_prompt logic for the changing annotation level
case as a consequence.

I do not know if this has repercussions in other areas of gdb, so I
happily accept criticisms or proposals to fix this in a better way.

Here is the Changelog entry for my fix (and patch attached).
Diff is against the branch snapshot from today (2002-10-01).

2002-10-01	Ton van Overbeek (v-overbeek@cistron.nl)
	* event-top.h: Introduced change_annotation_level parameter to
	pop_prompt ().
	* event-top.c (pop_prompt): Added change_annotation_level parameter.
	(change_annotation_level, async_enable_stdin, command_line_handler):
	Use new parameter in pop_prompt.
	* top.c (gdb_readline_wrapper): Added push-prompt/pop_prompt pair
	around readline call for tui secondary prompts to work.

I hope this patch is accepted. If I need to complete a copyright
assignment for this, let me know.

Ton van Overbeek
-------------- next part --------------
--- event-top.c.orig	2002-07-03 22:27:12.000000000 +0200
+++ event-top.c	2002-09-22 12:39:54.000000000 +0200
@@ -350,7 +350,7 @@ change_annotation_level (void)
       if (strcmp (PREFIX (0), "") && strcmp (SUFFIX (0), ""))
 	{
 	  /* Pop the top of the stack, we are going back to annotation < 1. */
-	  pop_prompt ();
+	  pop_prompt (1);
 	}
     }
 }
@@ -378,11 +378,11 @@ push_prompt (char *prefix, char *prompt,
 
 /* Pops the top of the prompt stack, and frees the memory allocated for it. */
 void
-pop_prompt (void)
+pop_prompt (int change_annotation_level)
 {
   /* If we are not during a 'synchronous' execution command, in which
      case, the top prompt would be empty. */
-  if (strcmp (PROMPT (0), ""))
+  if (change_annotation_level && strcmp (PROMPT (0), ""))
     /* This is for the case in which the prompt is set while the
        annotation level is 2. The top prompt will be changed, but when
        we return to annotation level < 2, we want that new prompt to be
@@ -430,7 +430,7 @@ async_enable_stdin (void *dummy)
      sync_execution.  Current target_terminal_ours() implementations
      check for sync_execution before switching the terminal. */
   target_terminal_ours ();
-  pop_prompt ();
+  pop_prompt (0);
   sync_execution = 0;
 }
 
@@ -636,7 +636,7 @@ command_line_handler (char *rl)
       p = readline_input_state.linebuffer_ptr;
       xfree (readline_input_state.linebuffer);
       more_to_come = 0;
-      pop_prompt ();
+      pop_prompt (0);
     }
 
 #ifdef STOP_SIGNAL
--- event-top.h.orig	2001-11-27 05:15:10.000000000 +0100
+++ event-top.h	2002-09-22 12:37:44.000000000 +0200
@@ -88,7 +88,7 @@ extern void handle_stop_sig (int sig);
 #endif
 #endif
 extern void handle_sigint (int sig);
-extern void pop_prompt (void);
+extern void pop_prompt (int change_annotation_level);
 extern void push_prompt (char *prefix, char *prompt, char *suffix);
 extern void gdb_readline2 (void *client_data);
 extern void mark_async_signal_handler_wrapper (void *token);
--- top.c.orig	2002-09-15 01:32:00.000000000 +0200
+++ top.c	2002-09-22 12:42:16.000000000 +0200
@@ -960,6 +960,8 @@ static char *history_filename;
 char *
 gdb_readline_wrapper (char *prompt)
 {
+  char *ret;
+
   /* Set the hook that works in this case.  */
   if (event_loop_p && after_char_processing_hook)
     {
@@ -967,7 +969,11 @@ gdb_readline_wrapper (char *prompt)
       after_char_processing_hook = NULL;
     }
 
-  return readline (prompt);
+  push_prompt ("", prompt, "");
+  ret = readline (prompt);
+  pop_prompt (0);
+
+  return ret;
 }
 
 


More information about the Gdb-patches mailing list