From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9206 invoked by alias); 17 Apr 2002 22:46:09 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 9177 invoked from network); 17 Apr 2002 22:46:06 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 17 Apr 2002 22:46:06 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 0147F3D0C for ; Wed, 17 Apr 2002 18:46:15 -0400 (EDT) Message-ID: <3CBDFB36.2030605@cygnus.com> Date: Wed, 17 Apr 2002 15:46:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.9) Gecko/20020328 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [rfa:rs6000] Simplify alloca reg fetch Content-Type: multipart/mixed; boundary="------------040904010607040304030601" X-SW-Source: 2002-04/txt/msg00573.txt.bz2 This is a multi-part message in MIME format. --------------040904010607040304030601 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 320 Hello, The attatched replaces some hardwired code for fetching the alloca register with a call to frame_register_read(). The code is equivalent (except for the case where, for some reason, the register isn't available where the new code is more robust). (This is what was breaking the register cache code). Andrew --------------040904010607040304030601 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 2426 2002-04-17 Andrew Cagney * rs6000-tdep.c (frame_initial_stack_address): Use frame_register_read to read the alloca_reg. Index: rs6000-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v retrieving revision 1.55 diff -u -r1.55 rs6000-tdep.c --- rs6000-tdep.c 12 Apr 2002 19:48:36 -0000 1.55 +++ rs6000-tdep.c 17 Apr 2002 22:42:30 -0000 @@ -1488,41 +1488,22 @@ return fi->extra_info->initial_sp; } - /* This function has an alloca register. If this is the top-most frame - (with the lowest address), the value in alloca register is good. */ - - if (!fi->next) - return fi->extra_info->initial_sp = read_register (fdata.alloca_reg); - - /* Otherwise, this is a caller frame. Callee has usually already saved - registers, but there are exceptions (such as when the callee - has no parameters). Find the address in which caller's alloca - register is saved. */ - - for (callee_fi = fi->next; callee_fi; callee_fi = callee_fi->next) - { - - if (!callee_fi->saved_regs) - frame_get_saved_regs (callee_fi, NULL); - - /* this is the address in which alloca register is saved. */ - - tmpaddr = callee_fi->saved_regs[fdata.alloca_reg]; - if (tmpaddr) - { - fi->extra_info->initial_sp = - read_memory_addr (tmpaddr, TDEP->wordsize); - return fi->extra_info->initial_sp; - } - - /* Go look into deeper levels of the frame chain to see if any one of - the callees has saved alloca register. */ - } - - /* If alloca register was not saved, by the callee (or any of its callees) - then the value in the register is still good. */ - - fi->extra_info->initial_sp = read_register (fdata.alloca_reg); + /* There is an alloca register, use its value, in the current frame, + as the initial stack pointer. */ + { + char *tmpbuf = alloca (MAX_REGISTER_RAW_SIZE); + if (frame_register_read (fi, fdata.alloca_reg, tmpbuf)) + { + fi->extra_info->initial_sp + = extract_unsigned_integer (tmpbuf, + REGISTER_RAW_SIZE (fdata.alloca_reg)); + } + else + /* NOTE: cagney/2002-04-17: At present the only time + frame_register_read will fail is when the register isn't + available. If that does happen, use the frame. */ + fi->extra_info->initial_sp = fi->frame; + } return fi->extra_info->initial_sp; } --------------040904010607040304030601--