From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32798 invoked by alias); 11 May 2017 10:02:42 -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 32264 invoked by uid 89); 11 May 2017 10:02:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=HCC:D*ca, Tel, tel, commercial X-HELO: mga07.intel.com Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 May 2017 10:02:40 +0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 11 May 2017 03:02:40 -0700 X-ExtLoop1: 1 Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by fmsmga006.fm.intel.com with ESMTP; 11 May 2017 03:02:39 -0700 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.170]) by IRSMSX103.ger.corp.intel.com ([169.254.3.141]) with mapi id 14.03.0319.002; Thu, 11 May 2017 11:02:38 +0100 From: "Metzger, Markus T" To: "Wiederhake, Tim" , "gdb-patches@sourceware.org" CC: "simon.marchi@polymtl.ca" Subject: RE: [PATCH v4 04/12] btrace: Use function segment index in call iterator. Date: Thu, 11 May 2017 10:02:00 -0000 Message-ID: References: <1494416867-19612-1-git-send-email-tim.wiederhake@intel.com> <1494416867-19612-5-git-send-email-tim.wiederhake@intel.com> In-Reply-To: <1494416867-19612-5-git-send-email-tim.wiederhake@intel.com> dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00285.txt.bz2 Hello Tim, > /* See btrace.h. */ > @@ -2702,26 +2684,14 @@ btrace_find_call_by_number (struct > btrace_call_iterator *it, > const struct btrace_thread_info *btinfo, > unsigned int number) > { > - const struct btrace_function *bfun; > + const unsigned int length =3D btinfo->functions.size (); >=20 > - for (bfun =3D btinfo->end; bfun !=3D NULL; bfun =3D bfun->flow.prev) > - { > - unsigned int bnum; > - > - bnum =3D bfun->number; > - if (number =3D=3D bnum) > - { > - it->btinfo =3D btinfo; > - it->function =3D bfun; > - return 1; > - } > - > - /* Functions are ordered and numbered consecutively. We could bai= l out > - earlier. On the other hand, it is very unlikely that we search for > - a nonexistent function. */ > - } > + if ((number =3D=3D 0) || (number > length)) > + return 0; >=20 > - return 0; > + it->btinfo =3D btinfo; > + it->index =3D number - 1; > + return 1; > } We have those +1 and -1 operations throughout the code. Should we introduce some small helpers to document what we're doing? E.g. static inline unsigned int btrace_call_number_from_index (unsigned int call= _index) { return call_index + 1; } and static inline unsigned int btrace_call_number_to_index (unsigned int call_n= umber) { return call_number - 1; } Regards, Markus. Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928