public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Remove argument pc in get_next_pcs
  2016-01-15  9:57 [PATCH 0/2] Remove argument pc in get_next_pcs Yao Qi
@ 2016-01-15  9:57 ` Yao Qi
  2016-01-15  9:57 ` [PATCH 1/2] [GDBserver] Use regcache_read_pc in install_software_single_step_breakpoints Yao Qi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Yao Qi @ 2016-01-15  9:57 UTC (permalink / raw)
  To: gdb-patches

Nowadays, get_next_pcs in linux_target_ops has two parameters PC
and REGCACHE.  Parameter PC looks redundant because it can be go
from REGCACHE.  The patch is to remove PC from the arguments for
various functions.

gdb:

2016-01-15  Yao Qi  <yao.qi@linaro.org>

	* arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw):
	Remove argument pc.  Get pc by regcache_read_pc.  Callers updated.
	(arm_deal_with_atomic_sequence_raw): Likewise.
	(thumb_get_next_pcs_raw): Likewise.
	(arm_get_next_pcs_raw): Likewise.
	(arm_get_next_pcs): Remove argument pc.  Callers updated.
	* arch/arm-get-next-pcs.h (arm_get_next_pcs): Update declaration.

gdb/gdbserver:

2016-01-15  Yao Qi  <yao.qi@linaro.org>

	* linux-arm-low.c (arm_gdbserver_get_next_pcs): Remove argument pc.
	* linux-low.c (install_software_single_step_breakpoints): Don't
	call regcache_read_pc.
	* linux-low.h (struct linux_target_ops) <get_next_pcs>: Remove
	argument pc.
---
 gdb/arch/arm-get-next-pcs.c   | 24 +++++++++++++-----------
 gdb/arch/arm-get-next-pcs.h   |  3 +--
 gdb/arm-linux-tdep.c          |  2 +-
 gdb/arm-tdep.c                |  2 +-
 gdb/gdbserver/linux-arm-low.c |  4 ++--
 gdb/gdbserver/linux-low.c     |  4 +---
 gdb/gdbserver/linux-low.h     |  2 +-
 7 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/gdb/arch/arm-get-next-pcs.c b/gdb/arch/arm-get-next-pcs.c
index 6b8f38a..e840147 100644
--- a/gdb/arch/arm-get-next-pcs.c
+++ b/gdb/arch/arm-get-next-pcs.c
@@ -46,11 +46,11 @@ arm_get_next_pcs_ctor (struct arm_get_next_pcs *self,
    added to the next_pcs list.  */
 
 static VEC (CORE_ADDR) *
-thumb_deal_with_atomic_sequence_raw (struct arm_get_next_pcs *self,
-				     CORE_ADDR pc)
+thumb_deal_with_atomic_sequence_raw (struct arm_get_next_pcs *self)
 {
   int byte_order_for_code = self->byte_order_for_code;
   CORE_ADDR breaks[2] = {-1, -1};
+  CORE_ADDR pc = regcache_read_pc (self->regcache);
   CORE_ADDR loc = pc;
   unsigned short insn1, insn2;
   int insn_count;
@@ -183,11 +183,11 @@ thumb_deal_with_atomic_sequence_raw (struct arm_get_next_pcs *self,
    added to the next_pcs list.  */
 
 static VEC (CORE_ADDR) *
-arm_deal_with_atomic_sequence_raw (struct arm_get_next_pcs *self,
-				   CORE_ADDR pc)
+arm_deal_with_atomic_sequence_raw (struct arm_get_next_pcs *self)
 {
   int byte_order_for_code = self->byte_order_for_code;
   CORE_ADDR breaks[2] = {-1, -1};
+  CORE_ADDR pc = regcache_read_pc (self->regcache);
   CORE_ADDR loc = pc;
   unsigned int insn;
   int insn_count;
@@ -261,10 +261,11 @@ arm_deal_with_atomic_sequence_raw (struct arm_get_next_pcs *self,
 /* Find the next possible PCs for thumb mode.  */
 
 static VEC (CORE_ADDR) *
-thumb_get_next_pcs_raw (struct arm_get_next_pcs *self, CORE_ADDR pc)
+thumb_get_next_pcs_raw (struct arm_get_next_pcs *self)
 {
   int byte_order = self->byte_order;
   int byte_order_for_code = self->byte_order_for_code;
+  CORE_ADDR pc = regcache_read_pc (self->regcache);
   unsigned long pc_val = ((unsigned long) pc) + 4;	/* PC after prefetch */
   unsigned short inst1;
   CORE_ADDR nextpc = pc + 2;		/* Default is next instruction.  */
@@ -641,7 +642,7 @@ thumb_get_next_pcs_raw (struct arm_get_next_pcs *self, CORE_ADDR pc)
    address in GDB and arm_addr_bits_remove in GDBServer.  */
 
 static VEC (CORE_ADDR) *
-arm_get_next_pcs_raw (struct arm_get_next_pcs *self, CORE_ADDR pc)
+arm_get_next_pcs_raw (struct arm_get_next_pcs *self)
 {
   int byte_order = self->byte_order;
   int byte_order_for_code = self->byte_order_for_code;
@@ -650,6 +651,7 @@ arm_get_next_pcs_raw (struct arm_get_next_pcs *self, CORE_ADDR pc)
   unsigned long status;
   CORE_ADDR nextpc;
   struct regcache *regcache = self->regcache;
+  CORE_ADDR pc = regcache_read_pc (self->regcache);
   VEC (CORE_ADDR) *next_pcs = NULL;
 
   pc_val = (unsigned long) pc;
@@ -904,21 +906,21 @@ arm_get_next_pcs_raw (struct arm_get_next_pcs *self, CORE_ADDR pc)
 /* See arm-get-next-pcs.h.  */
 
 VEC (CORE_ADDR) *
-arm_get_next_pcs (struct arm_get_next_pcs *self, CORE_ADDR pc)
+arm_get_next_pcs (struct arm_get_next_pcs *self)
 {
   VEC (CORE_ADDR) *next_pcs = NULL;
 
   if (self->ops->is_thumb (self))
     {
-      next_pcs = thumb_deal_with_atomic_sequence_raw (self, pc);
+      next_pcs = thumb_deal_with_atomic_sequence_raw (self);
       if (next_pcs == NULL)
-	next_pcs = thumb_get_next_pcs_raw (self, pc);
+	next_pcs = thumb_get_next_pcs_raw (self);
     }
   else
     {
-      next_pcs = arm_deal_with_atomic_sequence_raw (self, pc);
+      next_pcs = arm_deal_with_atomic_sequence_raw (self);
       if (next_pcs == NULL)
-	next_pcs = arm_get_next_pcs_raw (self, pc);
+	next_pcs = arm_get_next_pcs_raw (self);
     }
 
   return next_pcs;
diff --git a/gdb/arch/arm-get-next-pcs.h b/gdb/arch/arm-get-next-pcs.h
index 4a0fc16..7cb0858 100644
--- a/gdb/arch/arm-get-next-pcs.h
+++ b/gdb/arch/arm-get-next-pcs.h
@@ -57,7 +57,6 @@ void arm_get_next_pcs_ctor (struct arm_get_next_pcs *self,
 			    struct regcache *regcache);
 
 /* Find the next possible PCs after the current instruction executes.  */
-VEC (CORE_ADDR) *arm_get_next_pcs (struct arm_get_next_pcs *self,
-				   CORE_ADDR pc);
+VEC (CORE_ADDR) *arm_get_next_pcs (struct arm_get_next_pcs *self);
 
 #endif /* ARM_GET_NEXT_PCS_H */
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 2306bda..7436270 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -935,7 +935,7 @@ arm_linux_software_single_step (struct frame_info *frame)
 			 1,
 			 regcache);
 
-  next_pcs = arm_get_next_pcs (&next_pcs_ctx, regcache_read_pc (regcache));
+  next_pcs = arm_get_next_pcs (&next_pcs_ctx);
 
   for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); i++)
     {
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index ccc2a03..5a2d490 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -6186,7 +6186,7 @@ arm_software_single_step (struct frame_info *frame)
 			 0,
 			 regcache);
 
-  next_pcs = arm_get_next_pcs (&next_pcs_ctx, regcache_read_pc (regcache));
+  next_pcs = arm_get_next_pcs (&next_pcs_ctx);
 
   for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); i++)
     arm_insert_single_step_breakpoint (gdbarch, aspace, pc);
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 57cb855..5ec0341 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -913,7 +913,7 @@ arm_arch_setup (void)
 /* Fetch the next possible PCs after the current instruction executes.  */
 
 static VEC (CORE_ADDR) *
-arm_gdbserver_get_next_pcs (CORE_ADDR pc, struct regcache *regcache)
+arm_gdbserver_get_next_pcs (struct regcache *regcache)
 {
   struct arm_get_next_pcs next_pcs_ctx;
   VEC (CORE_ADDR) *next_pcs = NULL;
@@ -926,7 +926,7 @@ arm_gdbserver_get_next_pcs (CORE_ADDR pc, struct regcache *regcache)
 			 1,
 			 regcache);
 
-  next_pcs = arm_get_next_pcs (&next_pcs_ctx, pc);
+  next_pcs = arm_get_next_pcs (&next_pcs_ctx);
 
   return next_pcs;
 }
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 9f194c7..d1632f3 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4107,9 +4107,7 @@ install_software_single_step_breakpoints (struct lwp_info *lwp)
   VEC (CORE_ADDR) *next_pcs = NULL;
   struct cleanup *old_chain = make_cleanup (VEC_cleanup (CORE_ADDR), &next_pcs);
 
-  pc = regcache_read_pc (regcache);
-
-  next_pcs = (*the_low_target.get_next_pcs) (pc, regcache);
+  next_pcs = (*the_low_target.get_next_pcs) (regcache);
 
   for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); ++i)
     set_reinsert_breakpoint (pc);
diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index 4845862..0d9eb40 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -154,7 +154,7 @@ struct linux_target_ops
   const gdb_byte *(*sw_breakpoint_from_kind) (int kind, int *size);
 
   /* Find the next possible PCs after the current instruction executes.  */
-  VEC (CORE_ADDR) *(*get_next_pcs) (CORE_ADDR pc, struct regcache *regcache);
+  VEC (CORE_ADDR) *(*get_next_pcs) (struct regcache *regcache);
 
   int decr_pc_after_break;
   int (*breakpoint_at) (CORE_ADDR pc);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 0/2] Remove argument pc in get_next_pcs
@ 2016-01-15  9:57 Yao Qi
  2016-01-15  9:57 ` [PATCH 2/2] " Yao Qi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yao Qi @ 2016-01-15  9:57 UTC (permalink / raw)
  To: gdb-patches

Hi,
get_next_pcs in struct linux_target_ops has two arguments, PC and
REGCACHE.  Since PC can be got from REGCACHE, PC is redundant, so this
patch series remove it in various places.  After the removal, PC is
got from regcache via regcache_read_pc, so patch #1 uses
regcache_read_pc out of *the_low_target.get_next_pcs.  Then, patch #2
removes PC arguments and PC can be got inside the implementations of
get_next_pcs via regcache_read_pc.

Regression tested on arm-linux.

*** BLURB HERE ***

Yao Qi (2):
  [GDBserver] Use regcache_read_pc in
    install_software_single_step_breakpoints
  Remove argument pc in get_next_pcs

 gdb/arch/arm-get-next-pcs.c   | 24 +++++++++++++-----------
 gdb/arch/arm-get-next-pcs.h   |  3 +--
 gdb/arm-linux-tdep.c          |  2 +-
 gdb/arm-tdep.c                |  2 +-
 gdb/gdbserver/linux-arm-low.c |  4 ++--
 gdb/gdbserver/linux-low.c     |  3 +--
 gdb/gdbserver/linux-low.h     |  2 +-
 7 files changed, 20 insertions(+), 20 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] [GDBserver] Use regcache_read_pc in install_software_single_step_breakpoints
  2016-01-15  9:57 [PATCH 0/2] Remove argument pc in get_next_pcs Yao Qi
  2016-01-15  9:57 ` [PATCH 2/2] " Yao Qi
@ 2016-01-15  9:57 ` Yao Qi
  2016-01-15 13:14 ` [PATCH 0/2] Remove argument pc in get_next_pcs Antoine Tremblay
  2016-01-26 14:09 ` Yao Qi
  3 siblings, 0 replies; 5+ messages in thread
From: Yao Qi @ 2016-01-15  9:57 UTC (permalink / raw)
  To: gdb-patches

In install_software_single_step_breakpoints, we've got the regcache
of current_thread, so we don't have to bother get_pc to get pc,
instead we can get pc from regcache directly.  Note that the callers
of install_software_single_step_breakpoints have already switched
current_thread to LWP.

Since the pc is got from regcache_read_pc, in the next patch, we can
get pc inside the implementation of *the_low_target.get_next_pcs and
stop passing pc to *the_low_target.get_next_pcs.

gdb/gdbserver:

2016-01-15  Yao Qi  <yao.qi@linaro.org>

	* linux-low.c (install_software_single_step_breakpoints): Call
	regcache_read_pc instead of get_pc.
---
 gdb/gdbserver/linux-low.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 6082d66..9f194c7 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4107,7 +4107,8 @@ install_software_single_step_breakpoints (struct lwp_info *lwp)
   VEC (CORE_ADDR) *next_pcs = NULL;
   struct cleanup *old_chain = make_cleanup (VEC_cleanup (CORE_ADDR), &next_pcs);
 
-  pc = get_pc (lwp);
+  pc = regcache_read_pc (regcache);
+
   next_pcs = (*the_low_target.get_next_pcs) (pc, regcache);
 
   for (i = 0; VEC_iterate (CORE_ADDR, next_pcs, i, pc); ++i)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Remove argument pc in get_next_pcs
  2016-01-15  9:57 [PATCH 0/2] Remove argument pc in get_next_pcs Yao Qi
  2016-01-15  9:57 ` [PATCH 2/2] " Yao Qi
  2016-01-15  9:57 ` [PATCH 1/2] [GDBserver] Use regcache_read_pc in install_software_single_step_breakpoints Yao Qi
@ 2016-01-15 13:14 ` Antoine Tremblay
  2016-01-26 14:09 ` Yao Qi
  3 siblings, 0 replies; 5+ messages in thread
From: Antoine Tremblay @ 2016-01-15 13:14 UTC (permalink / raw)
  To: Yao Qi, gdb-patches



On 01/15/2016 04:57 AM, Yao Qi wrote:
> Hi,
> get_next_pcs in struct linux_target_ops has two arguments, PC and
> REGCACHE.  Since PC can be got from REGCACHE, PC is redundant, so this
> patch series remove it in various places.  After the removal, PC is
> got from regcache via regcache_read_pc, so patch #1 uses
> regcache_read_pc out of *the_low_target.get_next_pcs.  Then, patch #2
> removes PC arguments and PC can be got inside the implementations of
> get_next_pcs via regcache_read_pc.
>
> Regression tested on arm-linux.
>
> *** BLURB HERE ***
>
> Yao Qi (2):
>    [GDBserver] Use regcache_read_pc in
>      install_software_single_step_breakpoints
>    Remove argument pc in get_next_pcs
>
>   gdb/arch/arm-get-next-pcs.c   | 24 +++++++++++++-----------
>   gdb/arch/arm-get-next-pcs.h   |  3 +--
>   gdb/arm-linux-tdep.c          |  2 +-
>   gdb/arm-tdep.c                |  2 +-
>   gdb/gdbserver/linux-arm-low.c |  4 ++--
>   gdb/gdbserver/linux-low.c     |  3 +--
>   gdb/gdbserver/linux-low.h     |  2 +-
>   7 files changed, 20 insertions(+), 20 deletions(-)
>

LGTM, thanks for the patches.

Regards,
Antoine

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Remove argument pc in get_next_pcs
  2016-01-15  9:57 [PATCH 0/2] Remove argument pc in get_next_pcs Yao Qi
                   ` (2 preceding siblings ...)
  2016-01-15 13:14 ` [PATCH 0/2] Remove argument pc in get_next_pcs Antoine Tremblay
@ 2016-01-26 14:09 ` Yao Qi
  3 siblings, 0 replies; 5+ messages in thread
From: Yao Qi @ 2016-01-26 14:09 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

Yao Qi <qiyaoltc@gmail.com> writes:

> Hi,
> get_next_pcs in struct linux_target_ops has two arguments, PC and
> REGCACHE.  Since PC can be got from REGCACHE, PC is redundant, so this
> patch series remove it in various places.  After the removal, PC is
> got from regcache via regcache_read_pc, so patch #1 uses
> regcache_read_pc out of *the_low_target.get_next_pcs.  Then, patch #2
> removes PC arguments and PC can be got inside the implementations of
> get_next_pcs via regcache_read_pc.
>
> Regression tested on arm-linux.

These two patches are pushed in.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-26 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-15  9:57 [PATCH 0/2] Remove argument pc in get_next_pcs Yao Qi
2016-01-15  9:57 ` [PATCH 2/2] " Yao Qi
2016-01-15  9:57 ` [PATCH 1/2] [GDBserver] Use regcache_read_pc in install_software_single_step_breakpoints Yao Qi
2016-01-15 13:14 ` [PATCH 0/2] Remove argument pc in get_next_pcs Antoine Tremblay
2016-01-26 14:09 ` Yao Qi

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).