From: Keith Seitz <keiths@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFC/A] gdb/680: ui_out_reset?
Date: Tue, 10 Sep 2002 16:41:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.44.0209101637260.10168-100000@valrhona.uglyboxes.com> (raw)
Hi,
Following up to gdb/680 where the MI register commands cause assertion
failures with errors...
There are several ways to approach this. One is to make sure that
everytime ui_out_{list,tuple}_begin is called, there is a
ui_out_{list,tuple}_end. This leads to code like (from
mi_data_list_register_values):
ui_out_list_begin (uiout, "register-values");
if (argc == 1) /* No args, beside the format: do all the regs */
{
for (regnum = 0;
regnum < numregs;
regnum++)
{
if (REGISTER_NAME (regnum) == NULL
|| *(REGISTER_NAME (regnum)) == '\0')
continue;
ui_out_tuple_begin (uiout, NULL);
ui_out_field_int (uiout, "number", regnum);
result = get_register (regnum, format);
if (result == -1)
{
ui_out_tuple_end (uiout);
ui_out_list_end (uiout);
return MI_CMD_ERROR;
}
ui_out_tuple_end (uiout);
}
}
/* snip */
I'd rather just propose a new ui-out function, ui_out_reset, which can be
called to "cleanup" the uiout in case of errors. In this case,
mi_out_rewind could call ui_out_reset and reset the "levels" field.
Of course, I think that Kevin also proposed something in the longjmp case
which is needed in these functions, afaict, but that's another bug/patch.
What do people think? Explicitly call ui_out_{list,tuple}_end before
returning an error code or add ui_out_reset? Perhaps another solution I've
overlooked?
Keith
ChangeLog
2002-09-05 Keith Seitz <keiths@redhat.com>
* ui-out.c (ui_out_reset): New function.
(ui_out_new): Use ui_out_reset.
* ui-out.h (ui_out_reset): Add declaration.
mi/ChangeLog
2002-09-05 Keith Seitz <keiths@redhat.com>
* mi-out.c (mi_out_rewind): Call ui_out_reset to reset
the uiout in case of errors.
Patch
Index: ui-out.c
===================================================================
RCS file: /cvs/src/src/gdb/ui-out.c,v
retrieving revision 1.23
diff -p -r1.23 ui-out.c
*** ui-out.c 27 Jul 2002 01:54:15 -0000 1.23
--- ui-out.c 5 Sep 2002 15:02:46 -0000
*************** ui_out_data (struct ui_out *uiout)
*** 1119,1124 ****
--- 1119,1136 ----
return uiout->data;
}
+ void
+ ui_out_reset (struct ui_out *uiout)
+ {
+ uiout->table.flag = 0;
+ uiout->table.body_flag = 0;
+ uiout->level = 0;
+ memset (uiout->levels, 0, sizeof (uiout->levels));
+ uiout->table.header_first = NULL;
+ uiout->table.header_last = NULL;
+ uiout->table.header_next = NULL;
+ }
+
/* initalize private members at startup */
struct ui_out *
*************** ui_out_new (struct ui_out_impl *impl,
*** 1130,1142 ****
uiout->data = data;
uiout->impl = impl;
uiout->flags = flags;
! uiout->table.flag = 0;
! uiout->table.body_flag = 0;
! uiout->level = 0;
! memset (uiout->levels, 0, sizeof (uiout->levels));
! uiout->table.header_first = NULL;
! uiout->table.header_last = NULL;
! uiout->table.header_next = NULL;
return uiout;
}
--- 1142,1148 ----
uiout->data = data;
uiout->impl = impl;
uiout->flags = flags;
! ui_out_reset (uiout);
return uiout;
}
Index: ui-out.h
===================================================================
RCS file: /cvs/src/src/gdb/ui-out.h,v
retrieving revision 1.15
diff -p -r1.15 ui-out.h
*** ui-out.h 6 Jul 2001 03:53:11 -0000 1.15
--- ui-out.h 5 Sep 2002 15:02:46 -0000
*************** extern struct ui_out *ui_out_new (struct
*** 272,275 ****
--- 272,278 ----
struct ui_out_data *data,
int flags);
+ /* Reset the ui_out object. This is useful when dealing with errors. */
+ extern void ui_out_reset (struct ui_out *uiout);
+
#endif /* UI_OUT_H */
Index: mi/mi-out.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-out.c,v
retrieving revision 1.23
diff -p -r1.23 mi-out.c
*** mi/mi-out.c 19 Mar 2002 02:51:08 -0000 1.23
--- mi/mi-out.c 5 Sep 2002 15:02:46 -0000
*************** mi_out_rewind (struct ui_out *uiout)
*** 409,414 ****
--- 409,417 ----
{
struct ui_out_data *data = ui_out_data (uiout);
ui_file_rewind (data->buffer);
+
+ /* Reset the uiout in case there was an error. */
+ ui_out_reset (uiout);
}
/* dump the buffer onto the specified stream */
next reply other threads:[~2002-09-10 23:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-10 16:41 Keith Seitz [this message]
2002-09-10 17:29 ` Kevin Buettner
2002-09-10 17:36 ` Kevin Buettner
2002-09-11 12:12 ` Keith Seitz
2002-09-11 12:36 ` Kevin Buettner
2002-09-11 14:29 ` Elena Zannoni
2002-09-11 14:39 ` Keith Seitz
2002-09-11 14:45 ` Elena Zannoni
2002-09-11 14:49 ` Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.44.0209101637260.10168-100000@valrhona.uglyboxes.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox