From: Kevin Buettner <kevinb@redhat.com>
To: Keith Seitz <keiths@redhat.com>, gdb-patches@sources.redhat.com
Subject: Re: [RFC/A] gdb/680: ui_out_reset?
Date: Tue, 10 Sep 2002 17:29:00 -0000 [thread overview]
Message-ID: <1020911002927.ZM18394@localhost.localdomain> (raw)
In-Reply-To: Keith Seitz <keiths@redhat.com> "[RFC/A] gdb/680: ui_out_reset?" (Sep 10, 4:44pm)
On Sep 10, 4:44pm, Keith Seitz wrote:
> 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?
Well, ui_out_reset() certainly seems easier, but I wonder if it's too
sloppy? I.e, if we're going to do this, I'm wonder what the point of
checking the value of the ``level'' field (in push_level() and
pop_level()) in the first place is?
Hmm. I guess it prevents you from writing code which goes too deep.
But it doesn't really help you to check to see if you've correctly
popped each level. At the moment, if you don't have enough pops,
you'll eventually wind up seeing an internal error. (Which is a good
thing, I think.)
It also occurs to me that making sure that you've done the pops in the
right places is important when the caller (of a function which
returns MI_CMD_ERROR) decides to do something other than return to
the top level. I.e, maybe it decides that it can somehow continue and
produces more output.
So... I guess I'm favoring explicit calls to ui_out_{list,tuple}_end().
Kevin
next prev parent reply other threads:[~2002-09-11 0:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-10 16:41 Keith Seitz
2002-09-10 17:29 ` Kevin Buettner [this message]
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=1020911002927.ZM18394@localhost.localdomain \
--to=kevinb@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=keiths@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