Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: gdb-patches@sourceware.org
Cc: Richard Henderson <rth@redhat.com>,
	Tobias Klausmann <klausman@schwarzvogel.de>
Subject: [PATCH]: Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha
Date: Fri, 15 Dec 2017 12:11:00 -0000	[thread overview]
Message-ID: <CAFULd4ZGUgGneAb9m_Z=9HeKjjcXpv4mtp=uWbf98-XH43ptxA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]

Hello!

Attached patch fixes PR19061, where gdb hangs/spins-on-cpu when
debugging any program on Alpha. The patch is effectively a forward
port of Richard's patch from the Comment #5 of the PR [1].


2017-12-15  Uros Bizjak  <ubizjak@gmail.com>
        Richard Henderson  <rth@redhat.com>

    PR gdb/19061
    * alpha-tdep.c (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.

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.

Please note that I have no commit access, so if approved, please
commit the patch to the source repository for me. I also have
functionally equivalent patch for gdb-8 branch which I plan to submit
later.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=19061#c5

Uros.

[-- Attachment #2: gdb-mainline.diff.txt --]
[-- Type: text/plain, Size: 2677 bytes --]

diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 21199bd988..f09050a73d 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -767,10 +767,8 @@ static const int stq_c_opcode = 0x2f;
    the sequence.  */
 
 static std::vector<CORE_ADDR>
-alpha_deal_with_atomic_sequence (struct regcache *regcache)
+alpha_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  struct gdbarch *gdbarch = regcache->arch ();
-  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.  */
@@ -1723,9 +1721,19 @@ alpha_next_pc (struct regcache *regcache, CORE_ADDR pc)
 std::vector<CORE_ADDR>
 alpha_software_single_step (struct regcache *regcache)
 {
-  CORE_ADDR pc = alpha_next_pc (regcache, regcache_read_pc (regcache));
+  struct gdbarch *gdbarch = regcache->arch ();
+  CORE_ADDR pc, next_pc;
+
+  pc = regcache_read_pc (regcache);
+  std::vector<CORE_ADDR> next_pcs
+    = alpha_deal_with_atomic_sequence (gdbarch, pc);
+
+  if (!next_pcs.empty ())
+    return next_pcs;
+
+  next_pc = alpha_next_pc (regcache, pc);
 
-  return {pc};
+  return {next_pc};
 }
 
 \f
@@ -1821,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 59549452c0..8a8c4c6d3e 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)

             reply	other threads:[~2017-12-15 12:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-15 12:11 Uros Bizjak [this message]
2017-12-15 18:21 ` Pedro Alves
2017-12-17 18:11   ` Uros Bizjak
2017-12-17 19:14     ` Uros Bizjak
2018-01-03 16:02       ` Pedro Alves
2018-05-30 18:07 ` Simon Marchi
2018-05-30 18:49   ` Uros Bizjak
2018-05-30 19:04     ` Simon Marchi
2018-05-31 11:10   ` Uros Bizjak
2018-05-31 14:55     ` Simon Marchi
2018-05-31 16:18       ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFULd4ZGUgGneAb9m_Z=9HeKjjcXpv4mtp=uWbf98-XH43ptxA@mail.gmail.com' \
    --to=ubizjak@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=klausman@schwarzvogel.de \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox