|
|
689258 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
689258 |
From: Andrew Cagney <cagney@gnu.org>
|
|
|
689258 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
689258 |
Subject: gdb-6.3-ppc64syscall-20040622.patch
|
|
|
689258 |
|
|
|
689258 |
;; Better parse 64-bit PPC system call prologues.
|
|
|
689258 |
;;=push: Write new testcase.
|
|
|
689258 |
|
|
|
689258 |
2004-06-22 Andrew Cagney <cagney@gnu.org>
|
|
|
689258 |
|
|
|
689258 |
* rs6000-tdep.c (struct rs6000_framedata): Add field "func_start".
|
|
|
689258 |
(skip_prologue): Delete local variable "orig_pc", use
|
|
|
689258 |
"func_start". Add local variable "num_skip_linux_syscall_insn",
|
|
|
689258 |
use to skip over first half of a GNU/Linux syscall and update
|
|
|
689258 |
"func_start".
|
|
|
689258 |
|
|
|
689258 |
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
|
|
|
689258 |
--- a/gdb/rs6000-tdep.c
|
|
|
689258 |
+++ b/gdb/rs6000-tdep.c
|
|
|
689258 |
@@ -134,6 +134,7 @@ static const char *powerpc_vector_abi_string = "auto";
|
|
|
689258 |
|
|
|
689258 |
struct rs6000_framedata
|
|
|
689258 |
{
|
|
|
689258 |
+ CORE_ADDR func_start; /* True function start. */
|
|
|
689258 |
int offset; /* total size of frame --- the distance
|
|
|
689258 |
by which we decrement sp to allocate
|
|
|
689258 |
the frame */
|
|
|
689258 |
@@ -1426,7 +1427,6 @@ static CORE_ADDR
|
|
|
689258 |
skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
|
|
|
689258 |
struct rs6000_framedata *fdata)
|
|
|
689258 |
{
|
|
|
689258 |
- CORE_ADDR orig_pc = pc;
|
|
|
689258 |
CORE_ADDR last_prologue_pc = pc;
|
|
|
689258 |
CORE_ADDR li_found_pc = 0;
|
|
|
689258 |
gdb_byte buf[4];
|
|
|
689258 |
@@ -1445,12 +1445,14 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
|
|
|
689258 |
int minimal_toc_loaded = 0;
|
|
|
689258 |
int prev_insn_was_prologue_insn = 1;
|
|
|
689258 |
int num_skip_non_prologue_insns = 0;
|
|
|
689258 |
+ int num_skip_ppc64_gnu_linux_syscall_insn = 0;
|
|
|
689258 |
int r0_contains_arg = 0;
|
|
|
689258 |
const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
|
|
|
689258 |
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
|
|
689258 |
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
689258 |
|
|
|
689258 |
memset (fdata, 0, sizeof (struct rs6000_framedata));
|
|
|
689258 |
+ fdata->func_start = pc;
|
|
|
689258 |
fdata->saved_gpr = -1;
|
|
|
689258 |
fdata->saved_fpr = -1;
|
|
|
689258 |
fdata->saved_vr = -1;
|
|
|
689258 |
@@ -1484,6 +1486,55 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
|
|
|
689258 |
break;
|
|
|
689258 |
op = extract_unsigned_integer (buf, 4, byte_order);
|
|
|
689258 |
|
|
|
689258 |
+ /* A PPC64 GNU/Linux system call function is split into two
|
|
|
689258 |
+ sub-functions: a non-threaded fast-path (__NAME_nocancel)
|
|
|
689258 |
+ which does not use a frame; and a threaded slow-path
|
|
|
689258 |
+ (Lpseudo_cancel) that does create a frame. Ref:
|
|
|
689258 |
+ nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
|
|
|
689258 |
+
|
|
|
689258 |
+ *INDENT-OFF*
|
|
|
689258 |
+ NAME:
|
|
|
689258 |
+ SINGLE_THREAD_P
|
|
|
689258 |
+ bne- .Lpseudo_cancel
|
|
|
689258 |
+ __NAME_nocancel:
|
|
|
689258 |
+ li r0,162
|
|
|
689258 |
+ sc
|
|
|
689258 |
+ bnslr+
|
|
|
689258 |
+ b 0x7fe014ef64 <.__syscall_error>
|
|
|
689258 |
+ Lpseudo_cancel:
|
|
|
689258 |
+ stdu r1,-128(r1)
|
|
|
689258 |
+ ...
|
|
|
689258 |
+ *INDENT-ON*
|
|
|
689258 |
+
|
|
|
689258 |
+ Unfortunatly, because the latter case uses a local label (not
|
|
|
689258 |
+ in the symbol table) a PC in "Lpseudo_cancel" appears to be
|
|
|
689258 |
+ in "__NAME_nocancel". The following code recognizes this,
|
|
|
689258 |
+ adjusting FUNC_START to point to where "Lpseudo_cancel"
|
|
|
689258 |
+ should be, and parsing the prologue sequence as if
|
|
|
689258 |
+ "Lpseudo_cancel" was the entry point. */
|
|
|
689258 |
+
|
|
|
689258 |
+ if (((op & 0xffff0000) == 0x38000000 /* li r0,N */
|
|
|
689258 |
+ && pc == fdata->func_start + 0
|
|
|
689258 |
+ && num_skip_ppc64_gnu_linux_syscall_insn == 0)
|
|
|
689258 |
+ || (op == 0x44000002 /* sc */
|
|
|
689258 |
+ && pc == fdata->func_start + 4
|
|
|
689258 |
+ && num_skip_ppc64_gnu_linux_syscall_insn == 1)
|
|
|
689258 |
+ || (op == 0x4ca30020 /* bnslr+ */
|
|
|
689258 |
+ && pc == fdata->func_start + 8
|
|
|
689258 |
+ && num_skip_ppc64_gnu_linux_syscall_insn == 2))
|
|
|
689258 |
+ {
|
|
|
689258 |
+ num_skip_ppc64_gnu_linux_syscall_insn++;
|
|
|
689258 |
+ continue;
|
|
|
689258 |
+ }
|
|
|
689258 |
+ else if ((op & 0xfc000003) == 0x48000000 /* b __syscall_error */
|
|
|
689258 |
+ && pc == fdata->func_start + 12
|
|
|
689258 |
+ && num_skip_ppc64_gnu_linux_syscall_insn == 3)
|
|
|
689258 |
+ {
|
|
|
689258 |
+ num_skip_ppc64_gnu_linux_syscall_insn = -1;
|
|
|
689258 |
+ fdata->func_start = pc;
|
|
|
689258 |
+ continue;
|
|
|
689258 |
+ }
|
|
|
689258 |
+
|
|
|
689258 |
if ((op & 0xfc1fffff) == 0x7c0802a6)
|
|
|
689258 |
{ /* mflr Rx */
|
|
|
689258 |
/* Since shared library / PIC code, which needs to get its
|
|
|
689258 |
@@ -1673,9 +1724,9 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
|
|
|
689258 |
we have no line table information or the line info tells
|
|
|
689258 |
us that the subroutine call is not part of the line
|
|
|
689258 |
associated with the prologue. */
|
|
|
689258 |
- if ((pc - orig_pc) > 8)
|
|
|
689258 |
+ if ((pc - fdata->func_start) > 8)
|
|
|
689258 |
{
|
|
|
689258 |
- struct symtab_and_line prologue_sal = find_pc_line (orig_pc, 0);
|
|
|
689258 |
+ struct symtab_and_line prologue_sal = find_pc_line (fdata->func_start, 0);
|
|
|
689258 |
struct symtab_and_line this_sal = find_pc_line (pc, 0);
|
|
|
689258 |
|
|
|
689258 |
if ((prologue_sal.line == 0)
|