From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3350 invoked by alias); 20 Jun 2013 16:45:44 -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 3300 invoked by uid 89); 20 Jun 2013 16:45:44 -0000 X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 20 Jun 2013 16:45:43 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5KGjdEO029987 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 20 Jun 2013 12:45:40 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5KGjb1b009605; Thu, 20 Jun 2013 12:45:38 -0400 Message-ID: <51C331B0.1010502@redhat.com> Date: Thu, 20 Jun 2013 16:50:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: "Maciej W. Rozycki" CC: Tom Tromey , Richard Sandiford , Catherine Moore , binutils@sourceware.org, gdb-patches@sourceware.org Subject: Re: [PING^2][PATCH] in_plt_section: support alternate stub section names References: <87wqu19y1x.fsf@fleche.redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-06/txt/msg00548.txt.bz2 On 06/20/2013 05:19 PM, Maciej W. Rozycki wrote: > > return 0; > Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c > =================================================================== > --- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c 2013-06-19 16:54:49.000000000 +0100 > +++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c 2013-06-19 16:55:00.280199593 +0100 > @@ -3628,12 +3628,7 @@ mips_stub_frame_sniffer (const struct fr > if (in_plt_section (pc, NULL)) > return 1; > > - /* Binutils for MIPS puts lazy resolution stubs into .MIPS.stubs. */ > - s = find_pc_section (pc); > - > - if (s != NULL > - && strcmp (bfd_get_section_name (s->objfile->obfd, s->the_bfd_section), > - ".MIPS.stubs") == 0) > + if (in_plt_section (pc, ".MIPS.stubs")) > return 1; Quite honestly, this looks like an odd API to me. If all MIPS callers will have to pass in ".MIPS.stubs", then it just looks like in_plt_section becomes a convenience for "is pc in section. It'd make more sense to me to refactor in_plt_section to something like this, somewhere: int pc_in_section (CORE_ADDR pc, const char *name) { struct obj_section *s; int retval = 0; s = find_pc_section (pc); retval = (s != NULL && s->the_bfd_section->name != NULL && strcmp (s->the_bfd_section->name, name) == 0); return (retval); } And then: /* In SVR4, we recognize a trampoline by it's section name. That is, if the pc is in a section named ".plt" then we are in a trampoline. */ int in_plt_section (CORE_ADDR pc) { return pc_in_section (pc, ".plt"); } And then MIPS would have somewhere, mips-tdep.c perhaps, something like: int in_mips_stubs_section (CORE_ADDR pc) { return pc_in_section (pc, ".MIPS.stubs"); } Or #define MIPS_STUBS_SECTION ".MIPS.stubs" pc_in_section (pc, MIPS_STUBS_SECTION); As bonus, you end up with just one place that can typo the section name. Perhaps missed the plan to make in_plt_section fetch the section name from elsewhere, instead of taking it as argument, so callers in common code don't care? -- Pedro Alves