From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20580 invoked by alias); 10 Jul 2008 22:41:48 -0000 Received: (qmail 20567 invoked by uid 22791); 10 Jul 2008 22:41:47 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 10 Jul 2008 22:41:30 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m6AMfEKE023237; Thu, 10 Jul 2008 18:41:14 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6AMfEif018813; Thu, 10 Jul 2008 18:41:14 -0400 Received: from opsy.redhat.com (vpn-10-44.bos.redhat.com [10.16.10.44]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6AMfD0h005476; Thu, 10 Jul 2008 18:41:13 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 3D74137829C; Thu, 10 Jul 2008 16:41:13 -0600 (MDT) To: Stan Shebs Cc: gdb@sourceware.org Subject: Re: Move GDB to C++ ? References: <487658F7.1090508@earthlink.net> From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom Date: Thu, 10 Jul 2008 22:41:00 -0000 In-Reply-To: <487658F7.1090508@earthlink.net> (Stan Shebs's message of "Thu\, 10 Jul 2008 11\:46\:15 -0700") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00098.txt.bz2 >>>>> "Stan" == Stan Shebs writes: Stan> As many know, there is a project afoot to investigate the Stan> recoding of GCC from C into C++. I'll send a separate note about this soon, probably tomorrow. Thanks for raising this topic -- very brave! Stan> For my part, I think we should do it. GDB has quite a bit of Stan> object-like structure internally I think GDB is nearly written in a dialect of C++ already: * It uses exceptions all over the place. Instead of throw, gdb uses error(). Instead of try{} catch{}, gdb uses TRY_CATCH. * RAII is omnipresent, in the form of cleanups. * Classes exist. For instance, struct cmd_list_element is a class with a constructor, various fields, accessor methods, and some virtual methods. * Subclasses are in use too. The 'struct expression' and 'struct type' classes essentially have subclasses, they are just written as discriminated unions or whatnot. * Templates are used in at least one place -- vec.h. * I think function overloading is in use too, and default arguments. One example is parse_exp_1 and parse_exp_in_context. In all these cases, the C++ code is, in my opinion, simpler to read and write than the corresponding gdb code. It is also more regular; whereas in gdb some "virtual methods" take a 'this' pointer, some do not; some classes have destructors, some do not (these are both things I ran into on the Python branch). Finally, C++ provides better support for abstraction, specifically via access control. So, I am in favor of this change. Tom