From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10011 invoked by alias); 2 Mar 2012 00:39:02 -0000 Received: (qmail 9996 invoked by uid 22791); 2 Mar 2012 00:39:00 -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 00:38:44 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q220ciDW031239 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Mar 2012 19:38:44 -0500 Received: from mesquite.lan (ovpn-113-100.phx2.redhat.com [10.3.113.100]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q220chmT007206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 1 Mar 2012 19:38:44 -0500 Date: Fri, 02 Mar 2012 00:39:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [RFC] rx sim: Print load statistics Message-ID: <20120301173842.3802cca3@mesquite.lan> 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/msg00062.txt.bz2 The patch below updates the rx sim to print load statistics. I.e. instead of printing nothing when the gdb "load" command is invoked, it'll now do something like this: (gdb) target sim Connected to the simulator. (gdb) load Loading section .text, size 0x7358 lma 01000000 vma 01000000 Loading section .vectors, size 0x30 lma ffffffd0 vma ffffffd0 Comments? 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 00:30:36 -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, 0); 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 00:30:36 -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 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 00:30:36 -0000 @@ -20,8 +20,9 @@ along with this program. If not, see