Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gdb/dist/gdb Skip the initial GP load in funct...



details:   https://anonhg.NetBSD.org/src/rev/8327392b962d
branches:  trunk
changeset: 819729:8327392b962d
user:      rin <rin%NetBSD.org@localhost>
date:      Thu Dec 15 10:01:16 2016 +0000

description:
Skip the initial GP load in function prologue when inserting a breakpoint.

GNU ld for alpha is so clever that the redundant GP load in function
entrypoint is skipped. we must therefore skip initial GP loads; otherwise
breakpoints in function entrypoints can also be skipped.

Reported to upstream (Bug 20969):
  https://sourceware.org/bugzilla/show_bug.cgi?id=20969

ok martin

diffstat:

 external/gpl3/gdb/dist/gdb/alpha-tdep.c |  28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diffs (45 lines):

diff -r 61dcfb7749dc -r 8327392b962d external/gpl3/gdb/dist/gdb/alpha-tdep.c
--- a/external/gpl3/gdb/dist/gdb/alpha-tdep.c   Thu Dec 15 09:39:24 2016 +0000
+++ b/external/gpl3/gdb/dist/gdb/alpha-tdep.c   Thu Dec 15 10:01:16 2016 +0000
@@ -757,6 +757,31 @@
   return pc + offset;
 }
 
+/* GNU ld for alpha is so clever that the redundant GP load in function
+   entrypoint is skipped.  We must therefore skip initial GP loads; otherwise
+   breakpoints in function entrypoints can also be skipped.  */
+
+static CORE_ADDR
+alpha_skip_entrypoint (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+  unsigned long inst;
+  gdb_byte buf[ALPHA_INSN_SIZE];
+
+  /* Refer to the comment in alpha_skip_prologue above.  */
+  if (target_read_memory (pc, buf, sizeof (buf)))
+    return pc;
+
+  /* Skip a GP load in the first two words in the function entrypoint.  */
+  inst = alpha_read_insn (gdbarch, pc);
+  if ((inst & 0xffff0000) != 0x27bb0000)       /* ldah $gp,n($t12) */
+    return pc;
+  inst = alpha_read_insn (gdbarch, pc + ALPHA_INSN_SIZE);
+  if ((inst & 0xffff0000) != 0x23bd0000)       /* lda $gp,n($gp) */
+    return pc;
+
+  return pc + 2 * ALPHA_INSN_SIZE;
+}
+
 
 static const int ldl_l_opcode = 0x2a;
 static const int ldq_l_opcode = 0x2b;
@@ -1802,6 +1827,9 @@
   /* Prologue heuristics.  */
   set_gdbarch_skip_prologue (gdbarch, alpha_skip_prologue);
 
+  /* Entrypoint heuristics.  */
+  set_gdbarch_skip_entrypoint (gdbarch, alpha_skip_entrypoint);
+
   /* Disassembler.  */
   set_gdbarch_print_insn (gdbarch, print_insn_alpha);
 



Home | Main Index | Thread Index | Old Index