From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9737 invoked by alias); 11 Nov 2006 18:37:50 -0000 Received: (qmail 9729 invoked by uid 22791); 11 Nov 2006 18:37:50 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate1.de.ibm.com (HELO mtagate1.de.ibm.com) (195.212.29.150) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 11 Nov 2006 18:37:41 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate1.de.ibm.com (8.13.8/8.13.8) with ESMTP id kABIbc0P241938 for ; Sat, 11 Nov 2006 18:37:38 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.6/8.13.6/NCO v8.1.1) with ESMTP id kABIenZ12928642 for ; Sat, 11 Nov 2006 19:40:49 +0100 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 kABIbcKl031162 for ; Sat, 11 Nov 2006 19:37:38 +0100 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id kABIbcwQ031159 for ; Sat, 11 Nov 2006 19:37:38 +0100 Message-Id: <200611111837.kABIbcwQ031159@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sat, 11 Nov 2006 19:37:38 +0100 Subject: [RFA][1/5] New port: Cell BE SPU (dwarf2loc.c fix) To: gdb-patches@sourceware.org Date: Sat, 11 Nov 2006 18:37:00 -0000 From: "Ulrich Weigand" X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00082.txt.bz2 Hello, this fixes a problem in dwarf2loc.c that triggers for the SPU port. The code in dwarf_expr_read_reg currently expects that in order to retrieve an address value from a register, it's OK to assume the address can always be extracted using extract_unsigned_integer on the full size of the register. This fails on the SPU, because all registers are 16 bytes wide, and a pointer is represented by simply using the uppermost 4 bytes and ignoring the contents of the remaining 12 bytes. I would assume that there's also other architectures where the assumption in dwarf_expr_read_reg might fail, e.g. due to sign extension issues or other required fiddling. So, to fix this I thought that we already *know* how to extract values of a certain type from a register: value_from_register does just that, and provides all sorts of configurability for the back end to have it just do the right thing. Since the value retrieved by dwarf_expr_read_reg is always a pointer to some data object (normally on the stack), it should be OK to get it by using value_from_register (builtin_type_void_data_ptr, ...). This is what the patch below does, and it works fine on SPU. Additionally tested without regressions on s390-ibm-linux and s390x-ibm-linux. OK? Bye, Ulrich * dwarf2loc.c (dwarf_expr_read_reg): Use value_from_register to retrieve address from register. diff -ur gdb-orig/gdb/dwarf2loc.c gdb-head/gdb/dwarf2loc.c --- gdb-orig/gdb/dwarf2loc.c 2006-11-10 03:00:22.000000000 +0100 +++ gdb-head/gdb/dwarf2loc.c 2006-11-11 18:16:58.663849888 +0100 @@ -115,23 +115,23 @@ /* Helper functions for dwarf2_evaluate_loc_desc. */ /* Using the frame specified in BATON, return the value of register - REGNUM, treated as an unsigned integer. */ + REGNUM, treated as a pointer. */ static CORE_ADDR dwarf_expr_read_reg (void *baton, int dwarf_regnum) { struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton; + struct value *value; CORE_ADDR result; - gdb_byte *buf; - int regnum, regsize; + int regnum; regnum = DWARF2_REG_TO_REGNUM (dwarf_regnum); - regsize = register_size (current_gdbarch, regnum); - buf = alloca (regsize); - frame_register_read (debaton->frame, regnum, buf); - /* NOTE: cagney/2003-05-22: This extract is assuming that a DWARF 2 - address is always unsigned. That may or may not be true. */ - result = extract_unsigned_integer (buf, regsize); + value = value_from_register (builtin_type_void_data_ptr, + regnum, debaton->frame); + + result = value_as_address (value); + release_value (value); + value_free (value); return result; } -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com