From: Yao Qi <qiyaoltc@gmail.com>
To: marcus.shawcroft@gmail.com
Cc: gdb-patches@sourceware.org, binutils@sourceware.org
Subject: [PATCH 3/3] [aarch64] use aarch64_decode_insn to decode instructions in GDB
Date: Fri, 02 Oct 2015 11:24:00 -0000 [thread overview]
Message-ID: <1443785039-24602-4-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1443785039-24602-1-git-send-email-yao.qi@linaro.org>
In this patch, we start to use aarch64_decode_insn to decode instructions
in aarch64_software_single_step.
gdb:
2015-10-02 Yao Qi <yao.qi@linaro.org>
* aarch64-tdep.c: Include opcode/aarch64.h.
(submask): Move it above.
(bit): Likewise.
(bits): Likewise.
(aarch64_software_single_step): Call aarch64_decode_insn.
Decode instruction by aarch64_inst instead of using
aarch64_decode_bcond and decode_masked_match.
---
gdb/aarch64-tdep.c | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 5b5e1ad..df67e12 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -59,6 +59,12 @@
#include "arch/aarch64-insn.h"
+#include "opcode/aarch64.h"
+
+#define submask(x) ((1L << ((x) + 1)) - 1)
+#define bit(obj,st) (((obj) >> (st)) & 1)
+#define bits(obj,st,fn) (((obj) >> (st)) & submask ((fn) - (st)))
+
/* Pseudo register base numbers. */
#define AARCH64_Q0_REGNUM 0
#define AARCH64_D0_REGNUM (AARCH64_Q0_REGNUM + 32)
@@ -2491,35 +2497,40 @@ aarch64_software_single_step (struct frame_info *frame)
int insn_count;
int bc_insn_count = 0; /* Conditional branch instruction count. */
int last_breakpoint = 0; /* Defaults to 0 (no breakpoints placed). */
+ aarch64_inst inst;
+
+ if (aarch64_decode_insn (insn, &inst) != 0)
+ return 0;
/* Look for a Load Exclusive instruction which begins the sequence. */
- if (!decode_masked_match (insn, 0x3fc00000, 0x08400000))
+ if (inst.opcode->iclass != ldstexcl || bit (insn, 22) == 0)
return 0;
for (insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
{
- int32_t offset;
- unsigned cond;
-
loc += insn_size;
insn = read_memory_unsigned_integer (loc, insn_size,
byte_order_for_code);
+ if (aarch64_decode_insn (insn, &inst) != 0)
+ return 0;
/* Check if the instruction is a conditional branch. */
- if (aarch64_decode_bcond (loc, insn, &cond, &offset))
+ if (inst.opcode->iclass == condbranch)
{
+ gdb_assert (inst.operands[0].type == AARCH64_OPND_ADDR_PCREL19);
+
if (bc_insn_count >= 1)
return 0;
/* It is, so we'll try to set a breakpoint at the destination. */
- breaks[1] = loc + offset;
+ breaks[1] = loc + inst.operands[0].imm.value;
bc_insn_count++;
last_breakpoint++;
}
/* Look for the Store Exclusive which closes the atomic sequence. */
- if (decode_masked_match (insn, 0x3fc00000, 0x08000000))
+ if (inst.opcode->iclass == ldstexcl && bit (insn, 22) == 0)
{
closing_insn = loc;
break;
@@ -2771,10 +2782,6 @@ When on, AArch64 specific debugging is enabled."),
/* AArch64 process record-replay related structures, defines etc. */
-#define submask(x) ((1L << ((x) + 1)) - 1)
-#define bit(obj,st) (((obj) >> (st)) & 1)
-#define bits(obj,st,fn) (((obj) >> (st)) & submask ((fn) - (st)))
-
#define REG_ALLOC(REGS, LENGTH, RECORD_BUF) \
do \
{ \
--
1.9.1
next prev parent reply other threads:[~2015-10-02 11:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 16:35 [PATCH 0/2] [aarch64] Use opcodes " Yao Qi
2015-10-01 16:35 ` [PATCH 1/2] [aarch64] Remove argument pc from disas_aarch64_insn Yao Qi
2015-10-01 16:36 ` [PATCH 2/2] [aarch64] Use opcodes to decode instructions in GDB Yao Qi
2015-10-02 7:51 ` Marcus Shawcroft
2015-10-02 11:24 ` [PATCH 0/3 V2] " Yao Qi
2015-10-02 11:24 ` [PATCH 1/3] [aarch64] Remove argument pc from disas_aarch64_insn Yao Qi
2015-10-02 12:30 ` Marcus Shawcroft
2015-10-02 11:24 ` [PATCH 2/3] [aarch64] expose disas_aarch64_insn and rename it to aarch64_decode_insn Yao Qi
2015-10-02 12:35 ` Marcus Shawcroft
2015-10-02 14:32 ` Yao Qi
2015-10-02 11:24 ` Yao Qi [this message]
2015-10-07 8:56 ` [PATCH 3/3] [aarch64] use aarch64_decode_insn to decode instructions in GDB Yao Qi
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=1443785039-24602-4-git-send-email-yao.qi@linaro.org \
--to=qiyaoltc@gmail.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=marcus.shawcroft@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