From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55790 invoked by alias); 24 Feb 2017 09:33:26 -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 55769 invoked by uid 89); 24 Feb 2017 09:33:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,GIT_PATCH_2,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Feb 2017 09:33:24 +0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2017 01:33:21 -0800 X-ExtLoop1: 1 Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by orsmga005.jf.intel.com with ESMTP; 24 Feb 2017 01:33:18 -0800 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.142]) by IRSMSX106.ger.corp.intel.com ([169.254.8.197]) with mapi id 14.03.0248.002; Fri, 24 Feb 2017 09:33:17 +0000 From: "Metzger, Markus T" To: "Wiederhake, Tim" , "gdb-patches@sourceware.org" Subject: RE: [PATCH 07/11] [SQUASH] btrace: Adjust struct btrace_function::up. Date: Fri, 24 Feb 2017 09:33:00 -0000 Message-ID: References: <1487337989-6367-1-git-send-email-tim.wiederhake@intel.com> <1487337989-6367-8-git-send-email-tim.wiederhake@intel.com> In-Reply-To: <1487337989-6367-8-git-send-email-tim.wiederhake@intel.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00664.txt.bz2 > -----Original Message----- > From: Wiederhake, Tim > Sent: Friday, February 17, 2017 2:26 PM > To: gdb-patches@sourceware.org > Cc: Metzger, Markus T > Subject: [PATCH 07/11] [SQUASH] btrace: Adjust struct btrace_function::up. Hello Tim, > +static struct btrace_function * > +ftrace_find_call_by_number (const struct btrace_thread_info *btinfo, > + unsigned int number) > +{ > + if (number =3D=3D 0 || number > VEC_length (btrace_fun_s, btinfo->func= tions)) > + return NULL; > + > + return VEC_index (btrace_fun_s, btinfo->functions, number - 1); > +} This new function needs a comment. > -/* Find the innermost caller in the back trace of BFUN with MFUN/FUN > - symbol information. */ > +/* Find the innermost caller with MFUN/FUN symbol information in the back > trace > + of the function call segment with number NUMBER. */ Just "function segment" without the "call". More below. > static struct btrace_function * > ftrace_find_caller (struct btrace_thread_info *btinfo, > - struct btrace_function *bfun, > + unsigned int number, > struct minimal_symbol *mfun, > struct symbol *fun) > { > - for (; bfun !=3D NULL; bfun =3D bfun->up) > + struct btrace_function *bfun; > + > + while ((bfun =3D ftrace_find_call_by_number (btinfo, number)) !=3D NUL= L) > { > - /* Skip functions with incompatible symbol information. */ > - if (ftrace_function_switched (bfun, mfun, fun)) > - continue; > + if (!ftrace_function_switched (bfun, mfun, fun)) > + break; >=20 > - /* This is the function segment we're looking for. */ > - break; > + number =3D bfun->up; > } >=20 > return bfun; > } Eventually, I think we'd want most functions to take and return indices or = function numbers instead of btrace_function pointers. They can get the actual btrac= e_function in the body. This will reduce the lifetime of btrace_function pointers and make it easie= r to deal with vector reallocations. If we added helpers to get the up, segment.prev, and segment.next numbers f= rom a function number, most won't need a btrace_function pointer, at all. They c= ould work solely on the function numbers. > - caller =3D bfun->up; > - if (caller =3D=3D NULL) > + if (bfun->up =3D=3D 0) > throw_error (NOT_AVAILABLE_ERROR, > _("No caller in btrace record history")); >=20 > + caller =3D VEC_index (btrace_fun_s, cache->tp->btrace.functions, bfun-= >up - 1); We should add functions to btrace.h to translate function numbers into const struct btrace_function *. Thanks, 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