aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2018-01-03 15:14:12 +0000
committerPedro Alves <palves@redhat.com>2018-01-03 15:14:12 +0000
commitbd496067387a9c89a7e62bbba76e784634936932 (patch)
tree72f60034d605d510f0e06b1b558aacf91b7d11cf
parent8f108421329f4318c4467f751c270413119395d4 (diff)
downloadfsf-binutils-gdb-bd496067387a9c89a7e62bbba76e784634936932.zip
fsf-binutils-gdb-bd496067387a9c89a7e62bbba76e784634936932.tar.gz
fsf-binutils-gdb-bd496067387a9c89a7e62bbba76e784634936932.tar.bz2
Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha
This fixes PR19061, where gdb hangs/spins-on-cpu when debugging any program on Alpha. (This patch is Uros' forward port of the patch from comment #5 of the PR [1].) Patch was tested on alphaev68-linux-gnu, also tested with gcc's testsuite, where it fixed all hangs in guality.exp and simulate-thread.exp testcases. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=19061#c5 gdb/ChangeLog: 2018-01-03 Richard Henderson <rth@redhat.com> Uros Bizjak <ubizjak@gmail.com> PR gdb/19061 * alpha-tdep.c (alpha_deal_with_atomic_sequence): Change prototype. (alpha_software_single_step): Call alpha_deal_with_atomic_sequence here. (set_gdbarch_software_single_step): Set to alpha_software_single_step. * nat/linux-ptrace.h [__alpha__]: Define GDB_ARCH_IS_TRAP_BRKPT and GDB_ARCH_IS_TRAP_HWBKPT.
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/alpha-tdep.c17
-rw-r--r--gdb/nat/linux-ptrace.h5
3 files changed, 28 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bfa2359..b80bc98 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@
+2018-01-03 Richard Henderson <rth@redhat.com>
+ Uros Bizjak <ubizjak@gmail.com>
+
+ PR gdb/19061
+ * alpha-tdep.c (alpha_deal_with_atomic_sequence): Change
+ prototype.
+ (alpha_software_single_step): Call alpha_deal_with_atomic_sequence
+ here.
+ (set_gdbarch_software_single_step): Set to
+ alpha_software_single_step.
+ * nat/linux-ptrace.h [__alpha__]: Define GDB_ARCH_IS_TRAP_BRKPT
+ and GDB_ARCH_IS_TRAP_HWBKPT.
+
2017-10-25 Leszek Swirski <leszeks@google.com>
* dwarf2read.c (dwarf2_string_attr): Allow DW_FORM_GNU_str_index.
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 7c521db..2302e6d 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -766,10 +766,8 @@ static const int stq_c_opcode = 0x2f;
the sequence. */
static VEC (CORE_ADDR) *
-alpha_deal_with_atomic_sequence (struct regcache *regcache)
+alpha_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- CORE_ADDR pc = regcache_read_pc (regcache);
CORE_ADDR breaks[2] = {-1, -1};
CORE_ADDR loc = pc;
CORE_ADDR closing_insn; /* Instruction that closes the atomic sequence. */
@@ -1721,12 +1719,17 @@ VEC (CORE_ADDR) *
alpha_software_single_step (struct regcache *regcache)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
- CORE_ADDR pc;
- VEC (CORE_ADDR) *next_pcs = NULL;
+ CORE_ADDR pc, next_pc;
+ VEC (CORE_ADDR) *next_pcs;
pc = regcache_read_pc (regcache);
+ next_pcs = alpha_deal_with_atomic_sequence (gdbarch, pc);
+ if (next_pcs != NULL)
+ return next_pcs;
+
+ next_pc = alpha_next_pc (regcache, pc);
- VEC_safe_push (CORE_ADDR, next_pcs, alpha_next_pc (regcache, pc));
+ VEC_safe_push (CORE_ADDR, next_pcs, next_pc);
return next_pcs;
}
@@ -1826,7 +1829,7 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_cannot_step_breakpoint (gdbarch, 1);
/* Handles single stepping of atomic sequences. */
- set_gdbarch_software_single_step (gdbarch, alpha_deal_with_atomic_sequence);
+ set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index 5954945..8a8c4c6 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -155,6 +155,8 @@ struct buffer;
Beginning with Linux 4.6, the MIPS port reports proper TRAP_BRKPT and
TRAP_HWBKPT codes, so we also match them.
+ The Alpha kernel uses TRAP_BRKPT for all traps.
+
The generic Linux target code should use GDB_ARCH_IS_TRAP_* instead
of TRAP_* to abstract out these peculiarities. */
#if defined __i386__ || defined __x86_64__
@@ -166,6 +168,9 @@ struct buffer;
#elif defined __mips__
# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == SI_KERNEL || (X) == TRAP_BRKPT)
# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == SI_KERNEL || (X) == TRAP_HWBKPT)
+#elif defined __alpha__
+# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == TRAP_BRKPT)
+# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_BRKPT)
#else
# define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == TRAP_BRKPT)
# define GDB_ARCH_IS_TRAP_HWBKPT(X) ((X) == TRAP_HWBKPT)