From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1861 invoked by alias); 9 Apr 2012 19:49:18 -0000 Received: (qmail 1846 invoked by uid 22791); 9 Apr 2012 19:49:16 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Apr 2012 19:49:00 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q39Jmxh0001530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 9 Apr 2012 15:48:59 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q39JmvgG024588; Mon, 9 Apr 2012 15:48:58 -0400 Message-ID: <4F833D29.4050102@redhat.com> Date: Mon, 09 Apr 2012 19:49:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: Jan Kratochvil CC: Tom Tromey , gdb@sourceware.org Subject: Re: Will therefore GDB utilize C++ or not? References: <20120330161403.GA17891@host2.jankratochvil.net> <87aa2rjkb8.fsf@fleche.redhat.com> <4F832D5B.9030308@redhat.com> <20120409190519.GA524@host2.jankratochvil.net> In-Reply-To: <20120409190519.GA524@host2.jankratochvil.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 2012-04/txt/msg00065.txt.bz2 On 04/09/2012 08:05 PM, Jan Kratochvil wrote: > On Mon, 09 Apr 2012 20:41:31 +0200, Pedro Alves wrote: >> Indeed, gdbserver would need to remain pure C, > [...] >> This is important, because we want gdbserver to be usable >> in #1, resource constrained scenarios where the C++ dependency would >> be unacceptable. We don't want there to need to be other gdbserver-like >> programs specialized for such environments, and gdbserver to be usable only >> on bigger machines. We want gdbserver to run everywhere. And #2, the debugger >> is one of the first programs that is desirable to get running on a new >> system/board. Usually you get C going much sooner than C++. > > While it was said before gdbserver should stay in C I did not see it long-term > maintainable - due to the code sharing goals. I do. > While I wanted to simplify the > talk excluding gdbserver first we can talk even about C++ization of gdbserver. > > Which specific platforms do you talk about which is UNIX compatible (=FSF > gdbserver compatible, not just an embedded stub) and cannot run C++ programs? > (*) Please give examples of viable platforms with future development. GNU's not UNIX. Haven't you heard? And why do you keep excluding embedded things? This is a recurrent point you raise in several discussions. Haven't you noticed the trend towards mobile computing? Even Red Hat has business in the embedded world since a long long time (GNUPro and services). Even Android/Bionic doesn't support C++ exceptions (not sure if it doesn't in recent versions or not). I don't even need to leave my office to find such a system. $ssh 192.168.0.253 [pedro@NAS][~] >ls /usr/lib/libstd* ls: cannot access /usr/lib/libstdc*: No such file or directory > uname -a Linux NAS 2.6.24.4 #1 Tue Feb 10 11:00:22 GMT 2009 armv5tejl unknown >> The event-loop.c file is yet another thing. >> It is currently duplicated (though a bit simplified) in gdbserver/event-loop.c. >> There goes another use for C++ classes. > > The mail lists all the code parts which cannot be C++ized. I do not find that > too interesting. It explained that many core parts of GDB should stay in C. Which served to raise awareness that converting just a few parts to avoid a few bugs and making things neater here and there has a lot of potential for making things worse. I find interesting code parts which can be C++ized - such as > anything about symbols/types outside of gdbserver. It is very much not clear to me that it is worth the pain (that I tried to show we will end up with) to bring in C++ for this. Symbol/types even are long lived objects, it's not common at all to need to worry about leaks (RAII/exceptions) here. And all we have are simple hierarchies. As much as I like C++, C does quite fine here too. The language it is written in is not the problem with our symbol tables. > > >> (On a sidenote: I get the impression from some that C++ would be mostly >> useful for the stronger static typing, > > Not just that one, std::string vs. cleanups vs. exceptions are even more > wanted (by me); just static typing (probably) cannot be done without C++, > the other parts are still being fixed up without C++. Sure, there will always be bugs. C++ doesn't magically make all bugs go away. Even RAII is not _that_ different from cleanups. We still need to have a way to tell the RAII wrapper objects to stop managing whatever they're managing, for instance. And with C++98/03, we have to write these things out of line, like cleanups too. What I'm saying is that our C mechanisms work. There is no need to rush to replace them. We should consider this very very carefully, not just flip just because. -- Pedro Alves