From: Antoine Tremblay <antoine.tremblay@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH v2 02/17] arm-tdep.c: Refactor displaced stepping relocation functions
Date: Thu, 09 Jun 2016 12:57:00 -0000 [thread overview]
Message-ID: <1465476975-25062-3-git-send-email-antoine.tremblay@ericsson.com> (raw)
In-Reply-To: <1465476975-25062-1-git-send-email-antoine.tremblay@ericsson.com>
From: Simon Marchi <simon.marchi@ericsson.com>
Refactor so that arm_process_displaced_insn is the only function that
is specific to GDB. All functions called from this function will
eventually be moved to common/, so they need to be free of anything
GDB-specific.
gdb/ChangeLog:
arm-tdep.c (thumb_process_displaced_16bit_insn): Rename to...
(thumb_16bit_relocate_insn): ... this, and return error code instead of
throwing an error.
(thumb_process_displaced_32bit_insn): Rename to...
(thumb_32bit_relocate_insn): ... this, and return error code instead of
throwing an error.
(arm_relocate_insn): New function.
(thumb_process_displaced_insn): Remove.
(arm_process_displaced_insn): Refactor, extract some content to
arm_relocate_insn, integrate content from thumb_process_displaced_insn.
---
gdb/arm-tdep.c | 123 ++++++++++++++++++++++++++++++---------------------------
1 file changed, 64 insertions(+), 59 deletions(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index d6e8858..5a0e247 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -7259,9 +7259,8 @@ thumb_copy_pop_pc_16bit (uint16_t insn1, struct arm_insn_reloc_data *data)
return 0;
}
-static void
-thumb_process_displaced_16bit_insn (uint16_t insn1,
- struct arm_insn_reloc_data *data)
+static int
+thumb_16bit_relocate_insn (uint16_t insn1, struct arm_insn_reloc_data *data)
{
unsigned short op_bit_12_15 = bits (insn1, 12, 15);
unsigned short op_bit_10_11 = bits (insn1, 10, 11);
@@ -7350,9 +7349,7 @@ thumb_process_displaced_16bit_insn (uint16_t insn1,
err = 1;
}
- if (err)
- internal_error (__FILE__, __LINE__,
- _("thumb_process_displaced_16bit_insn: Instruction decode error"));
+ return err;
}
static int
@@ -7427,9 +7424,9 @@ decode_thumb_32bit_ld_mem_hints (uint16_t insn1, uint16_t insn2,
return 0;
}
-static void
-thumb_process_displaced_32bit_insn (uint16_t insn1, uint16_t insn2,
- struct arm_insn_reloc_data *data)
+static int
+thumb_32bit_relocate_insn (uint16_t insn1, uint16_t insn2,
+ struct arm_insn_reloc_data *data)
{
int err = 0;
unsigned short op = bit (insn2, 15);
@@ -7541,34 +7538,41 @@ thumb_process_displaced_32bit_insn (uint16_t insn1, uint16_t insn2,
err = 1;
}
- if (err)
- internal_error (__FILE__, __LINE__,
- _("thumb_process_displaced_32bit_insn: Instruction decode error"));
+ return err;
}
-static void
-thumb_process_displaced_insn (CORE_ADDR from, struct arm_insn_reloc_data *data)
+static int
+arm_relocate_insn (uint32_t insn, struct arm_insn_reloc_data *data)
{
- enum bfd_endian byte_order_for_code
- = gdbarch_byte_order_for_code (data->gdbarch);
- uint16_t insn1
- = read_memory_unsigned_integer (from, 2, byte_order_for_code);
+ int err = 1;
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: process thumb insn %.4x "
- "at %.8lx\n", insn1, (unsigned long) from);
-
- data->dsc->is_thumb = 1;
- data->dsc->insn_size = thumb_insn_size (insn1);
- if (thumb_insn_size (insn1) == 4)
+ if ((insn & 0xf0000000) == 0xf0000000)
+ err = arm_decode_unconditional (insn, data);
+ else switch (((insn & 0x10) >> 4) | ((insn & 0xe000000) >> 24))
{
- uint16_t insn2
- = read_memory_unsigned_integer (from + 2, 2, byte_order_for_code);
- thumb_process_displaced_32bit_insn (insn1, insn2, data);
+ case 0x0: case 0x1: case 0x2: case 0x3:
+ err = arm_decode_dp_misc (insn, data);
+ break;
+
+ case 0x4: case 0x5: case 0x6:
+ err = arm_decode_ld_st_word_ubyte (insn, data);
+ break;
+
+ case 0x7:
+ err = arm_decode_media (insn, data);
+ break;
+
+ case 0x8: case 0x9: case 0xa: case 0xb:
+ err = arm_decode_b_bl_ldmstm (insn, data);
+ break;
+
+ case 0xc: case 0xd: case 0xe: case 0xf:
+ err = arm_decode_svc_copro (insn, data);
+ break;
}
- else
- thumb_process_displaced_16bit_insn (insn1, data);
+
+ return err;
}
void
@@ -7578,7 +7582,6 @@ arm_process_displaced_insn (struct gdbarch *gdbarch, CORE_ADDR from,
{
int err = 0;
enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
- uint32_t insn;
struct arm_insn_reloc_data reloc_data;
reloc_data.dsc = dsc;
@@ -7593,40 +7596,42 @@ arm_process_displaced_insn (struct gdbarch *gdbarch, CORE_ADDR from,
dsc->cleanup = NULL;
dsc->wrote_to_pc = 0;
- if (!displaced_in_arm_mode (regs))
- return thumb_process_displaced_insn (from, &reloc_data);
+ if (displaced_in_arm_mode (regs))
+ {
+ uint32_t insn
+ = read_memory_unsigned_integer (from, 4, byte_order_for_code);
- dsc->is_thumb = 0;
- dsc->insn_size = 4;
- insn = read_memory_unsigned_integer (from, 4, byte_order_for_code);
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: stepping insn %.8lx "
- "at %.8lx\n", (unsigned long) insn,
- (unsigned long) from);
+ if (debug_displaced)
+ fprintf_unfiltered (gdb_stdlog, "displaced: stepping insn %.8lx "
+ "at %.8lx\n", (unsigned long) insn,
+ (unsigned long) from);
- if ((insn & 0xf0000000) == 0xf0000000)
- err = arm_decode_unconditional (insn, &reloc_data);
- else switch (((insn & 0x10) >> 4) | ((insn & 0xe000000) >> 24))
- {
- case 0x0: case 0x1: case 0x2: case 0x3:
- err = arm_decode_dp_misc (insn, &reloc_data);
- break;
+ dsc->is_thumb = 0;
+ dsc->insn_size = 4;
- case 0x4: case 0x5: case 0x6:
- err = arm_decode_ld_st_word_ubyte (insn, &reloc_data);
- break;
+ err = arm_relocate_insn (insn, &reloc_data);
+ }
+ else
+ {
+ uint16_t insn1
+ = read_memory_unsigned_integer (from, 2, byte_order_for_code);
+ unsigned int insn_size = thumb_insn_size (insn1);
- case 0x7:
- err = arm_decode_media (insn, &reloc_data);
- break;
+ if (debug_displaced)
+ fprintf_unfiltered (gdb_stdlog, "displaced: process thumb insn %.4x "
+ "at %.8lx\n", insn1, (unsigned long) from);
- case 0x8: case 0x9: case 0xa: case 0xb:
- err = arm_decode_b_bl_ldmstm (insn, &reloc_data);
- break;
+ dsc->is_thumb = 1;
+ dsc->insn_size = insn_size;
- case 0xc: case 0xd: case 0xe: case 0xf:
- err = arm_decode_svc_copro (insn, &reloc_data);
- break;
+ if (insn_size == 4)
+ {
+ uint16_t insn2
+ = read_memory_unsigned_integer (from + 2, 2, byte_order_for_code);
+ err = thumb_32bit_relocate_insn (insn1, insn2, &reloc_data);
+ }
+ else
+ err = thumb_16bit_relocate_insn (insn1, &reloc_data);
}
if (err)
--
2.8.1
next prev parent reply other threads:[~2016-06-09 12:56 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-09 12:56 [PATCH v2 00/17] Fast tracepoint support for ARMv7 Antoine Tremblay
2016-06-09 12:56 ` [PATCH v2 06/17] arm-tdep.c: Use relocation visitor in Thumb 16-bits instruction decoding Antoine Tremblay
2016-06-09 12:56 ` [PATCH v2 07/17] Move ARM instruction decode functions to arch/arm-insn-reloc.c Antoine Tremblay
2016-06-09 12:56 ` [PATCH v2 08/17] Move Thumb 32 bits " Antoine Tremblay
2016-06-09 12:56 ` [PATCH v2 11/17] Use software single step to step out of a fast tracepoint jump pad Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 10/17] gdbserver: pass pointer to struct tracepoint to install_fast_tracepoint_jump_pad Antoine Tremblay
2016-06-15 14:59 ` Marcin Kościelnicki
2016-06-15 15:42 ` Antoine Tremblay
2016-06-16 17:14 ` [PATCH v3] " Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 13/17] Fast tracepoint support for ARM on Linux Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 01/17] arm-tdep.c: Replace arguments to decode function by a structure Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 15/17] arm: Move insn_references_pc to common code Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 05/17] arm-tdep.c: Use relocation visitor in Thumb 32-bits instruction decoding Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 14/17] JIT conditions support for ARM tracepoints Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 04/17] arm-tdep.c: Use relocation visitor in ARM instruction decoding Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 17/17] arm fast tracepoints: Relocation of Thumb 32-bits instructions Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 09/17] Move Thumb 16 bits instruction decode functions to arch/arm-insn-reloc.c Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 03/17] arm-tdep.c: Move debug printout from decode to copy function Antoine Tremblay
2016-06-09 12:57 ` [PATCH v2 16/17] arm fast tracepoints: Relocation of ARM instructions Antoine Tremblay
2016-06-09 12:57 ` Antoine Tremblay [this message]
2016-06-09 12:57 ` [PATCH v2 12/17] Add ARM/Thumb instruction assembler for fast tracepoints Antoine Tremblay
2016-06-29 13:55 ` [PATCH v2 00/17] Fast tracepoint support for ARMv7 Antoine Tremblay
2016-06-29 16:59 ` Pedro Alves
2016-06-29 19:15 ` Antoine Tremblay
2016-06-29 20:10 ` Pedro Alves
2016-06-30 11:46 ` 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=1465476975-25062-3-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