This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Patch for gdb/mi problem 192
- From: "J. Johnston" <jjohnstn at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 30 Sep 2002 17:06:31 -0400
- Subject: Patch for gdb/mi problem 192
- Organization: Red Hat Inc.
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.
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" \