From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8786 invoked by alias); 6 Jul 2009 19:25:28 -0000 Received: (qmail 8776 invoked by uid 22791); 6 Jul 2009 19:25:28 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Jul 2009 19:25:21 +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 n66JPIx9024284 for ; Mon, 6 Jul 2009 15:25:18 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n66JPHTI015332 for ; Mon, 6 Jul 2009 15:25:17 -0400 Received: from [10.16.2.46] (dhcp-100-2-46.bos.redhat.com [10.16.2.46]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n66JPDjn023994; Mon, 6 Jul 2009 15:25:16 -0400 Message-ID: <4A525042.5030702@redhat.com> Date: Mon, 06 Jul 2009 19:25:00 -0000 From: Masami Hiramatsu User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: Andi Kleen CC: Ingo Molnar , Steven Rostedt , lkml , systemtap , kvm , DLE , Christoph Hellwig , Ananth N Mavinakayanahalli , Frederic Weisbecker , Roland McGrath , Srikar Dronamraju , linux-arch@vger.kernel.org Subject: Re: [PATCH -tip -v10 5/7] x86: add pt_regs register and stack access APIs References: <20090701010838.32547.62843.stgit@localhost.localdomain> <20090701010911.32547.1313.stgit@localhost.localdomain> <871votop6a.fsf@basil.nowhere.org> In-Reply-To: <871votop6a.fsf@basil.nowhere.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00027.txt.bz2 Andi Kleen wrote: > Masami Hiramatsu writes: > >> Add following APIs for accessing registers and stack entries from pt_regs. > > You forgot to state who calls these functions/why are they added? > Who only has strings for registers? Oh, yes. This patch is needed for kprobes based event tracer on ftrace. Some other debugging tools might be able to use it. > I can see the point of having a function for nth argument though, > that's useful. > >> +static inline unsigned long regs_get_argument_nth(struct pt_regs *regs, >> + unsigned n) >> +{ >> + if (n < NR_REGPARMS) { >> + switch (n) { >> + case 0: >> + return regs->ax; >> + case 1: >> + return regs->dx; >> + case 2: >> + return regs->cx; > > > [....] > > That could be done shorter with a offsetof table. > >> + if (n < NR_REGPARMS) { >> + switch (n) { >> + case 0: >> + return regs->di; >> + case 1: >> + return regs->si; >> + case 2: >> + return regs->dx; >> + case 3: >> + return regs->cx; >> + case 4: >> + return regs->r8; >> + case 5: >> + return regs->r9; > > and that too. I'm not so sure about your idea. Would you mean below code? int offs_table[NR_REGPARMS] = { [0] = offsetof(struct pt_regs, di), ... }; if (n < NR_REGPARMS) return *((unsigned long *)regs + offs_table[n]); Thank you, -- Masami Hiramatsu Software Engineer Hitachi Computer Products (America), Inc. Software Solutions Division e-mail: mhiramat@redhat.com