From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17246 invoked by alias); 17 Feb 2003 16:46:58 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 17239 invoked from network); 17 Feb 2003 16:46:57 -0000 Received: from unknown (HELO jackfruit.Stanford.EDU) (171.64.38.136) by 172.16.49.205 with SMTP; 17 Feb 2003 16:46:57 -0000 Received: (from carlton@localhost) by jackfruit.Stanford.EDU (8.11.6/8.11.6) id h1HGffa16810; Mon, 17 Feb 2003 08:41:41 -0800 X-Authentication-Warning: jackfruit.Stanford.EDU: carlton set sender to carlton@math.stanford.edu using -f To: Andrew Cagney Cc: gdb Subject: Re: How much should I cleanup? References: <3E4F585E.1020700@redhat.com> From: David Carlton Date: Mon, 17 Feb 2003 16:46:00 -0000 In-Reply-To: <3E4F585E.1020700@redhat.com> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-02/txt/msg00263.txt.bz2 On Sun, 16 Feb 2003 10:22:38 +0100, Andrew Cagney said: >> So, if that's correct: what are 'exceptional circumstances'? I assume >> error() and related functions count. I don't know exactly what QUIT >> does; do I have to be careful if there are QUIT's in between the >> xmalloc() and the xfree()? (Are those the only places where GDB pays >> attention to ^C's?) Any other situations? > Failed memory read, no frame. Thanks. >> Sigh. C has its benefits, but ease of memory management isn't one >> of them. Every time I have to write a cleanup function, every time >> I have to think about whether to alloca() memory for a string or to >> xmalloc() it (and every time I can't alloca() it because I'm >> returning the string in question), I get another grey hair. >> (Though the grey hair falls out soon thereafter, for better or for >> worse.) > Ah, yes. C++ `is the answer' :-^ Well, to handle this particular situation, a language with actual garbage collection would be the most pleasant to program in. (Let's rewrite GDB in Scheme!) But yes, C++'s improved support for exceptions, memory management, and strings makes it much more pleasant to program in compared to C when dealing with this sort of stuff. (At least once you have your old C pointer-usage habits drilled out of you: writing exception-safe code in C++ isn't hard, it just doesn't look quite like C code.) Getting C++ to play well with GDB's existing memory management/exception handling mechanisms would take a little thought, though I don't see any reason why it couldn't be done. David Carlton carlton@math.stanford.edu