From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28449 invoked by alias); 8 Aug 2007 06:46:11 -0000 Received: (qmail 28282 invoked by uid 22791); 8 Aug 2007 06:46:10 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate8.de.ibm.com (HELO mtagate8.de.ibm.com) (195.212.29.157) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 08 Aug 2007 06:46:07 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate8.de.ibm.com (8.13.8/8.13.8) with ESMTP id l786k4ja295402 for ; Wed, 8 Aug 2007 06:46:04 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.4) with ESMTP id l786k4Ys2314374 for ; Wed, 8 Aug 2007 08:46:04 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l786k0kV015149 for ; Wed, 8 Aug 2007 08:46:01 +0200 Received: from bbkeks.boeblingen.de.ibm.com (dyn-9-152-248-39.boeblingen.de.ibm.com [9.152.248.39]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l786k0b9015112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Aug 2007 08:46:00 +0200 Message-ID: <46B9664D.90907@de.ibm.com> Date: Wed, 08 Aug 2007 06:46:00 -0000 From: Markus Deuling User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: GDB Patches , Ulrich Weigand Subject: [rfc] Wrap addresses in spu-gdb Content-Type: multipart/mixed; boundary="------------020703060507040001040600" 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: 2007-08/txt/msg00141.txt.bz2 This is a multi-part message in MIME format. --------------020703060507040001040600 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1110 Hi, this patch makes GDB aware of a special feature of the SPU hardware. Every SPU has its own dedicated memory, called the Local Store (LS). Currently this is 256K of memory. If accessing memory above this 256K, the address is wrapped to fit in 256K (modulo calculation). So every memory address is valid. The size of the Local Store is found in the SPU's LSLR register. This examples tries to access an address > LS size and runs into an error which is fixed by this patch: (gdb) p *0xfffd0162 Error accessing memory address 0xfffd0162: Invalid argument. The patch introduces three new functions to spu-tdep for address conversion which also will be used by the Cell Broadband Engine combined debugger. ChangeLog: * spu-tdep.c (spu_address_to_pointer): New function. (spu_pointer_to_address): Likewise. (spu_integer_to_address): Likewise. (spu_gdbarch_init): Add spu_address_to_pointer, spu_pointer_to_address and spu_integer_to_address to gdbarch. Tested on spu-elf. Testsuite showed no regression. Ok to commit? -- Markus Deuling GNU Toolchain for Linux on Cell BE deuling@de.ibm.com --------------020703060507040001040600 Content-Type: text/plain; name="diff-spu-wrap-addr" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diff-spu-wrap-addr" Content-length: 2152 diff -urpN src/gdb/spu-tdep.c dev/gdb/spu-tdep.c --- src/gdb/spu-tdep.c 2007-06-18 05:36:44.000000000 +0200 +++ dev/gdb/spu-tdep.c 2007-08-08 08:39:41.000000000 +0200 @@ -324,6 +324,47 @@ spu_register_reggroup_p (struct gdbarch return default_register_reggroup_p (gdbarch, regnum, group); } +/* Address conversion. */ + +static void +spu_address_to_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr) +{ + store_unsigned_integer (buf, TYPE_LENGTH (type), addr); +} + +static CORE_ADDR +spu_pointer_to_address (struct type *type, const gdb_byte *buf) +{ + ULONGEST addr = extract_unsigned_integer (buf, TYPE_LENGTH (type)); + ULONGEST lslr = SPU_LS_SIZE - 1; /* Hard-wired LS size. */ + + if (target_has_registers && target_has_stack && target_has_memory) + { + struct frame_info *frame = get_selected_frame (NULL); + lslr = get_frame_register_unsigned (frame, SPU_LSLR_REGNUM); + } + + return addr & lslr; +} + +static CORE_ADDR +spu_integer_to_address (struct gdbarch *gdbarch, + struct type *type, const gdb_byte *buf) +{ + ULONGEST addr = unpack_long (type, buf); + ULONGEST lslr = SPU_LS_SIZE - 1; /* Hard-wired LS size. */ + + if (target_has_registers && target_has_stack && target_has_memory + /* FIXME: Currently needed for dwarf2_read_address to work. */ + && type != builtin_type_uint32) + { + struct frame_info *frame = get_selected_frame (NULL); + lslr = get_frame_register_unsigned (frame, SPU_LSLR_REGNUM); + } + + return addr & lslr; +} + /* Decoding SPU instructions. */ @@ -2008,6 +2049,11 @@ spu_gdbarch_init (struct gdbarch_info in set_gdbarch_double_format (gdbarch, floatformats_ieee_double); set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double); + /* Address conversion. */ + set_gdbarch_address_to_pointer (gdbarch, spu_address_to_pointer); + set_gdbarch_pointer_to_address (gdbarch, spu_pointer_to_address); + set_gdbarch_integer_to_address (gdbarch, spu_integer_to_address); + /* Inferior function calls. */ set_gdbarch_call_dummy_location (gdbarch, ON_STACK); set_gdbarch_frame_align (gdbarch, spu_frame_align); --------------020703060507040001040600--