From: Simon Marchi <simon.marchi@ericsson.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, Uros Bizjak <ubizjak@gmail.com>
Cc: <gdb-patches@sourceware.org>,
Tobias Klausmann <klausman@schwarzvogel.de>, <rth@twiddle.net>
Subject: Re: [PATCH]: Fix PR19061, gdb hangs/spins-on-cpu when debugging any program on Alpha
Date: Thu, 31 May 2018 16:18:00 -0000 [thread overview]
Message-ID: <94b25728-eef3-e23d-6582-6cb01602342d@ericsson.com> (raw)
In-Reply-To: <4a93db59737d2b7ebbea5982180f16d2@polymtl.ca>
On 2018-05-31 10:36 AM, Simon Marchi wrote:
> On 2018-05-31 05:23, Uros Bizjak wrote:
>> On Wed, May 30, 2018 at 4:53 PM, Simon Marchi <simon.marchi@ericsson.com> wrote:
>>> 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.
>
> TRAP_BKPT and TRAP_HWBKPT are different, so this will never happen with the default definitions of GDB_ARCH_IS_TRAP_BRKPT/GDB_ARCH_IS_TRAP_HWBKPT. Since the kernel for alpha never sets si_code to TRAP_HWBKPT, it means we'll never get in to the HW breakpoint branch, which is fine.
>
> In short, the patch LGTM.
>
>> I have tested the attached patch, and resulting gdb works OK for me.
>
> Thanks!
>
> Simon
Since Uros doesn't have write access, I wrote a commit log and pushed
the patch.
Simon
From 8a60efe714e636c9f958058a8dfb12de81bdcbfa Mon Sep 17 00:00:00 2001
From: Uros Bizjak <ubizjak@gmail.com>
Date: Thu, 31 May 2018 11:18:02 -0400
Subject: [PATCH] Fix Alpha native GDB build
[Commit log by Simon Marchi]
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))
^~~~~~~~~~~~~~~~~~~~~~
For Alpha, we currently define GDB_ARCH_IS_TRAP_BRKPT and
GDB_ARCH_IS_TRAP_HWBKPT both to ((X) == TRAP_BRKPT), which causes the
two if branches to be duplicated.
Alpha doesn't have hardware breakpoints, so the Linux kernel for Alpha
never sets si_code to TRAP_HWBKPT. We can just remove the special
definitions of these macros for __alpha__ and rely on the default ones.
Since the kernel will never report TRAP_HWBKPT, we will just never enter
the "hardware breakpoint" branch on Alpha (which is fine since it
doesn't have them).
gdb/ChangeLog:
* nat/linux-ptrace.h [__alpha__]
(GDB_ARCH_IS_TRAP_BRKPT, GDB_ARCH_IS_TRAP_HWBKPT): Remove
definitions.
---
gdb/ChangeLog | 6 ++++++
gdb/nat/linux-ptrace.h | 5 -----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c6c862f..8af7e67 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-31 Uros Bizjak <ubizjak@gmail.com>
+
+ * nat/linux-ptrace.h [__alpha__]
+ (GDB_ARCH_IS_TRAP_BRKPT, GDB_ARCH_IS_TRAP_HWBKPT): Remove
+ definitions.
+
2018-05-31 Maciej W. Rozycki <macro@mips.com>
* arch-utils.c (gdbarch_info_fill): Set `default_byte_order' to
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index dc180fb..98b44a8 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)
--
2.7.4
prev parent reply other threads:[~2018-05-31 15:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 12:11 Uros Bizjak
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 [this message]
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=94b25728-eef3-e23d-6582-6cb01602342d@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=klausman@schwarzvogel.de \
--cc=rth@twiddle.net \
--cc=simon.marchi@polymtl.ca \
--cc=ubizjak@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).