aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2008-10-14 23:39:29 +0000
committerPedro Alves <palves@redhat.com>2008-10-14 23:39:29 +0000
commitad53cd71541c9a208dc896f1d7b5a8adbc0d856c (patch)
tree055358f8f7890a18c28e7280dc95dc9bff9037be
parent63c715c603b979fe95172c1873247a0ec0bff849 (diff)
downloadgdb-ad53cd71541c9a208dc896f1d7b5a8adbc0d856c.zip
gdb-ad53cd71541c9a208dc896f1d7b5a8adbc0d856c.tar.gz
gdb-ad53cd71541c9a208dc896f1d7b5a8adbc0d856c.tar.bz2
* infrun.c (displaced_step_prepare): Switch thread temporarily
while we're here. (displaced_step_fixup): Make sure target_resume sees ptid as inferior_ptid. Add debug output.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/infrun.c32
2 files changed, 32 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d134713..6bf9358 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2008-10-14 Pedro Alves <pedro@codesourcery.com>
+ * infrun.c (displaced_step_prepare): Switch thread temporarily
+ while we're here.
+ (displaced_step_fixup): Make sure target_resume sees ptid as
+ inferior_ptid. Add debug output.
+
+2008-10-14 Pedro Alves <pedro@codesourcery.com>
+
Remove dead code.
* breakpoint.c (show_breakpoint_hit_counts): Delete.
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 0aefa25..f60f938 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -629,7 +629,7 @@ displaced_step_dump_bytes (struct ui_file *file,
static int
displaced_step_prepare (ptid_t ptid)
{
- struct cleanup *old_cleanups;
+ struct cleanup *old_cleanups, *ignore_cleanups;
struct regcache *regcache = get_thread_regcache (ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR original, copy;
@@ -681,6 +681,9 @@ displaced_step_prepare (ptid_t ptid)
displaced_step_clear ();
+ old_cleanups = save_inferior_ptid ();
+ inferior_ptid = ptid;
+
original = regcache_read_pc (regcache);
copy = gdbarch_displaced_step_location (gdbarch);
@@ -688,8 +691,8 @@ displaced_step_prepare (ptid_t ptid)
/* Save the original contents of the copy area. */
displaced_step_saved_copy = xmalloc (len);
- old_cleanups = make_cleanup (free_current_contents,
- &displaced_step_saved_copy);
+ ignore_cleanups = make_cleanup (free_current_contents,
+ &displaced_step_saved_copy);
read_memory (copy, displaced_step_saved_copy, len);
if (debug_displaced)
{
@@ -699,7 +702,7 @@ displaced_step_prepare (ptid_t ptid)
};
closure = gdbarch_displaced_step_copy_insn (gdbarch,
- original, copy, regcache);
+ original, copy, regcache);
/* We don't support the fully-simulated case at present. */
gdb_assert (closure);
@@ -709,11 +712,13 @@ displaced_step_prepare (ptid_t ptid)
/* Resume execution at the copy. */
regcache_write_pc (regcache, copy);
- discard_cleanups (old_cleanups);
+ discard_cleanups (ignore_cleanups);
+
+ do_cleanups (old_cleanups);
if (debug_displaced)
fprintf_unfiltered (gdb_stdlog, "displaced: displaced pc to 0x%s\n",
- paddr_nz (copy));
+ paddr_nz (copy));
/* Save the information we need to fix things up if the step
succeeds. */
@@ -801,9 +806,22 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
"displaced: stepping queued %s now\n",
target_pid_to_str (ptid));
-
displaced_step_ptid = null_ptid;
displaced_step_prepare (ptid);
+ context_switch (ptid);
+
+ if (debug_displaced)
+ {
+ struct regcache *resume_regcache = get_thread_regcache (ptid);
+ CORE_ADDR actual_pc = regcache_read_pc (resume_regcache);
+ gdb_byte buf[4];
+
+ fprintf_unfiltered (gdb_stdlog, "displaced: run 0x%s: ",
+ paddr_nz (actual_pc));
+ read_memory (actual_pc, buf, sizeof (buf));
+ displaced_step_dump_bytes (gdb_stdlog, buf, sizeof (buf));
+ }
+
target_resume (ptid, 1, TARGET_SIGNAL_0);
}
}