1 2004-06-22 Andrew Cagney <cagney@gnu.org>
3 * rs6000-tdep.c (struct rs6000_framedata): Add field "func_start".
4 (skip_prologue): Delete local variable "orig_pc", use
5 "func_start". Add local variable "num_skip_linux_syscall_insn",
6 use to skip over first half of a GNU/Linux syscall and update
9 Index: gdb-6.8/gdb/rs6000-tdep.c
10 ===================================================================
11 --- gdb-6.8.orig/gdb/rs6000-tdep.c 2008-02-20 15:34:43.000000000 +0100
12 +++ gdb-6.8/gdb/rs6000-tdep.c 2008-07-14 10:25:29.000000000 +0200
13 @@ -124,6 +124,7 @@ static const char *powerpc_vector_abi_st
15 struct rs6000_framedata
17 + CORE_ADDR func_start; /* True function start. */
18 int offset; /* total size of frame --- the distance
19 by which we decrement sp to allocate
21 @@ -1262,7 +1263,6 @@ static CORE_ADDR
22 skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
23 struct rs6000_framedata *fdata)
25 - CORE_ADDR orig_pc = pc;
26 CORE_ADDR last_prologue_pc = pc;
27 CORE_ADDR li_found_pc = 0;
29 @@ -1280,11 +1280,13 @@ skip_prologue (struct gdbarch *gdbarch,
30 int minimal_toc_loaded = 0;
31 int prev_insn_was_prologue_insn = 1;
32 int num_skip_non_prologue_insns = 0;
33 + int num_skip_ppc64_gnu_linux_syscall_insn = 0;
34 int r0_contains_arg = 0;
35 const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
36 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
38 memset (fdata, 0, sizeof (struct rs6000_framedata));
39 + fdata->func_start = pc;
40 fdata->saved_gpr = -1;
41 fdata->saved_fpr = -1;
43 @@ -1313,6 +1315,55 @@ skip_prologue (struct gdbarch *gdbarch,
45 op = extract_unsigned_integer (buf, 4);
47 + /* A PPC64 GNU/Linux system call function is split into two
48 + sub-functions: a non-threaded fast-path (__NAME_nocancel)
49 + which does not use a frame; and a threaded slow-path
50 + (Lpseudo_cancel) that does create a frame. Ref:
51 + nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
56 + bne- .Lpseudo_cancel
61 + b 0x7fe014ef64 <.__syscall_error>
67 + Unfortunatly, because the latter case uses a local label (not
68 + in the symbol table) a PC in "Lpseudo_cancel" appears to be
69 + in "__NAME_nocancel". The following code recognizes this,
70 + adjusting FUNC_START to point to where "Lpseudo_cancel"
71 + should be, and parsing the prologue sequence as if
72 + "Lpseudo_cancel" was the entry point. */
74 + if (((op & 0xffff0000) == 0x38000000 /* li r0,N */
75 + && pc == fdata->func_start + 0
76 + && num_skip_ppc64_gnu_linux_syscall_insn == 0)
77 + || (op == 0x44000002 /* sc */
78 + && pc == fdata->func_start + 4
79 + && num_skip_ppc64_gnu_linux_syscall_insn == 1)
80 + || (op == 0x4ca30020 /* bnslr+ */
81 + && pc == fdata->func_start + 8
82 + && num_skip_ppc64_gnu_linux_syscall_insn == 2))
84 + num_skip_ppc64_gnu_linux_syscall_insn++;
87 + else if ((op & 0xfc000003) == 0x48000000 /* b __syscall_error */
88 + && pc == fdata->func_start + 12
89 + && num_skip_ppc64_gnu_linux_syscall_insn == 3)
91 + num_skip_ppc64_gnu_linux_syscall_insn = -1;
92 + fdata->func_start = pc;
96 if ((op & 0xfc1fffff) == 0x7c0802a6)
98 /* Since shared library / PIC code, which needs to get its
99 @@ -1486,9 +1537,9 @@ skip_prologue (struct gdbarch *gdbarch,
100 we have no line table information or the line info tells
101 us that the subroutine call is not part of the line
102 associated with the prologue. */
103 - if ((pc - orig_pc) > 8)
104 + if ((pc - fdata->func_start) > 8)
106 - struct symtab_and_line prologue_sal = find_pc_line (orig_pc, 0);
107 + struct symtab_and_line prologue_sal = find_pc_line (fdata->func_start, 0);
108 struct symtab_and_line this_sal = find_pc_line (pc, 0);
110 if ((prologue_sal.line == 0) || (prologue_sal.line != this_sal.line))