Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [try 3rd] arm_pc_is_thumb takes displaced stepping into account
Date: Wed, 12 Jan 2011 05:39:00 -0000	[thread overview]
Message-ID: <4D2D27F2.7050303@codesourcery.com> (raw)
In-Reply-To: <4D12F3A8.3020102@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 901 bytes --]

On 12/23/2010 01:00 AM, Yao Qi wrote:
> OK.  I have to try the second approach, which is 1) exposing displaced
> stepping state to tdep, and 2) take displaced stepping state into
> account when determining the mode.
>

After talked with Ulrich, I realize that it is *not* a good idea to 
expose displaced stepping outside of infrun, and my patch is a little 
bit too intrusive.

> 2010-12-23  Yao Qi<yao@codesourcery.com>
>
> 	* arm-tdep.c: (arm_pc_is_thumb):  Adjust MEMADDR if it is within
> 	copy area of displaced stepping.
> 	* infrun.c (struct displaced_step_inferior_state): Move to ...
> 	Expose get_displaced_stepping_state.
> 	* inferior.h: ... here.
> 	Declare get_displaced_stepping_state.

This time, instead of exposing displaced_step_inferior_state to tdep, we 
return displaced_step_closure, which is defined by each tdep, instance 
to tdep appropriately.

OK to mainline?

-- 
Yao Qi

[-- Attachment #2: arm_displace_step_in_thumb_0111.patch --]
[-- Type: text/x-patch, Size: 2445 bytes --]

gdb/
        * infrun.c (get_displaced_step_closure_by_addr): New.
        * inferior.h: Declare it.
        * arm-tdep.c: (arm_pc_is_thumb): Call
	get_displaced_step_closure_by_addr.  Adjust MEMADDR if it
	returns non-NULL.

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index ef4d9f3..fb080c1 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -368,6 +368,20 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr)
   struct obj_section *sec;
   struct minimal_symbol *sym;
   char type;
+  struct displaced_step_closure* dsc
+    = get_displaced_step_closure_by_addr(memaddr);
+
+  /* If checking the mode of displaced instruction in copy area, the mode
+     should be determined by instruction on the original address.  */
+  if (dsc)
+    {
+      if (debug_displaced)
+	fprintf_unfiltered (gdb_stdlog,
+			    "displaced: check mode of %.8lx instead of %.8lx\n",
+			    (unsigned long) dsc->insn_addr,
+			    (unsigned long) memaddr);
+      memaddr = dsc->insn_addr;
+    }
 
   /* If bit 0 of the address is set, assume this is a Thumb address.  */
   if (IS_THUMB_ADDR (memaddr))
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 7052d6f..a319847 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -366,6 +366,8 @@ extern int debug_displaced;
 void displaced_step_dump_bytes (struct ui_file *file,
                                 const gdb_byte *buf, size_t len);
 
+struct displaced_step_closure*
+get_displaced_step_closure_by_addr (CORE_ADDR addr);
 \f
 /* Possible values for gdbarch_call_dummy_location.  */
 #define ON_STACK 1
diff --git a/gdb/infrun.c b/gdb/infrun.c
index dd6fe6c..0714308 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1078,6 +1078,26 @@ add_displaced_stepping_state (int pid)
   return state;
 }
 
+/* If inferior is in displaced stepping, and ADDR equals to starting address
+   of copy area, return corresponding displaced_step_closure.  Otherwise,
+   return NULL.  */
+
+struct displaced_step_closure*
+get_displaced_step_closure_by_addr (CORE_ADDR addr)
+{
+  struct displaced_step_inferior_state *displaced
+    = get_displaced_stepping_state (ptid_get_pid (inferior_ptid));
+
+  /* If checking the mode of displaced instruction in copy area.  */
+  if (displaced && !ptid_equal (displaced->step_ptid, null_ptid)
+     && (displaced->step_copy == addr))
+    return displaced->step_closure;
+
+  return NULL;
+}
+
 /* Remove the displaced stepping state of process PID.  */
 
 static void

  parent reply	other threads:[~2011-01-12  4:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20  7:50 [rfa] Update PC without side effect in displaced stepping Yao Qi
2010-12-20  8:06 ` Mark Kettenis
2010-12-20 13:42   ` Yao Qi
2010-12-21 16:19     ` Yao Qi
2010-12-23  4:54       ` Joel Brobecker
2010-12-23  8:45         ` Yao Qi
2011-01-06 14:19           ` [PING : rfa] " Yao Qi
2011-01-12  5:39           ` Yao Qi [this message]
2011-01-13 15:55             ` [try 3rd] arm_pc_is_thumb takes displaced stepping into account Matthew Gretton-Dann
2011-01-13 16:34               ` Yao Qi
2011-01-19 16:09             ` [Ping 1: try " Yao Qi
2011-01-30  3:21               ` [Ping 2: " Yao Qi
2011-01-31 15:40             ` [try " Ulrich Weigand
2011-02-10  6:42               ` Yao Qi
2011-02-15 21:15                 ` Ulrich Weigand
2010-12-23 12:04         ` [rfa] Update PC without side effect in displaced stepping Mark Kettenis

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=4D2D27F2.7050303@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