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