From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17136 invoked by alias); 25 Sep 2013 19:05:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 17127 invoked by uid 89); 25 Sep 2013 19:05:45 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Sep 2013 19:05:45 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8PJ5SDe029322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Sep 2013 15:05:28 -0400 Received: from host2.jankratochvil.net (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r8PJ5Np7026277 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 25 Sep 2013 15:05:27 -0400 Date: Wed, 25 Sep 2013 19:05:00 -0000 From: Jan Kratochvil To: "Metzger, Markus T" Cc: "gdb-patches@sourceware.org" , Pedro Alves Subject: Re: [patch v4 20/24] btrace, gdbserver: read branch trace incrementally Message-ID: <20130925190523.GA18559@host2.jankratochvil.net> References: <1372842874-28951-1-git-send-email-markus.t.metzger@intel.com> <1372842874-28951-21-git-send-email-markus.t.metzger@intel.com> <20130818190905.GP24153@host2.jankratochvil.net> <20130922144224.GC19149@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2013-09/txt/msg00903.txt.bz2 On Mon, 23 Sep 2013 09:09:18 +0200, Metzger, Markus T wrote: > > > I need to distinguish different types of errors, e.g. overflow and not > > supported. > > > > Then use enum. There is for example: > > enum return_reason > > { > > /* User interrupt. */ > > RETURN_QUIT = -2, > > /* Any other error. */ > > RETURN_ERROR > > }; > > > > One could even throw and catch specific exceptions (enum errors) but I find > > that needlessly overcomplicated when we just return to the immediate > > caller. > > In addition to errors I defined myself, I might get errors from the system call, > e.g. ENOMEM, EOPNOTSUPP, ENOSYS. I do not see such system call. linux_read_btrace can ever return only 0, -EOVERFLOW or -ENOSYS and nothing else. It never returns for example variable value like "-errno". > For the not-available function, for > example, I'm just mimicking the error that would be returned by the system > call on systems where that call is not available. This is not GDB style, it probably comes from Linux kernel. GDB code should not needlessly depend on any system E* macros as it reduces portability (these are linux-* files but still). > Do you want me to translate those into an enum? As it can return only 0, -EOVERFLOW and -ENOSYS yes, I find enum as the best one. Thanks, Jan