Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Patch for gdb/mi problem 192
@ 2002-09-30 14:06 J. Johnston
  2002-10-02 15:27 ` Andrew Cagney
  0 siblings, 1 reply; 4+ messages in thread
From: J. Johnston @ 2002-09-30 14:06 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]

I have attached a patch for the problem 192.  The problem is that under mi,
the frame level is being output as an integer followed by a space.  This
occurs because the code in print_frame_info_base was using a format string
%-2d to output the level.  This format has a field-width of 2 and left-adjusts
the output.  This causes a right-most blank to occur for levels < 10.  The
mi code does not analyze format strings such as this and ends up with an
extraneous blank.

To fix this, I have added a new ui_out function: ui_out_field_fmt_int.  It
is essentially the same as ui_out_field_int, but allows specification of
field width and alignment.  The calls to printf_filtered and ui_out_field_fmt
in print_frame_info_base have been replaced with the new function call.
The mi testsuite has been modified to remove expected blanks after frame level.

Is this ok?  Can it be committed?

gdb/ChangeLog:

2002-09-30  Jeff Johnston  <jjohnstn@redhat.com>

	* ui-out.h (ui_out_field_fmt_int): New prototype.
	* ui-out.c (ui_out_field_fmt_int): New function allowing specification
	of field width and alignment.
	* stack.c (print_frame_info_base): When printing frame level, use
	ui_out_field_fmt_int with a width of 2 and left alignment.  Fix for
	PR gdb/192


gdb/testsuite/gdb.mi/ChangeLog:

2002-09-30  Jeff Johnston  <jjohnstn@redhat.com>

	* mi-stack.exp: Change testcases that print frame to not expect "level" field
	to have extraneous right space.  Fix for PR gdb/192.
	* mi-return.exp: Ditto.

-- Jeff J.

[-- Attachment #2: 192.patch --]
[-- Type: text/plain, Size: 5766 bytes --]

Index: stack.c
===================================================================
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.44
diff -u -r1.44 stack.c
--- stack.c	22 Sep 2002 22:18:41 -0000	1.44
+++ stack.c	30 Sep 2002 20:52:42 -0000
@@ -358,7 +358,10 @@
       /* Do this regardless of SOURCE because we don't have any source
          to list for this frame.  */
       if (level >= 0)
-	printf_filtered ("#%-2d ", level);
+        {
+          ui_out_text (uiout, "#");
+          ui_out_field_fmt_int (uiout, 2, ui_left, "level", level);
+        }
       annotate_function_call ();
       printf_filtered ("<function called from gdb>\n");
       annotate_frame_end ();
@@ -371,7 +374,10 @@
       /* Do this regardless of SOURCE because we don't have any source
          to list for this frame.  */
       if (level >= 0)
-	printf_filtered ("#%-2d ", level);
+        {
+          ui_out_text (uiout, "#");
+          ui_out_field_fmt_int (uiout, 2, ui_left, "level", level);
+        }
       annotate_signal_handler_caller ();
       printf_filtered ("<signal handler called>\n");
       annotate_frame_end ();
@@ -548,8 +554,7 @@
   if (level >= 0)
     {
       ui_out_text (uiout, "#");
-      ui_out_field_fmt (uiout, "level", "%-2d", level);
-      ui_out_spaces (uiout, 1);
+      ui_out_field_fmt_int (uiout, 2, ui_left, "level", level);
     }
   if (addressprint)
     if (fi->pc != sal.pc || !sal.symtab || source == LOC_AND_ADDRESS)
Index: ui-out.c
===================================================================
RCS file: /cvs/src/src/gdb/ui-out.c,v
retrieving revision 1.23
diff -u -r1.23 ui-out.c
--- ui-out.c	27 Jul 2002 01:54:15 -0000	1.23
+++ ui-out.c	30 Sep 2002 20:52:42 -0000
@@ -486,6 +486,23 @@
 }
 
 void
+ui_out_field_fmt_int (struct ui_out *uiout,
+                      int input_width,
+                      enum ui_align input_align,
+		      const char *fldname,
+		      int value)
+{
+  int fldno;
+  int width;
+  int align;
+  struct ui_out_level *current = current_level (uiout);
+
+  verify_field (uiout, &fldno, &width, &align);
+
+  uo_field_int (uiout, fldno, input_width, input_align, fldname, value);
+}
+
+void
 ui_out_field_core_addr (struct ui_out *uiout,
 			const char *fldname,
 			CORE_ADDR address)
Index: ui-out.h
===================================================================
RCS file: /cvs/src/src/gdb/ui-out.h,v
retrieving revision 1.15
diff -u -r1.15 ui-out.h
--- ui-out.h	6 Jul 2001 03:53:11 -0000	1.15
+++ ui-out.h	30 Sep 2002 20:52:42 -0000
@@ -119,6 +119,10 @@
 extern void ui_out_field_int (struct ui_out *uiout, const char *fldname,
 			      int value);
 
+extern void ui_out_field_fmt_int (struct ui_out *uiout, int width,
+				  enum ui_align align, const char *fldname, 
+		 		  int value);
+
 extern void ui_out_field_core_addr (struct ui_out *uiout, const char *fldname,
 				    CORE_ADDR address);
 
Index: testsuite/gdb.mi/mi-return.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-return.exp,v
retrieving revision 1.7
diff -u -r1.7 mi-return.exp
--- testsuite/gdb.mi/mi-return.exp	19 Aug 2001 01:23:43 -0000	1.7
+++ testsuite/gdb.mi/mi-return.exp	30 Sep 2002 20:52:42 -0000
@@ -80,7 +80,7 @@
 
     send_gdb "111-exec-return\n"
     gdb_expect {
-	-re "111\\^done,frame=\{level=\"0 \",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",line=\"18\"\}\r\n$mi_gdb_prompt$" {pass "return from callee4 now"}
+	-re "111\\^done,frame=\{level=\"0\",addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",line=\"18\"\}\r\n$mi_gdb_prompt$" {pass "return from callee4 now"}
 	-re ".*\r\n$mi_gdb_prompt$" { fail "return from callee4 now" }
 	timeout { fail "return from callee4 now (timeout)"
 	}
Index: testsuite/gdb.mi/mi-stack.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stack.exp,v
retrieving revision 1.8
diff -u -r1.8 mi-stack.exp
--- testsuite/gdb.mi/mi-stack.exp	19 Aug 2001 01:23:43 -0000	1.8
+++ testsuite/gdb.mi/mi-stack.exp	30 Sep 2002 20:52:42 -0000
@@ -73,13 +73,13 @@
     # -stack-list-frames 1 3
 
     mi_gdb_test "231-stack-list-frames" \
-	    "231\\^done,stack=\\\[frame=\{level=\"0 \",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\"\},frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2 \",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3 \",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4 \",addr=\"$hex\",func=\"main\",.*\}\\\]" \
+	    "231\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"callee4\",file=\".*basics.c\",line=\"8\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\},frame=\{level=\"4\",addr=\"$hex\",func=\"main\",.*\}\\\]" \
                 "stack frame listing"
     mi_gdb_test "232-stack-list-frames 1 1" \
-	    "232\\^done,stack=\\\[frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\}\\\]" \
+	    "232\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\}\\\]" \
                 "stack frame listing 1 1"
     mi_gdb_test "233-stack-list-frames 1 3" \
-	    "233\\^done,stack=\\\[frame=\{level=\"1 \",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2 \",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3 \",addr=\"$hex\",func=\"callee1\",.*\}\\\]" \
+	    "233\\^done,stack=\\\[frame=\{level=\"1\",addr=\"$hex\",func=\"callee3\",.*\},frame=\{level=\"2\",addr=\"$hex\",func=\"callee2\",.*\},frame=\{level=\"3\",addr=\"$hex\",func=\"callee1\",.*\}\\\]" \
                 "stack frame listing 1 3"
 
     mi_gdb_test "234-stack-list-frames 1" \

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch for gdb/mi problem 192
  2002-09-30 14:06 Patch for gdb/mi problem 192 J. Johnston
@ 2002-10-02 15:27 ` Andrew Cagney
  2002-10-03 13:21   ` J. Johnston
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2002-10-02 15:27 UTC (permalink / raw)
  To: J. Johnston; +Cc: gdb-patches

> gdb/ChangeLog:
> 
> 2002-09-30  Jeff Johnston  <jjohnstn@redhat.com>
> 
> 	* ui-out.h (ui_out_field_fmt_int): New prototype.
> 	* ui-out.c (ui_out_field_fmt_int): New function allowing specification
> 	of field width and alignment.
> 	* stack.c (print_frame_info_base): When printing frame level, use
> 	ui_out_field_fmt_int with a width of 2 and left alignment.  Fix for
> 	PR gdb/192

Ok, so instead of:
	frame="2 "
it outputs
	frame="2"
I think this is a straight bug that can't (?) affect old parsers (...).

So, yes, ok.

Can you just add a NEWS entry pointing out that this was fixed.  You'll 
now also need to update both mi-*.exp and mi1-*.exp.

> gdb/testsuite/gdb.mi/ChangeLog:
> 
> 2002-09-30  Jeff Johnston  <jjohnstn@redhat.com>
> 
> 	* mi-stack.exp: Change testcases that print frame to not expect "level" field
> 	to have extraneous right space.  Fix for PR gdb/192.
> 	* mi-return.exp: Ditto.
> 

Also (independant patch) can you please mention this new 
ui_out_field_fmt_int() function in the gdbint.texinfo doco (look for 
ui_out_field_int()).  If Eli is ok with it, then it is approved.

Andrew



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch for gdb/mi problem 192
  2002-10-02 15:27 ` Andrew Cagney
