Module Name:    src
Committed By:   rin
Date:           Thu Dec 15 10:01:16 UTC 2016

Modified Files:
        src/external/gpl3/gdb/dist/gdb: alpha-tdep.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.5 -r1.2 src/external/gpl3/gdb/dist/gdb/alpha-tdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gdb/dist/gdb/alpha-tdep.c
diff -u src/external/gpl3/gdb/dist/gdb/alpha-tdep.c:1.1.1.5 src/external/gpl3/gdb/dist/gdb/alpha-tdep.c:1.2
--- src/external/gpl3/gdb/dist/gdb/alpha-tdep.c:1.1.1.5	Wed Oct 12 16:47:13 2016
+++ src/external/gpl3/gdb/dist/gdb/alpha-tdep.c	Thu Dec 15 10:01:16 2016
@@ -757,6 +757,31 @@ alpha_skip_prologue (struct gdbarch *gdb
   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 @@ alpha_gdbarch_init (struct gdbarch_info 
   /* 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);
 

Reply via email to