Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Wilson <jimw@sifive.com>
To: gdb-patches@sourceware.org
Cc: Jim Wilson <jimw@sifive.com>,	andrew.burgess@embecosm.com
Subject: [PATCH] RISC-V: Don't decrement pc after break.
Date: Tue, 17 Jul 2018 00:12:00 -0000	[thread overview]
Message-ID: <20180717001241.25908-1-jimw@sifive.com> (raw)

This is the gdb patch for the RISC-V Linux kernel patch I just submitted.
    https://patchwork.kernel.org/patch/10524925/
This removes the code that decrements the pc after a break, now that we have
a patch to stop linux from pointlessly adding to the pc after a break.  It
would be nice if this goes in now, to avoid unnecessary divergence between
gdb and the linux kernel.  Palmer, the RISC-V linux kernel maintainer, has
already agreed to accept that patch.

This will also be needed by the FreeBSD gdb port which may be started soon.

This also fixes a bug in the code.  The fact that we have two different
mechanisms to decide breakpoint size, used_compressed_breakpoints and
has_compressed_isa, means that it is possible for gdb to emit a 4 byte
breakpoint and then subtract 2 from the pc, and vice versa.  Removing the
unnecessary pc decrement fixes that problem.

OK?

Jim

	gdb/
	* riscv-tdep.c (riscv_has_feature): Delete comment that refers to
	set_gdbarch_decr_pc_after_break.  Call riscv_read_misa_reg always.
	(riscv_gdbarch_init): Delete local has_compressed_isa.  Delete now
	unecessary braces after EF_RISCV_RVC test.  Delete call to
	set_gdbarch_decr_pc_after_break.
---
 gdb/riscv-tdep.c | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 72dab0f897..f5d1af822c 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -335,23 +335,7 @@ riscv_has_feature (struct gdbarch *gdbarch, char feature)
 
   gdb_assert (feature >= 'A' && feature <= 'Z');
 
-  /* It would be nice to always check with the real target where possible,
-     however, for compressed instructions this is a bad idea.
-
-     The call to `set_gdbarch_decr_pc_after_break' is made just once per
-     GDBARCH and we decide at that point if we should decrement by 2 or 4
-     bytes based on whether the BFD has compressed instruction support or
-     not.
-
-     If the BFD was not compiled with compressed instruction support, but we
-     are running on a target with compressed instructions then we might
-     place a 4-byte breakpoint, then decrement the $pc by 2 bytes leading to
-     confusion.
-
-     It's safer if we just make decisions about compressed instruction
-     support based on the BFD.  */
-  if (feature != 'C')
-    misa = riscv_read_misa_reg (&have_read_misa);
+  misa = riscv_read_misa_reg (&have_read_misa);
   if (!have_read_misa || misa == 0)
     misa = gdbarch_tdep (gdbarch)->core_features;
 
@@ -2440,7 +2424,6 @@ riscv_gdbarch_init (struct gdbarch_info info,
   struct gdbarch *gdbarch;
   struct gdbarch_tdep *tdep;
   struct gdbarch_tdep tmp_tdep;
-  bool has_compressed_isa = false;
   int i;
 
   /* Ideally, we'd like to get as much information from the target for
@@ -2472,10 +2455,7 @@ riscv_gdbarch_init (struct gdbarch_info info,
 			_("unknown ELF header class %d"), eclass);
 
       if (e_flags & EF_RISCV_RVC)
-	{
-	  has_compressed_isa = true;
-	  tmp_tdep.core_features |= (1 << ('C' - 'A'));
-	}
+	tmp_tdep.core_features |= (1 << ('C' - 'A'));
 
       if (e_flags & EF_RISCV_FLOAT_ABI_DOUBLE)
 	{
@@ -2545,7 +2525,6 @@ riscv_gdbarch_init (struct gdbarch_info info,
   set_gdbarch_register_reggroup_p (gdbarch, riscv_register_reggroup_p);
 
   /* Functions to analyze frames.  */
-  set_gdbarch_decr_pc_after_break (gdbarch, (has_compressed_isa ? 2 : 4));
   set_gdbarch_skip_prologue (gdbarch, riscv_skip_prologue);
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
   set_gdbarch_frame_align (gdbarch, riscv_frame_align);
-- 
2.17.1


             reply	other threads:[~2018-07-17  0:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17  0:12 Jim Wilson [this message]
2018-07-17 15:37 ` Andrew Burgess
2018-07-23 10:31 ` Sebastian Huber
2018-07-23 15:38   ` Jim Wilson
2018-07-23 17:25     ` Sebastian Huber
2018-07-23 23:27       ` Jim Wilson
2018-07-24  6:15         ` Sebastian Huber
2018-07-24 11:41           ` Jim Wilson
2018-07-26  6:30             ` Sebastian Huber
2018-08-03 22:05 ` Palmer Dabbelt

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=20180717001241.25908-1-jimw@sifive.com \
    --to=jimw@sifive.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /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