2010-12-23 Yao Qi * 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. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 636c1de..3227619 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -367,6 +367,22 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr) struct obj_section *sec; struct minimal_symbol *sym; char type; + 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, the mode + should be determined by instruction on the original address. */ + + if (displaced && !ptid_equal (displaced->step_ptid, null_ptid) + && (displaced->step_copy == memaddr)) + { + if (debug_displaced) + fprintf_unfiltered (gdb_stdlog, + "displaced: check mode of %.8lx instead of %.8lx\n", + (unsigned long) displaced->step_original, + (unsigned long) memaddr); + memaddr = displaced->step_original; + } /* 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 f80ecb5..7e68d3b 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -362,10 +362,46 @@ extern struct regcache *stop_registers; /* True if we are debugging displaced stepping. */ extern int debug_displaced; +/* Per-inferior displaced stepping state. */ +struct displaced_step_inferior_state +{ + /* Pointer to next in linked list. */ + struct displaced_step_inferior_state *next; + + /* The process this displaced step state refers to. */ + int pid; + + /* A queue of pending displaced stepping requests. One entry per + thread that needs to do a displaced step. */ + struct displaced_step_request *step_request_queue; + + /* If this is not null_ptid, this is the thread carrying out a + displaced single-step in process PID. This thread's state will + require fixing up once it has completed its step. */ + ptid_t step_ptid; + + /* The architecture the thread had when we stepped it. */ + struct gdbarch *step_gdbarch; + + /* The closure provided gdbarch_displaced_step_copy_insn, to be used + for post-step cleanup. */ + struct displaced_step_closure *step_closure; + + /* The address of the original instruction, and the copy we + made. */ + CORE_ADDR step_original, step_copy; + + /* Saved contents of copy area. */ + gdb_byte *step_saved_copy; +}; + /* Dump LEN bytes at BUF in hex to FILE, followed by a newline. */ void displaced_step_dump_bytes (struct ui_file *file, const gdb_byte *buf, size_t len); + +struct displaced_step_inferior_state *get_displaced_stepping_state (int pid); + /* Possible values for gdbarch_call_dummy_location. */ #define ON_STACK 1 diff --git a/gdb/infrun.c b/gdb/infrun.c index 1bc00a4..d943dd3 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -998,46 +998,13 @@ struct displaced_step_request struct displaced_step_request *next; }; -/* Per-inferior displaced stepping state. */ -struct displaced_step_inferior_state -{ - /* Pointer to next in linked list. */ - struct displaced_step_inferior_state *next; - - /* The process this displaced step state refers to. */ - int pid; - - /* A queue of pending displaced stepping requests. One entry per - thread that needs to do a displaced step. */ - struct displaced_step_request *step_request_queue; - - /* If this is not null_ptid, this is the thread carrying out a - displaced single-step in process PID. This thread's state will - require fixing up once it has completed its step. */ - ptid_t step_ptid; - - /* The architecture the thread had when we stepped it. */ - struct gdbarch *step_gdbarch; - - /* The closure provided gdbarch_displaced_step_copy_insn, to be used - for post-step cleanup. */ - struct displaced_step_closure *step_closure; - - /* The address of the original instruction, and the copy we - made. */ - CORE_ADDR step_original, step_copy; - - /* Saved contents of copy area. */ - gdb_byte *step_saved_copy; -}; - /* The list of states of processes involved in displaced stepping presently. */ static struct displaced_step_inferior_state *displaced_step_inferior_states; /* Get the displaced stepping state of process PID. */ -static struct displaced_step_inferior_state * +struct displaced_step_inferior_state * get_displaced_stepping_state (int pid) { struct displaced_step_inferior_state *state;