From a42244dbec4d58c5577a84215d92c85a6c067d1a Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Wed, 16 Feb 2011 14:54:42 +0000 Subject: [PATCH] 2011-02-16 Yao Qi * 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. --- gdb/ChangeLog | 8 ++++++++ gdb/arm-tdep.c | 14 ++++++++++++++ gdb/inferior.h | 2 ++ gdb/infrun.c | 18 ++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6b92f5d6cf..b81c0ba4e7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2011-02-16 Yao Qi + + * 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. + 2011-02-16 Pedro Alves Jan Kratochvil diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 6a279d19e1..96061e37d9 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -369,6 +369,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 7cebcbf6bf..381fd8274d 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); /* Possible values for gdbarch_call_dummy_location. */ #define ON_STACK 1 diff --git a/gdb/infrun.c b/gdb/infrun.c index dd26af3194..274082dc3b 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1078,6 +1078,24 @@ 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 -- 2.34.1