From patchwork Thu May 31 09:23:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 27590 Received: (qmail 50584 invoked by alias); 31 May 2018 09:23:24 -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 50573 invoked by uid 89); 31 May 2018 09:23:24 -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=v4 X-HELO: mail-io0-f195.google.com Received: from mail-io0-f195.google.com (HELO mail-io0-f195.google.com) (209.85.223.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 May 2018 09:23:22 +0000 Received: by mail-io0-f195.google.com with SMTP id g7-v6so1174962ioh.11 for ; Thu, 31 May 2018 02:23:22 -0700 (PDT) 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=A9maO6ok+kMK2PCbX0ZWpSq7WAyZqcVcQebwJCXpW8Y=; b=hjnPND3GgmyfUrN7jn+F/hy/4QQCHz+zqYPlK1GTfonJoGC+vCmjpq/cxtK+ieoTwu EAcAD+D8YZFFuq3WVmCEzmwEnpzpijuXO8/XoldcyyMYxzmvvCKfbFaWWL2i/UH4pC5l 9TBZzGtMBc63CD6aktOyaE1EcW5CmMgruuT2O90w6CEmXBF+AJN3W/4zm+1pRu59Lx/+ fReGAfHCRdDNDLryEuiIdfh4gDozT9taLGH0MEySWNwzwzUj8TL6IOKgBMiDkDdPaDXH nbwOQDF1Ckrp7n4qE+mKMHTQhznUnF9rDwmxvp+tHBQRdIjHh+9ALRMdF2nx6valeSpW Xtxw== X-Gm-Message-State: ALKqPweipdVKT9KPG1t9K3aS4jasTZLVHblama1TuPWtwSZmVQcKbTO/ LauqRxFIKxAG5Qd9EciGEC1iPJ4NuPd1TtqF7+8= X-Google-Smtp-Source: ADUXVKJGVWvAKFuB7dAtw4sTHoXia0Uc4nRsEPsW0OWs2Pw6FDY5+zeKqg3u72uXt18pGViaLP0BcIKtJdd1dhUdlao= X-Received: by 2002:a6b:bc06:: with SMTP id m6-v6mr5375822iof.205.1527758600607; Thu, 31 May 2018 02:23:20 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:b815:0:0:0:0:0 with HTTP; Thu, 31 May 2018 02:23:20 -0700 (PDT) In-Reply-To: <56293ba8-f95b-5da1-af14-7500a0f8f892@ericsson.com> References: <56293ba8-f95b-5da1-af14-7500a0f8f892@ericsson.com> From: Uros Bizjak Date: Thu, 31 May 2018 11:23:20 +0200 Message-ID: Subject: Re: [PATCH]: Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha To: Simon Marchi Cc: gdb-patches@sourceware.org, Tobias Klausmann , rth@twiddle.net On Wed, May 30, 2018 at 4:53 PM, Simon Marchi wrote: > On 2017-12-15 07:11 AM, Uros Bizjak wrote: >> 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. >> > > Hi Uros and Richard, > > I would need your input. Using this cross-compiler: > > alphaev67-unknown-linux-gnu-gcc (crosstool-NG crosstool-ng-1.22.0-677-ga3dd55b9) 6.3.0 > Copyright (C) 2016 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > I get this error: > > CXX linux-nat.o > /home/simark/src/binutils-gdb/gdb/linux-nat.c: In function 'void save_stop_reason(lwp_info*)': > /home/simark/src/binutils-gdb/gdb/linux-nat.c:2718:9: error: duplicated 'if' condition [-Werror=duplicated-cond] > else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code)) > ^~ > In file included from /home/simark/src/binutils-gdb/gdb/linux-nat.c:31:0: > /home/simark/src/binutils-gdb/gdb/nat/linux-ptrace.h:173:41: note: previously used here > # define GDB_ARCH_IS_TRAP_BRKPT(X) ((X) == TRAP_BRKPT) > ~~~~~^~~~~~~~~~~~~~ > /home/simark/src/binutils-gdb/gdb/linux-nat.c:2709:13: note: in expansion of macro 'GDB_ARCH_IS_TRAP_BRKPT' > else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)) > ^~~~~~~~~~~~~~~~~~~~~~ > > Does Alpha even have hardware breakpoints? If not, I would suggest > defining GDB_ARCH_IS_TRAP_HWBKPT to 0 for __alpha__. It would get > rid of the error, and be more exact (no si_code can mean "hardware > breakpoint" on alpha). I didn't find any mentions of hardware breakpoint support in Alpha Architecture Handbook v.4. Please note that save_stop_reason from linux-nat.c has some code to detect ambigous si_code, where si_code is both TRAP_BRKPT and TRAP_HWBKPT, and returns TARGET_STOPPED_BY_SW_BREAKPOINT in this case. So, if we don't define anything for __alpha__ in nat/linux-ptrace.h, we get the same result. I have tested the attached patch, and resulting gdb works OK for me. gdb/ChangeLog: 2018-05-31 Uros Bizjak * nat/linux-ptrace.h [__alpha__]: Remove definitions. --cut here-- --cut here-- Uros. diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h index dc180fbf82..98b44a82a6 100644 --- a/gdb/nat/linux-ptrace.h +++ b/gdb/nat/linux-ptrace.h @@ -156,8 +156,6 @@ 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__ @@ -169,9 +167,6 @@ 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)