+2020-02-14 Simon Marchi <simon.marchi@efficios.com>
+
+ * infrun.c (get_displaced_step_closure_by_addr): Adjust to
+ std::unique_ptr.
+ (displaced_step_clear): Rename to...
+ (displaced_step_reset): ... this. Just call displaced->reset ().
+ (displaced_step_clear_cleanup): Rename to...
+ (displaced_step_reset_cleanup): ... this.
+ (displaced_step_prepare_throw): Adjust to std::unique_ptr.
+ (displaced_step_fixup): Likewise.
+ (resume_1): Likewise.
+ (handle_inferior_event): Restore child's memory before calling
+ displaced_step_fixup on the parent.
+ * infrun.h (displaced_step_inferior_state) <reset>: Adjust
+ to std::unique_ptr.
+ <step_closure>: Change type to std::unique_ptr.
+
2020-02-14 Simon Marchi <simon.marchi@efficios.com>
* arm-tdep.c: Include count-one-bits.h.
/* If checking the mode of displaced instruction in copy area. */
if (displaced->step_thread != nullptr
&& displaced->step_copy == addr)
- return displaced->step_closure;
+ return displaced->step_closure.get ();
return NULL;
}
&& !displaced_state->failed_before);
}
-/* Clean out any stray displaced stepping state. */
+/* Simple function wrapper around displaced_step_inferior_state::reset. */
+
static void
-displaced_step_clear (struct displaced_step_inferior_state *displaced)
+displaced_step_reset (displaced_step_inferior_state *displaced)
{
- /* Indicate that there is no cleanup pending. */
- displaced->step_thread = nullptr;
-
- delete displaced->step_closure;
- displaced->step_closure = NULL;
+ displaced->reset ();
}
-/* A cleanup that wraps displaced_step_clear. */
-using displaced_step_clear_cleanup
- = FORWARD_SCOPE_EXIT (displaced_step_clear);
+/* A cleanup that wraps displaced_step_reset. We use this instead of, say,
+ SCOPE_EXIT, because it needs to be discardable with "cleanup.release ()". */
+
+using displaced_step_reset_cleanup = FORWARD_SCOPE_EXIT (displaced_step_reset);
/* Dump LEN bytes at BUF in hex to FILE, followed by a newline. */
void
target_pid_to_str (tp->ptid).c_str ());
}
- displaced_step_clear (displaced);
+ displaced_step_reset (displaced);
scoped_restore_current_thread restore_thread;
succeeds. */
displaced->step_thread = tp;
displaced->step_gdbarch = gdbarch;
- displaced->step_closure = closure;
+ displaced->step_closure.reset (closure);
displaced->step_original = original;
displaced->step_copy = copy;
{
- displaced_step_clear_cleanup cleanup (displaced);
+ displaced_step_reset_cleanup cleanup (displaced);
/* Resume execution at the copy. */
regcache_write_pc (regcache, copy);
if (displaced->step_thread != event_thread)
return 0;
- displaced_step_clear_cleanup cleanup (displaced);
+ displaced_step_reset_cleanup cleanup (displaced);
displaced_step_restore (displaced, displaced->step_thread->ptid);
{
/* Fix up the resulting state. */
gdbarch_displaced_step_fixup (displaced->step_gdbarch,
- displaced->step_closure,
+ displaced->step_closure.get (),
displaced->step_original,
displaced->step_copy,
get_thread_regcache (displaced->step_thread));
pc = regcache_read_pc (get_thread_regcache (tp));
displaced = get_displaced_stepping_state (tp->inf);
- step = gdbarch_displaced_step_hw_singlestep (gdbarch,
- displaced->step_closure);
+ step = gdbarch_displaced_step_hw_singlestep
+ (gdbarch, displaced->step_closure.get ());
}
}
struct regcache *child_regcache;
CORE_ADDR parent_pc;
+ if (ecs->ws.kind == TARGET_WAITKIND_FORKED)
+ {
+ struct displaced_step_inferior_state *displaced
+ = get_displaced_stepping_state (parent_inf);
+
+ /* Restore scratch pad for child process. */
+ displaced_step_restore (displaced, ecs->ws.value.related_pid);
+ }
+
/* GDB has got TARGET_WAITKIND_FORKED or TARGET_WAITKIND_VFORKED,
indicating that the displaced stepping of syscall instruction
has been done. Perform cleanup for parent process here. Note
that needs it. */
start_step_over ();
- if (ecs->ws.kind == TARGET_WAITKIND_FORKED)
- {
- struct displaced_step_inferior_state *displaced
- = get_displaced_stepping_state (parent_inf);
-
- /* Restore scratch pad for child process. */
- displaced_step_restore (displaced, ecs->ws.value.related_pid);
- }
-
/* Since the vfork/fork syscall instruction was executed in the scratchpad,
the child's PC is also within the scratchpad. Set the child's PC
to the parent's PC value, which has already been fixed up.