From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14988 invoked by alias); 2 Mar 2012 04:47:16 -0000 Received: (qmail 14953 invoked by uid 22791); 2 Mar 2012 04:47:13 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Mar 2012 04:46:55 +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 q224ks50006735 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Mar 2012 23:46:55 -0500 Received: from mesquite.lan (ovpn-113-100.phx2.redhat.com [10.3.113.100]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q224ksYO019576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 1 Mar 2012 23:46:54 -0500 Date: Fri, 02 Mar 2012 04:47:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: Re: [RFC] rx sim: Print load statistics Message-ID: <20120301214653.124a502f@mesquite.lan> In-Reply-To: <201203012221.15043.vapier@gentoo.org> References: <20120301173842.3802cca3@mesquite.lan> <201203012221.15043.vapier@gentoo.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 X-SW-Source: 2012-03/txt/msg00071.txt.bz2 On Thu, 1 Mar 2012 22:21:13 -0500 Mike Frysinger wrote: > > --- sim/rx/gdb-if.c 4 Jan 2012 08:28:24 -0000 1.13 > > +++ sim/rx/gdb-if.c 2 Mar 2012 00:30:36 -0000 > > > > if (abfd) > > { > > - rx_load (abfd); > > + rx_load (abfd, 0); > > these should be NULL rather than 0 for pointers > > > --- sim/rx/load.c 4 Jan 2012 08:28:24 -0000 1.6 > > +++ sim/rx/load.c 2 Mar 2012 00:30:36 -0000 > > > > +/* Given a file offset, look up the section name. */ > > +static char * > > +find_section_name_by_offset (bfd *abfd, file_ptr filepos) > > should return const char * Okay, I've fixed those. Thanks for the quick review! I'll commit the following in a day or so unless there are further comments. Kevin sim/rx/ChangeLog: * load.h (rx_load): Add `callback' parameter to function prototype. (gdb/callback.h): Include. * load.c (load.h): Include. (xprintf, find_section_name_by_offset): New functions. (rx_load): Add `callback' parameter. Add code for printing section loaded using GDB's printf facilities. * gdb-if.c (sim_load, sim_create_inferior): Update calls to rx_load(). * main.c (main): Likewise. * syscalls.c, syscalls.h (get_callbacks): New function. Index: sim/rx/gdb-if.c =================================================================== RCS file: /cvs/src/src/sim/rx/gdb-if.c,v retrieving revision 1.13 diff -u -p -r1.13 gdb-if.c --- sim/rx/gdb-if.c 4 Jan 2012 08:28:24 -0000 1.13 +++ sim/rx/gdb-if.c 2 Mar 2012 04:40:05 -0000 @@ -201,7 +201,7 @@ sim_load (SIM_DESC sd, char *prog, struc if (!abfd) return SIM_RC_FAIL; - rx_load (abfd); + rx_load (abfd, get_callbacks ()); build_swap_list (abfd); return SIM_RC_OK; @@ -214,7 +214,7 @@ sim_create_inferior (SIM_DESC sd, struct if (abfd) { - rx_load (abfd); + rx_load (abfd, NULL); build_swap_list (abfd); } Index: sim/rx/load.c =================================================================== RCS file: /cvs/src/src/sim/rx/load.c,v retrieving revision 1.6 diff -u -p -r1.6 load.c --- sim/rx/load.c 4 Jan 2012 08:28:24 -0000 1.6 +++ sim/rx/load.c 2 Mar 2012 04:40:05 -0000 @@ -28,9 +28,36 @@ along with this program. If not, see vprintf_filtered) (callback, fmt, ap); + + va_end (ap); +} + +/* Given a file offset, look up the section name. */ +static const char * +find_section_name_by_offset (bfd *abfd, file_ptr filepos) +{ + asection *s; + + for (s = abfd->sections; s; s = s->next) + if (s->filepos == filepos) + return bfd_get_section_name (abfd, s); + + return "(unknown)"; +} + /* A note about endianness and swapping... The RX chip is CISC-like in that the opcodes are variable length @@ -56,7 +83,7 @@ along with this program. If not, see 1) fprintf (stderr, "[load segment: lma=%08x vma=%08x size=%08x]\n", (int) base, (int) p->p_vaddr, (int) size); + if (callback) + xprintf (callback, + "Loading section %s, size %#lx lma %08lx vma %08lx\n", + find_section_name_by_offset (prog, p->p_offset), + size, base, p->p_vaddr); buf = malloc (size); if (buf == NULL) Index: sim/rx/load.h =================================================================== RCS file: /cvs/src/src/sim/rx/load.h,v retrieving revision 1.4 diff -u -p -r1.4 load.h --- sim/rx/load.h 4 Jan 2012 08:28:24 -0000 1.4 +++ sim/rx/load.h 2 Mar 2012 04:40:05 -0000 @@ -20,8 +20,9 @@ along with this program. If not, see