From: Yao Qi <yao@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [try 2nd 3/8] Refactor copy_svc_os
Date: Thu, 24 Mar 2011 14:01:00 -0000 [thread overview]
Message-ID: <4D8B4D84.4020002@codesourcery.com> (raw)
In-Reply-To: <4D8B4947.1000000@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 467 bytes --]
copy_svc is a little bit different from other copy helpers, OS stuff is
involved. arm_linux_copy_svc itself has nothing to do with ARM/Thumb
mode. It should work well under two modes. However, one of the
parameters INSN make it hard to be called from both modes. Fortunately,
INSN is *not* used inside arm_linux_copy_svc except printing debug
message. We can remove parameter INSN and TO, so it can be called from
two modes respectively.
--
Yao (é½å°§)
[-- Attachment #2: 0003-refactor-copy_svc_os-to-handle-multiple-modes.patch --]
[-- Type: text/x-patch, Size: 4343 bytes --]
2011-03-24 Yao Qi <yao@codesourcery.com>
* gdb/arm-linux-tdep.c (arm_linux_copy_svc): Remove parameters INSN
and TO.
* gdb/arm-tdep.c (cleanup_svc): Handle variable instruction size.
(arm_copy_svc): Remove parameters INSN and TO.
(decode_svc_copro): Update caller.
* gdb/arm-tdep.h (struct displaced_step_closure): Remove parameters
from function pointer `copy_svc_os'.
---
gdb/arm-linux-tdep.c | 10 ++--------
gdb/arm-tdep.c | 20 ++++++++++++--------
gdb/arm-tdep.h | 3 +--
3 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 2f3109c..e44ba25 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -798,19 +798,14 @@ arm_linux_cleanup_svc (struct gdbarch *gdbarch,
}
static int
-arm_linux_copy_svc (struct gdbarch *gdbarch, uint32_t insn, CORE_ADDR to,
- struct regcache *regs, struct displaced_step_closure *dsc)
+arm_linux_copy_svc (struct gdbarch *gdbarch, struct regcache *regs,
+ struct displaced_step_closure *dsc)
{
CORE_ADDR return_to = 0;
struct frame_info *frame;
unsigned int svc_number = displaced_read_reg (regs, dsc, 7);
int is_sigreturn = 0;
-
- if (debug_displaced)
- fprintf_unfiltered (gdb_stdlog, "displaced: copying Linux svc insn %.8lx\n",
- (unsigned long) insn);
-
frame = get_current_frame ();
is_sigreturn = arm_linux_sigreturn_return_addr(frame, svc_number,
@@ -864,7 +859,6 @@ arm_linux_copy_svc (struct gdbarch *gdbarch, uint32_t insn, CORE_ADDR to,
Cleanup: if pc lands in scratch space, pc <- insn_addr + 4
else leave pc alone. */
- dsc->modinsn[0] = insn;
dsc->cleanup = &arm_linux_cleanup_svc;
/* Pretend we wrote to the PC, so cleanup doesn't set PC to the next
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index af81b1e..3348dcb 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -6412,7 +6412,7 @@ static void
cleanup_svc (struct gdbarch *gdbarch, struct regcache *regs,
struct displaced_step_closure *dsc)
{
- CORE_ADDR resume_addr = dsc->insn_addr + 4;
+ CORE_ADDR resume_addr = dsc->insn_addr + dsc->insn_size;
if (debug_displaced)
fprintf_unfiltered (gdb_stdlog, "displaced: cleanup for svc, resume at "
@@ -6422,12 +6422,9 @@ cleanup_svc (struct gdbarch *gdbarch, struct regcache *regs,
}
static int
-arm_copy_svc (struct gdbarch *gdbarch, uint32_t insn, CORE_ADDR to,
+arm_copy_svc (struct gdbarch *gdbarch, uint32_t insn,
struct regcache *regs, struct displaced_step_closure *dsc)
{
- /* Allow OS-specific code to override SVC handling. */
- if (dsc->u.svc.copy_svc_os)
- return dsc->u.svc.copy_svc_os (gdbarch, insn, to, regs, dsc);
if (debug_displaced)
fprintf_unfiltered (gdb_stdlog, "displaced: copying svc insn %.8lx\n",
@@ -6439,12 +6436,19 @@ arm_copy_svc (struct gdbarch *gdbarch, uint32_t insn, CORE_ADDR to,
dsc->modinsn[0] = insn;
- dsc->cleanup = &cleanup_svc;
/* Pretend we wrote to the PC, so cleanup doesn't set PC to the next
instruction. */
dsc->wrote_to_pc = 1;
- return 0;
+ /* Allow OS-specific code to override SVC handling. */
+ if (dsc->u.svc.copy_svc_os)
+ return dsc->u.svc.copy_svc_os (gdbarch, regs, dsc);
+ else
+ {
+ dsc->cleanup = &cleanup_svc;
+ return 0;
+ }
+
}
/* Copy undefined instructions. */
@@ -6898,7 +6902,7 @@ decode_svc_copro (struct gdbarch *gdbarch, uint32_t insn, CORE_ADDR to,
else if ((op1 & 0x31) == 0x21 && op && (coproc & 0xe) != 0xa)
return arm_copy_unmodified (gdbarch, insn, "mrc/mrc2", dsc);
else if ((op1 & 0x30) == 0x30)
- return arm_copy_svc (gdbarch, insn, to, regs, dsc);
+ return arm_copy_svc (gdbarch, insn, regs, dsc);
else
return copy_undef (gdbarch, insn, dsc); /* Possibly unreachable. */
}
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 3b1fce9..3f5e7d6 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -271,8 +271,7 @@ struct displaced_step_closure
{
/* If non-NULL, override generic SVC handling (e.g. for a particular
OS). */
- int (*copy_svc_os) (struct gdbarch *gdbarch, uint32_t insn, CORE_ADDR to,
- struct regcache *regs,
+ int (*copy_svc_os) (struct gdbarch *gdbarch, struct regcache *regs,
struct displaced_step_closure *dsc);
} svc;
} u;
--
1.7.0.4
next prev parent reply other threads:[~2011-03-24 13:56 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-25 14:17 [patch 0/3] Displaced stepping for 16-bit Thumb instructions Yao Qi
2010-12-25 14:22 ` [patch 1/3] " Yao Qi
2011-02-17 19:09 ` Ulrich Weigand
2010-12-25 17:09 ` [patch 2/3] " Yao Qi
2011-02-17 19:46 ` Ulrich Weigand
2011-02-18 6:33 ` Yao Qi
2011-02-18 12:18 ` Ulrich Weigand
2011-02-21 7:41 ` Yao Qi
2011-02-21 20:14 ` Ulrich Weigand
2011-02-25 18:09 ` Yao Qi
2011-02-25 20:17 ` Ulrich Weigand
2011-02-26 14:07 ` Yao Qi
2011-02-28 17:37 ` Ulrich Weigand
2011-03-01 9:01 ` Yao Qi
2011-03-01 16:11 ` Ulrich Weigand
2010-12-25 17:54 ` [patch 3/3] " Yao Qi
2010-12-27 15:15 ` Yao Qi
2011-02-17 20:55 ` Ulrich Weigand
2011-02-18 7:30 ` Yao Qi
2011-02-18 13:25 ` Ulrich Weigand
2011-02-28 2:04 ` Displaced stepping 0003: " Yao Qi
2010-12-29 5:48 ` [patch 0/3] Displaced stepping " Yao Qi
2011-01-13 12:38 ` Yao Qi
2011-02-10 6:48 ` Ping 2 " Yao Qi
2011-02-26 17:50 ` Displaced stepping 0002: refactor and create some copy helpers Yao Qi
2011-02-28 17:53 ` Ulrich Weigand
2011-02-28 2:15 ` Displaced stepping 0004: wip: 32-bit Thumb instructions Yao Qi
2011-03-24 13:49 ` [try 2nd 0/8] Displaced stepping for " Yao Qi
2011-03-24 13:56 ` [try 2nd 1/8] Fix cleanup_branch to take Thumb into account Yao Qi
2011-04-06 20:46 ` Ulrich Weigand
2011-04-07 3:45 ` Yao Qi
2011-03-24 13:58 ` [try 2nd 2/8] Rename copy_* functions to arm_copy_* Yao Qi
2011-04-06 20:51 ` Ulrich Weigand
2011-04-07 8:02 ` Yao Qi
2011-04-19 9:07 ` Yao Qi
2011-04-26 17:09 ` Ulrich Weigand
2011-04-27 10:27 ` Yao Qi
2011-04-27 13:32 ` Ulrich Weigand
2011-04-28 5:05 ` Yao Qi
2011-03-24 14:01 ` Yao Qi [this message]
2011-04-06 20:55 ` [try 2nd 3/8] Refactor copy_svc_os Ulrich Weigand
2011-04-07 4:19 ` Yao Qi
2011-03-24 14:05 ` [try 2nd 4/8] Displaced stepping for Thumb 16-bit insn Yao Qi
2011-05-05 13:24 ` Yao Qi
2011-05-10 13:58 ` Ulrich Weigand
2011-05-11 13:06 ` Yao Qi
2011-05-16 17:19 ` Ulrich Weigand
2011-05-17 14:29 ` Yao Qi
2011-05-17 17:20 ` Ulrich Weigand
2011-03-24 14:05 ` [try 2nd 5/8] Displaced stepping for Thumb 32-bit insns Yao Qi
2011-05-05 13:25 ` Yao Qi
2011-05-17 17:14 ` Ulrich Weigand
2011-05-23 11:32 ` Yao Qi
2011-05-23 11:32 ` Yao Qi
2011-05-27 22:11 ` Ulrich Weigand
2011-07-06 10:55 ` Yao Qi
2011-07-15 19:57 ` Ulrich Weigand
2011-07-18 9:26 ` Yao Qi
2011-03-24 14:06 ` [try 2nd 6/8] Rename some functions to arm_* Yao Qi
2011-04-06 20:52 ` Ulrich Weigand
2011-04-07 4:26 ` Yao Qi
2011-03-24 14:11 ` [try 2nd 7/8] Test case Yao Qi
2011-05-05 13:26 ` Yao Qi
2011-05-11 13:15 ` [try 2nd 7/8] Test case: V3 Yao Qi
2011-05-17 17:24 ` Ulrich Weigand
2011-03-24 15:14 ` [try 2nd 8/8] NEWS 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=4D8B4D84.4020002@codesourcery.com \
--to=yao@codesourcery.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