From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22354 invoked by alias); 16 Mar 2004 22:28:55 -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 22311 invoked from network); 16 Mar 2004 22:28:54 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 16 Mar 2004 22:28:54 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 522A32B92; Tue, 16 Mar 2004 17:28:54 -0500 (EST) Message-ID: <40577FA6.5080506@gnu.org> Date: Fri, 19 Mar 2004 00:09:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-GB; rv:1.4.1) Gecko/20040217 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [rfa/ppc] prologue parser tweaks Content-Type: multipart/mixed; boundary="------------010005080702050003020108" X-SW-Source: 2004-03/txt/msg00371.txt.bz2 Message-ID: <20040319000900.j_spKakNSwAVZP9p2gQndyDyOduBighV0rvdNhjZDbM@z> This is a multi-part message in MIME format. --------------010005080702050003020108 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 524 Hello, Attached are two tweaks to the PPC skip_prologue method so that it works better with glibc: - handle glibc syscall Without this an unwinder won't be able to find its way out of a system call - it needs to figure out the location of a local label, see comment for details. - handle PIC code where the LR appears to be saved twice It appears that skip_prologue code tried to handle this but missed an edge case. Without this the wrong LR gets used when trying to unwind out of GLIBC. Ok for mainline? Andrew --------------010005080702050003020108 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 3171 2004-03-07 Andrew Cagney * rs6000-tdep.c: Add field "func_start". (skip_prologue): New variable num_skip_syscall_insn, use to skip over first half of a GNU/Linux syscall and update "func_start". Record only the first LR save, use to skip over PIC code. Index: rs6000-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v retrieving revision 1.183 diff -u -r1.183 rs6000-tdep.c --- rs6000-tdep.c 2 Mar 2004 02:20:25 -0000 1.183 +++ rs6000-tdep.c 16 Mar 2004 22:08:24 -0000 @@ -65,6 +65,7 @@ struct rs6000_framedata { + CORE_ADDR func_start; /* true function start */ int offset; /* total size of frame --- the distance by which we decrement sp to allocate the frame */ @@ -502,6 +503,7 @@ int minimal_toc_loaded = 0; int prev_insn_was_prologue_insn = 1; int num_skip_non_prologue_insns = 0; + int num_skip_syscall_insn = 0; const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (current_gdbarch); struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); @@ -521,6 +523,7 @@ lim_pc = refine_prologue_limit (pc, lim_pc); memset (fdata, 0, sizeof (struct rs6000_framedata)); + fdata->func_start = pc; fdata->saved_gpr = -1; fdata->saved_fpr = -1; fdata->saved_vr = -1; @@ -548,6 +551,70 @@ if (target_read_memory (pc, buf, 4)) break; op = extract_signed_integer (buf, 4); + + /* A PPC64 GNU/Linux system call function starts with a + non-threaded fast-path, only when that fails is a stack frame + created, treat it as several functions: + nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h + + *INDENT-OFF* + NAME: + SINGLE_THREAD_P + bne- .Lpseudo_cancel + __NAME_nocancel: + li r0,162 + sc + bnslr+ + b 0x7fe014ef64 <.__syscall_error> + Lpseudo_cancel: + stdu r1,-128(r1) + ... + *INDENT-ON* */ + + if (((op & 0xffff0000) == 0x38000000 /* li r0,N */ + && pc == fdata->func_start + 0) + || (op == 0x44000002 /* sc */ + && pc == fdata->func_start + 4 + && num_skip_syscall_insn == 1) + || (op == 0x4ca30020 /* bnslr+ */ + && pc == fdata->func_start + 8 + && num_skip_syscall_insn == 2)) + { + num_skip_syscall_insn++; + continue; + } + else if ((op & 0xfc000003) == 0x48000000 /* b __syscall_error */ + && pc == fdata->func_start + 12 + && num_skip_syscall_insn == 3) + { + num_skip_syscall_insn++; + fdata->func_start = pc; + continue; + } + + if ((op & 0xfc1fffff) == 0x7c0802a6) + { /* mflr Rx */ + /* Since shared library / PIC code, which needs to get its + address at runtime, can appear to save more than one link + register vis: + + *INDENT-OFF* + stwu r1,-304(r1) + mflr r3 + bl 0xff570d0 (blrl) + stw r30,296(r1) + mflr r30 + stw r31,300(r1) + stw r3,308(r1); + ... + *INDENT-ON* + + remember just the first one, but skip over additional + ones. */ + if (lr_reg < 0) + lr_reg = (op & 0x03e00000); + continue; + } if ((op & 0xfc1fffff) == 0x7c0802a6) { /* mflr Rx */ --------------010005080702050003020108--