From patchwork Sun Dec 17 19:14:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 24982 Received: (qmail 28098 invoked by alias); 17 Dec 2017 19:14:08 -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 28081 invoked by uid 89); 17 Dec 2017 19:14:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 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= X-HELO: mail-io0-f182.google.com Received: from mail-io0-f182.google.com (HELO mail-io0-f182.google.com) (209.85.223.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Dec 2017 19:14:06 +0000 Received: by mail-io0-f182.google.com with SMTP id o2so7602710ioe.8 for ; Sun, 17 Dec 2017 11:14:06 -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:in-reply-to:references:from:date :message-id:subject:to:cc; bh=mj4CyafbVDCu4MiWWIf9q1PTAdPVp+cBMhmx0yJHVks=; b=Q6/R42l7ZcnOjzddAsWCEJe5Hy2SEBiZypb3n7Q4Iay18mF22LOvh+Y0lWTQUL5zL+ l9gecv0mE5sYOQoFpCygMV5M7J/DGQ3ypyOOddXBJ9HuDV9C2aJP0nxRTRKYsrJ+t4Hx /DbQQh83BUbvp9NePhI6dYorpexvtepfC0uWsa/QMaK7aNbK3Apq5/1NmhPlQe9hb7G+ iCRwQUi5w1Wy7MXX6W+WWIulehTs3mzEkwVk9FfVEIBZnywcEhyXXOeGLkJX1A0DvYqT QpRzC/R1U/P+b8/kAF0Hh/EmhSa6hpgJTZrpKq+HxtsueRTjqkbtpTk3rNrnh4jZ11uF Yzkg== X-Gm-Message-State: AKGB3mJSI5XBbuZnYhYAlRx1fdeR2DTYE/5eA9prz5ohpqlL0OVM6W24 ymSeIBxhBGp9HfoalGEotB00MbPK7F43lOTTMIU= X-Google-Smtp-Source: ACJfBoswUoekts0XK5ObI5IDWIp9f8uqKdpEbmwPbViGRhYgqlMHvpEj6/fSffVfm0pT0Cjx0Abx2ZB5y/OZCTgTxDE= X-Received: by 10.107.35.140 with SMTP id j134mr17581834ioj.166.1513538044829; Sun, 17 Dec 2017 11:14:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.43.85 with HTTP; Sun, 17 Dec 2017 11:14:04 -0800 (PST) In-Reply-To: References: From: Uros Bizjak Date: Sun, 17 Dec 2017 20:14:04 +0100 Message-ID: Subject: Re: [PATCH]: Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha To: Pedro Alves Cc: gdb-patches@sourceware.org, Richard Henderson , Tobias Klausmann On Sun, Dec 17, 2017 at 7:11 PM, Uros Bizjak wrote: > On Fri, Dec 15, 2017 at 7:21 PM, Pedro Alves wrote: >> On 12/15/2017 12:11 PM, Uros Bizjak wrote: >>> >>> Please note that I have no commit access, so if approved, please >>> commit the patch to the source repository for me. >> >> Merged. > > Thanks! > > Attached, please find a patch for gdb-8.0 branch. The patch is tested > in the same way as the patch for mainline, with native > alphaev68-linux-gnu build and tests and with gcc's guality.exp and > simulate-thread.exp testcases. This one is the correct one. Sorry, for the confusion, Uros. diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 7c521db24c..2302e6ded3 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 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)