From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8638 invoked by alias); 11 Sep 2002 00:29:39 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 8630 invoked from network); 11 Sep 2002 00:29:38 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 11 Sep 2002 00:29:38 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id g8B0DEw01577 for ; Tue, 10 Sep 2002 20:13:14 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id g8B0TUd27918; Tue, 10 Sep 2002 20:29:30 -0400 Received: from romulus.sfbay.redhat.com (IDENT:MFINxDAxEeeWY89xYsd+SdWhuNRBp7Y5@romulus.sfbay.redhat.com [172.16.27.251]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id g8B0TTC05418; Tue, 10 Sep 2002 17:29:29 -0700 Received: (from kev@localhost) by romulus.sfbay.redhat.com (8.11.6/8.11.6) id g8B0TRJ18395; Tue, 10 Sep 2002 17:29:27 -0700 Date: Tue, 10 Sep 2002 17:29:00 -0000 From: Kevin Buettner Message-Id: <1020911002927.ZM18394@localhost.localdomain> In-Reply-To: Keith Seitz "[RFC/A] gdb/680: ui_out_reset?" (Sep 10, 4:44pm) References: To: Keith Seitz , gdb-patches@sources.redhat.com Subject: Re: [RFC/A] gdb/680: ui_out_reset? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-09/txt/msg00175.txt.bz2 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