This is the mail archive of the gdb-patches@sources.redhat.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]

[RFA] A few ui_out formatting bugs with commands-on-breakpoints


Hi, it looks like there were a few small oversights in the ui
support of printing-commands-on-breakpoints.  With the current gdb,
you enter these commands:

   (gdb) b main
   (gdb) comm
   > if $testval == 0
    >   print "true"
    > else
    >   print "false"
    > end
   > print "done"
   > end
   (gdb)

And this is how it's printed:

   (gdb) info br
   Num Type           Disp Enb Address    What
   1   breakpoint     keep y   0x08071a9e in main at ../../src3/gdb/main.c:714
           if if $testval == 0
             print "true"
           elseelse
             print "false"
   end        end
           print "done"
   (gdb)

Not quite ideal. :-)  With the attached patch, the output is

   (gdb) info br
   Num Type           Disp Enb Address    What
   1   breakpoint     keep y   0x08070f30 in captured_command_loop
                                          at ../../src2/gdb/main.c:1
           if $testval == 0
             print "true"
           else
             print "false"
           end
           print "done"
   (gdb)

The 'while' command has a similar problem.  There aren't any
testsuite regressions with this change.

My only concern is that I'm unfamiliar with the UI_OUT suite of
functions.  Are certain ui_out functions are preferred over others?
For instance, we have "end" printed out by both ui_out_field_string()
and by ui_out_text().  I removed the first occurrence in each case,
but who knows, maybe there's a reason to do it the other way.  From
what I can tell in the uiout doco, it's six of one and half a dozen
of the other.

Jason
2001-09-07  Jason Molenda  (jason-gdb-cl@molenda.com)

	* cli-script.c (print_command_lines): Fix double printing of
	'if', 'while', 'else', and 'end'; correct typeo in comment.

Index: cli-script.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-script.c,v
retrieving revision 1.7
diff -u -p -r1.7 cli-script.c
--- cli-script.c	2001/06/17 15:16:12	1.7
+++ cli-script.c	2001/09/08 06:31:04
@@ -171,11 +171,9 @@ print_command_lines (struct ui_out *uiou
       /* A while command.  Recursively print its subcommands and continue.  */
       if (list->control_type == while_control)
 	{
-	  ui_out_text (uiout, "while ");
 	  ui_out_field_fmt (uiout, NULL, "while %s", list->line);
 	  ui_out_text (uiout, "\n");
 	  print_command_lines (uiout, *list->body_list, depth + 1);
-	  ui_out_field_string (uiout, NULL, "end");
 	  if (depth)
 	    ui_out_spaces (uiout, 2 * depth);
 	  ui_out_text (uiout, "end\n");
@@ -183,10 +181,9 @@ print_command_lines (struct ui_out *uiou
 	  continue;
 	}
 
-      /* An if command.  Recursively print both arms before continueing.  */
+      /* An if command.  Recursively print both arms before continuing.  */
       if (list->control_type == if_control)
 	{
-	  ui_out_text (uiout, "if ");
 	  ui_out_field_fmt (uiout, NULL, "if %s", list->line);
 	  ui_out_text (uiout, "\n");
 	  /* The true arm. */
@@ -197,12 +194,10 @@ print_command_lines (struct ui_out *uiou
 	    {
 	      if (depth)
 		ui_out_spaces (uiout, 2 * depth);
-	      ui_out_field_string (uiout, NULL, "else");
 	      ui_out_text (uiout, "else\n");
 	      print_command_lines (uiout, list->body_list[1], depth + 1);
 	    }
 
-	  ui_out_field_string (uiout, NULL, "end");
 	  if (depth)
 	    ui_out_spaces (uiout, 2 * depth);
 	  ui_out_text (uiout, "end\n");

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