@ 2002-10-03 13:21   ` J. Johnston
  2002-10-03 13:33     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: J. Johnston @ 2002-10-03 13:21 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

Andrew Cagney wrote:
> 
> > gdb/ChangeLog:
> >
> > 2002-09-30  Jeff Johnston  <jjohnstn@redhat.com>
> >
> >       * ui-out.h (ui_out_field_fmt_int): New prototype.
> >       * ui-out.c (ui_out_field_fmt_int): New function allowing specification
> >       of field width and alignment.
> >       * stack.c (print_frame_info_base): When printing frame level, use
> >       ui_out_field_fmt_int with a width of 2 and left alignment.  Fix for
> >       PR gdb/192
> 
> Ok, so instead of:
>         frame="2 "
> it outputs
>         frame="2"
> I think this is a straight bug that can't (?) affect old parsers (...).
> 
> So, yes, ok.
> 
> Can you just add a NEWS entry pointing out that this was fixed.  You'll
> now also need to update both mi-*.exp and mi1-*.exp.
> 
> > gdb/testsuite/gdb.mi/ChangeLog:
> >
> > 2002-09-30  Jeff Johnston  <jjohnstn@redhat.com>
> >
> >       * mi-stack.exp: Change testcases that print frame to not expect "level" field
> >       to have extraneous right space.  Fix for PR gdb/192.
> >       * mi-return.exp: Ditto.
> >
> 
> Also (independant patch) can you please mention this new
> ui_out_field_fmt_int() function in the gdbint.texinfo doco (look for
> ui_out_field_int()).  If Eli is ok with it, then it is approved.
> 

Ok, additional doc patches added to this note.  Eli, I will wait for your
approval.

-- Jeff J.

[-- Attachment #2: 192.doc.patch --]
[-- Type: text/plain, Size: 5063 bytes --]

Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.102
diff -u -r1.102 gdbint.texinfo
--- doc/gdbint.texinfo	19 Sep 2002 15:43:49 -0000	1.102
+++ doc/gdbint.texinfo	3 Oct 2002 20:19:31 -0000
@@ -1011,6 +1011,13 @@
 the name of the field.
 @end deftypefun
 
+@deftypefun void ui_out_field_fmt_int (struct ui_out *@var{uiout}, int @var{width}, enum ui_align @var{alignment}, const char *@var{fldname}, int @var{value})
+This function outputs a value of an @code{int} variable.  It differs from
+@code{ui_out_field_int} in that the caller specifies the desired @var{width} and @var{alignment} of the output.
+@var{fldname} specifies
+the name of the field.
+@end deftypefun
+
 @deftypefun void ui_out_field_core_addr (struct ui_out *@var{uiout}, const char *@var{fldname}, CORE_ADDR @var{address})
 This function outputs an address.
 @end deftypefun
Index: mi/gdbmi.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/mi/gdbmi.texinfo,v
retrieving revision 1.28
diff -u -r1.28 gdbmi.texinfo
--- mi/gdbmi.texinfo	27 Sep 2002 18:09:27 -0000	1.28
+++ mi/gdbmi.texinfo	3 Oct 2002 20:19:31 -0000
@@ -2034,7 +2034,7 @@
 205^done
 (@value{GDBP})
 111-exec-return
-111^done,frame=@{level="0 ",func="callee3",
+111^done,frame=@{level="0",func="callee3",
 args=[@{name="strarg",
 value="0x11940 \"A string argument.\""@}],
 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="18"@}
@@ -2641,15 +2641,15 @@
 -stack-list-frames
 ^done,
 stack=[
-frame=@{level="0 ",addr="0x00010734",func="callee4",
+frame=@{level="0",addr="0x00010734",func="callee4",
 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"@},
-frame=@{level="1 ",addr="0x0001076c",func="callee3",
+frame=@{level="1",addr="0x0001076c",func="callee3",
 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="17"@},
-frame=@{level="2 ",addr="0x0001078c",func="callee2",
+frame=@{level="2",addr="0x0001078c",func="callee2",
 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="22"@},
-frame=@{level="3 ",addr="0x000107b4",func="callee1",
+frame=@{level="3",addr="0x000107b4",func="callee1",
 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="27"@},
-frame=@{level="4 ",addr="0x000107e0",func="main",
+frame=@{level="4",addr="0x000107e0",func="main",
 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="32"@}]
 (@value{GDBP})
 -stack-list-arguments 0
@@ -2731,25 +2731,25 @@
 (@value{GDBP})
 -stack-list-frames
 ^done,stack=
-[frame=@{level="0 ",addr="0x0001076c",func="foo",
+[frame=@{level="0",addr="0x0001076c",func="foo",
   file="recursive2.c",line="11"@},
-frame=@{level="1 ",addr="0x000107a4",func="foo",
+frame=@{level="1",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="2 ",addr="0x000107a4",func="foo",
+frame=@{level="2",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="3 ",addr="0x000107a4",func="foo",
+frame=@{level="3",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="4 ",addr="0x000107a4",func="foo",
+frame=@{level="4",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="5 ",addr="0x000107a4",func="foo",
+frame=@{level="5",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="6 ",addr="0x000107a4",func="foo",
+frame=@{level="6",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="7 ",addr="0x000107a4",func="foo",
+frame=@{level="7",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="8 ",addr="0x000107a4",func="foo",
+frame=@{level="8",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="9 ",addr="0x000107a4",func="foo",
+frame=@{level="9",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
 frame=@{level="10",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
@@ -2764,11 +2764,11 @@
 (@value{GDBP})
 -stack-list-frames 3 5
 ^done,stack=
-[frame=@{level="3 ",addr="0x000107a4",func="foo",
+[frame=@{level="3",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="4 ",addr="0x000107a4",func="foo",
+frame=@{level="4",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@},
-frame=@{level="5 ",addr="0x000107a4",func="foo",
+frame=@{level="5",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@}]
 (@value{GDBP})
 @end smallexample
@@ -2779,7 +2779,7 @@
 (@value{GDBP})
 -stack-list-frames 3 3
 ^done,stack=
-[frame=@{level="3 ",addr="0x000107a4",func="foo",
+[frame=@{level="3",addr="0x000107a4",func="foo",
   file="recursive2.c",line="14"@}]
 (@value{GDBP})
 @end smallexample
@@ -3442,7 +3442,7 @@
 (@value{GDBP})
 -thread-select 3
 ^done,new-thread-id="3",
-frame=@{level="0 ",func="vprintf",
+frame=@{level="0",func="vprintf",
 args=[@{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""@},
 @{name="arg",value="0x2"@}],file="vprintf.c",line="31"@}
 (@value{GDBP})

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch for gdb/mi problem 192
  2002-10-03 13:21   ` J. Johnston
@ 2002-10-03 13:33     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2002-10-03 13:33 UTC (permalink / raw)
  To: jjohnstn; +Cc: ac131313, gdb-patches

> Date: Thu, 03 Oct 2002 16:21:21 -0400
> From: "J. Johnston" <jjohnstn@redhat.com>
> 
> Ok, additional doc patches added to this note.  Eli, I will wait for your
> approval.

Approved, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-10-03 20:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-30 14:06 Patch for gdb/mi problem 192 J. Johnston
2002-10-02 15:27 ` Andrew Cagney
2002-10-03 13:21   ` J. Johnston
2002-10-03 13:33     ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox