public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Antoine Tremblay <antoine.tremblay@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH v3 16/18] arm: Move insn_references_pc to common code
Date: Tue, 05 Jul 2016 13:41:00 -0000	[thread overview]
Message-ID: <1467726030-13020-17-git-send-email-antoine.tremblay@ericsson.com> (raw)
In-Reply-To: <1467726030-13020-1-git-send-email-antoine.tremblay@ericsson.com>

From: Simon Marchi <simon.marchi@ericsson.com>

This patch moves insn_references_pc to common code in arch/, so that it
can be used in gdbserver.  It adds the arm_ prefix, since the function
is now exported.

gdb/ChangeLog:

	* arm-tdep.c (arm_copy_preload): Adjust to renaming.
	(arm_copy_preload_reg): Likewise.
	(arm_copy_copro_load_store): Likewise.
	(arm_copy_alu_imm): Likewise.
	(arm_copy_alu_reg): Likewise.
	(arm_copy_alu_shifted_reg): Likewise.
	(arm_copy_extra_ld_st): Likewise.
	(arm_copy_ldr_str_ldrb_strb): Likewise.
	(insn_references_pc): Move to...
	* arch/arm-insn-reloc.c (arm_insn_references_pc): ... here.
	* arch/arm-insn-reloc.h (arm_insn_references_pc): New declaraction.
---
 gdb/arch/arm-insn-reloc.c | 29 ++++++++++++++++++++++++++++
 gdb/arch/arm-insn-reloc.h |  8 ++++++++
 gdb/arm-tdep.c            | 49 ++++++++---------------------------------------
 3 files changed, 45 insertions(+), 41 deletions(-)

diff --git a/gdb/arch/arm-insn-reloc.c b/gdb/arch/arm-insn-reloc.c
index b6ede60..7ebb507 100644
--- a/gdb/arch/arm-insn-reloc.c
+++ b/gdb/arch/arm-insn-reloc.c
@@ -20,6 +20,35 @@
 #include "arm.h"
 #include "arm-insn-reloc.h"
 
+
+/* See arch/arm-insn-reloc.h.  */
+
+int
+arm_insn_references_pc (uint32_t insn, uint32_t bitmask)
+{
+  uint32_t lowbit = 1;
+
+  while (bitmask != 0)
+    {
+      uint32_t mask;
+
+      for (; lowbit && (bitmask & lowbit) == 0; lowbit <<= 1)
+	;
+
+      if (!lowbit)
+	break;
+
+      mask = lowbit * 0xf;
+
+      if ((insn & mask) == mask)
+	return 1;
+
+      bitmask &= ~mask;
+    }
+
+  return 0;
+}
+
 static int
 arm_decode_misc_memhint_neon (uint32_t insn,
 			      struct arm_insn_reloc_visitor *visitor,
diff --git a/gdb/arch/arm-insn-reloc.h b/gdb/arch/arm-insn-reloc.h
index 6e83ad4..8f93214 100644
--- a/gdb/arch/arm-insn-reloc.h
+++ b/gdb/arch/arm-insn-reloc.h
@@ -84,6 +84,14 @@ struct thumb_16bit_insn_reloc_visitor
   int (*svc) (uint16_t insn, struct arm_insn_reloc_data *data);
 };
 
+/* This function is used to concisely determine if an instruction INSN
+   references PC.  Register fields of interest in INSN should have the
+   corresponding fields of BITMASK set to 0b1111.  The function
+   returns return 1 if any of these fields in INSN reference the PC
+   (also 0b1111, r15), else it returns 0.  */
+
+extern int arm_insn_references_pc (uint32_t insn, uint32_t bitmask);
+
 extern int arm_relocate_insn (uint32_t insn,
 			      struct arm_insn_reloc_visitor *visitor,
 			      struct arm_insn_reloc_data *data);
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 2a83b82..32c81c2 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -4653,38 +4653,6 @@ displaced_write_reg (struct regcache *regs, struct displaced_step_closure *dsc,
     }
 }
 
-/* This function is used to concisely determine if an instruction INSN
-   references PC.  Register fields of interest in INSN should have the
-   corresponding fields of BITMASK set to 0b1111.  The function
-   returns return 1 if any of these fields in INSN reference the PC
-   (also 0b1111, r15), else it returns 0.  */
-
-static int
-insn_references_pc (uint32_t insn, uint32_t bitmask)
-{
-  uint32_t lowbit = 1;
-
-  while (bitmask != 0)
-    {
-      uint32_t mask;
-
-      for (; lowbit && (bitmask & lowbit) == 0; lowbit <<= 1)
-	;
-
-      if (!lowbit)
-	break;
-
-      mask = lowbit * 0xf;
-
-      if ((insn & mask) == mask)
-	return 1;
-
-      bitmask &= ~mask;
-    }
-
-  return 0;
-}
-
 /* The simplest copy function.  Many instructions have the same effect no
    matter what address they are executed at: in those cases, use this.  */
 
@@ -4773,7 +4741,7 @@ arm_copy_preload (uint32_t insn, struct arm_insn_reloc_data *data)
 {
   unsigned int rn = bits (insn, 16, 19);
 
-  if (!insn_references_pc (insn, 0x000f0000ul))
+  if (!arm_insn_references_pc (insn, 0x000f0000ul))
     return arm_copy_unmodified (insn, "preload", data);
 
   if (debug_displaced)
@@ -4870,8 +4838,7 @@ arm_copy_preload_reg (uint32_t insn, struct arm_insn_reloc_data *data)
   unsigned int rn = bits (insn, 16, 19);
   unsigned int rm = bits (insn, 0, 3);
 
-
-  if (!insn_references_pc (insn, 0x000f000ful))
+  if (!arm_insn_references_pc (insn, 0x000f000ful))
     return arm_copy_unmodified (insn, "preload reg", data);
 
   if (debug_displaced)
@@ -4932,7 +4899,7 @@ arm_copy_copro_load_store (uint32_t insn, struct arm_insn_reloc_data *data)
 {
   unsigned int rn = bits (insn, 16, 19);
 
-  if (!insn_references_pc (insn, 0x000f0000ul))
+  if (!arm_insn_references_pc (insn, 0x000f0000ul))
     return arm_copy_unmodified (insn, "copro load/store", data);
 
   if (debug_displaced)
@@ -5238,7 +5205,7 @@ arm_copy_alu_imm (uint32_t insn, struct arm_insn_reloc_data *data)
   int is_mov = (op == 0xd);
   ULONGEST rd_val, rn_val;
 
-  if (!insn_references_pc (insn, 0x000ff000ul))
+  if (!arm_insn_references_pc (insn, 0x000ff000ul))
     return arm_copy_unmodified (insn, "ALU immediate", data);
 
   if (debug_displaced)
@@ -5386,7 +5353,7 @@ arm_copy_alu_reg (uint32_t insn, struct arm_insn_reloc_data *data)
   unsigned int op = bits (insn, 21, 24);
   int is_mov = (op == 0xd);
 
-  if (!insn_references_pc (insn, 0x000ff00ful))
+  if (!arm_insn_references_pc (insn, 0x000ff00ful))
     return arm_copy_unmodified (insn, "ALU reg", data);
 
   if (debug_displaced)
@@ -5487,7 +5454,7 @@ arm_copy_alu_shifted_reg (uint32_t insn, struct arm_insn_reloc_data *data)
   int is_mov = (op == 0xd);
   unsigned int rd, rn, rm, rs;
 
-  if (!insn_references_pc (insn, 0x000fff0ful))
+  if (!arm_insn_references_pc (insn, 0x000fff0ful))
     return arm_copy_unmodified (insn, "ALU shifted reg", data);
 
   if (debug_displaced)
@@ -5581,7 +5548,7 @@ arm_copy_extra_ld_st (uint32_t insn, struct arm_insn_reloc_data *data,
   struct displaced_step_closure *dsc = data->dsc;
   struct regcache *regs = data->regs;
 
-  if (!insn_references_pc (insn, 0x000ff00ful))
+  if (!arm_insn_references_pc (insn, 0x000ff00ful))
     return arm_copy_unmodified (insn, "extra load/store", data);
 
   if (debug_displaced)
@@ -5812,7 +5779,7 @@ arm_copy_ldr_str_ldrb_strb (uint32_t insn, struct arm_insn_reloc_data *data,
   unsigned int rm = bits (insn, 0, 3);  /* Only valid if !immed.  */
   struct displaced_step_closure *dsc = data->dsc;
 
-  if (!insn_references_pc (insn, 0x000ff00ful))
+  if (!arm_insn_references_pc (insn, 0x000ff00ful))
     return arm_copy_unmodified (insn, "load/store", data);
 
   if (debug_displaced)
-- 
2.8.1

  parent reply	other threads:[~2016-07-05 13:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05 13:41 [PATCH v3 00/18] Fast tracepoint support for ARMv7 Antoine Tremblay
2016-07-05 13:41 ` [PATCH v3 15/18] JIT conditions support for ARM tracepoints Antoine Tremblay
2016-07-05 13:41 ` [PATCH v3 12/18] Add ARM/Thumb instruction assembler for fast tracepoints Antoine Tremblay
2016-07-05 13:41 ` [PATCH v3 03/18] arm-tdep.c: Move debug printout from decode to copy function Antoine Tremblay
2016-07-05 13:41 ` [PATCH v3 08/18] Move Thumb 32 bits instruction decode functions to arch/arm-insn-reloc.c Antoine Tremblay
2016-07-05 13:41 ` [PATCH v3 06/18] arm-tdep.c: Use relocation visitor in Thumb 16-bits instruction decoding Antoine Tremblay
2016-07-05 13:41 ` [PATCH v3 02/18] arm-tdep.c: Refactor displaced stepping relocation functions Antoine Tremblay
2016-07-05 13:41 ` [PATCH v3 13/18] Export tracing control breakpoints functions via global function pointers Antoine Tremblay
2016-07-05 13:41 ` Antoine Tremblay [this message]
2016-07-05 13:41 ` [PATCH v3 11/18] Use software single step to step out of a fast tracepoint jump pad Antoine Tremblay
2016-07-05 13:42 ` [PATCH v3 14/18] Fast tracepoint support for ARM on Linux Antoine Tremblay
2016-07-05 13:42 ` [PATCH v3 10/18] gdbserver: pass pointer to struct tracepoint to install_fast_tracepoint_jump_pad Antoine Tremblay
2016-07-05 13:42 ` [PATCH v3 01/18] arm-tdep.c: Replace arguments to decode function by a structure Antoine Tremblay
2016-07-05 13:42 ` [PATCH v3 18/18] arm fast tracepoints: Relocation of Thumb 32-bits instructions Antoine Tremblay
2016-07-05 13:42 ` [PATCH v3 09/18] Move Thumb 16 bits instruction decode functions to arch/arm-insn-reloc.c Antoine Tremblay
2016-07-05 13:42 ` [PATCH v3 07/18] Move ARM " Antoine Tremblay
2016-07-05 13:42 ` [PATCH v3 17/18] arm fast tracepoints: Relocation of ARM instructions Antoine Tremblay
2016-07-05 13:56 ` [PATCH v3 05/18] arm-tdep.c: Use relocation visitor in Thumb 32-bits instruction decoding Antoine Tremblay
2016-07-05 13:56 ` [PATCH v3 04/18] arm-tdep.c: Use relocation visitor in ARM " Antoine Tremblay

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=1467726030-13020-17-git-send-email-antoine.tremblay@ericsson.com \
    --to=antoine.tremblay@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.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).