From patchwork Fri Dec 15 12:11:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 24963 Received: (qmail 14257 invoked by alias); 15 Dec 2017 12:11:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 14243 invoked by uid 89); 15 Dec 2017 12:11:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Beginning, hello!, bizjak, gdb8 X-HELO: mail-it0-f41.google.com Received: from mail-it0-f41.google.com (HELO mail-it0-f41.google.com) (209.85.214.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Dec 2017 12:11:39 +0000 Received: by mail-it0-f41.google.com with SMTP id 68so18484513ite.4 for ; Fri, 15 Dec 2017 04:11:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=d68rmv4Z+dU7TNkMSGpgLa34gWkFPEuTIFYmpEXsCvk=; b=cQ4d4zBJ8lXGYKakbgl65Hdv5sn2DX9e9Omq+ihiIi8k7SZk0RFhsAr80gBaK26ucs MGQReNFoJhddZ9niK9EgLI5oNuAkmq0lsT+llks4LYUzgUWOVz9q/f8KhPAnFT+qbdVb nnwoxuqjkeD+bu8gChuAdIBEUmqQvUqFLGHxnU8GdJvzr74hRhLqmHj1nxq6QZaPuTEI OWlmJ1cfZtJDaf/J6b0p4eT3D9P4kc+N8jdduawRjJLzC50oCrcDvVqHx3iTQjoiZmd6 bUFtqGsdxXsYRVnO5vHEV8uH5OkKOg+uhGzauIBk1pd16yE4Iv03s/iiw2sCl67sbLZ5 Y1aA== X-Gm-Message-State: AKGB3mKsyxpN9Qio+UECovKlDccUyExpEGBZMnbdXXTZKnoFJLLU7bmG cwyOLZdxzkIYUbM5E+qz1I6TBnXzeaAU52KsdukDiA== X-Google-Smtp-Source: ACJfBos/8g8Jf2ZFuP/QwGJ5DGFirrOi26Eg13jQo/PxXWmqMO0nLb6dE4UdGn+a4Pisn04X+ZUMOcM1U7wVys5JIyU= X-Received: by 10.107.35.140 with SMTP id j134mr8551423ioj.166.1513339897240; Fri, 15 Dec 2017 04:11:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.43.85 with HTTP; Fri, 15 Dec 2017 04:11:36 -0800 (PST) From: Uros Bizjak Date: Fri, 15 Dec 2017 13:11:36 +0100 Message-ID: Subject: [PATCH]: Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha To: gdb-patches@sourceware.org Cc: Richard Henderson , Tobias Klausmann 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 Richard Henderson 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. 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 -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 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 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}; } @@ -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)