}
else
{
- struct program_space *pspace;
-
/* If this is a vfork child exiting, then the pspace and
aspaces were shared with the parent. Since we're
reporting the process exit, we'll be mourning all that is
scoped_restore restore_ptid
= make_scoped_restore (&inferior_ptid, null_ptid);
- /* This inferior is dead, so avoid giving the breakpoints
- module the option to write through to it (cloning a
- program space resets breakpoints). */
- inf->aspace = NULL;
- inf->pspace = NULL;
- pspace = new program_space (maybe_new_address_space ());
- set_current_program_space (pspace);
+ inf->pspace = new program_space (maybe_new_address_space ());
+ inf->aspace = inf->pspace->aspace;
+ set_current_program_space (inf->pspace);
inf->removable = 1;
inf->symfile_flags = SYMFILE_NO_READ;
- clone_program_space (pspace, vfork_parent->pspace);
- inf->pspace = pspace;
- inf->aspace = pspace->aspace;
+ clone_program_space (inf->pspace, vfork_parent->pspace);
resume_parent = vfork_parent->pid;
}
/* 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
const address_space *aspace = regcache->aspace ();
CORE_ADDR original, copy;
ULONGEST len;
- struct displaced_step_closure *closure;
int status;
/* We should never reach this function if the architecture does not
target_pid_to_str (tp->ptid).c_str ());
}
- displaced_step_clear (displaced);
+ displaced_step_reset (displaced);
scoped_restore_current_thread restore_thread;
len);
};
- closure = gdbarch_displaced_step_copy_insn (gdbarch,
- original, copy, regcache);
- if (closure == NULL)
+ displaced->step_closure
+ = gdbarch_displaced_step_copy_insn (gdbarch, original, copy, regcache);
+ if (displaced->step_closure == NULL)
{
/* The architecture doesn't know how or want to displaced step
this instruction or instruction sequence. Fallback to
succeeds. */
displaced->step_thread = tp;
displaced->step_gdbarch = gdbarch;
- displaced->step_closure = 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));
}
tp->inf->process_target ()->threads_executing = true;
- tp->resumed = 1;
+ tp->resumed = true;
/* FIXME: What should we do if we are supposed to resume this
thread with a signal? Maybe we should maintain a queue of
resume_ptid = internal_resume_ptid (user_step);
do_target_resume (resume_ptid, 0, GDB_SIGNAL_0);
- tp->resumed = 1;
+ tp->resumed = true;
return;
}
}
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 ());
}
}
}
do_target_resume (resume_ptid, step, sig);
- tp->resumed = 1;
+ tp->resumed = true;
}
/* Resume the inferior. SIG is the signal to give the inferior
inferior function, as in that case we pretend the inferior
doesn't run at all. */
if (!cur_thr->control.in_infcall)
- set_running (resume_target, resume_ptid, 1);
+ set_running (resume_target, resume_ptid, true);
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog,
/* Otherwise we can process the (new) pending event now. Set
it so this pending event is considered by
do_target_wait. */
- tp->resumed = 1;
+ tp->resumed = true;
}
}
/* The thread may be not executing, but still be
resumed with a pending status to process. */
- t->resumed = 0;
+ t->resumed = false;
}
}
t->stop_requested = 0;
t->executing = 0;
- t->resumed = 0;
+ t->resumed = false;
t->control.may_range_step = 0;
/* This may be the first time we see the inferior report
else
mark_ptid = ecs->ptid;
- set_executing (ecs->target, mark_ptid, 0);
+ set_executing (ecs->target, mark_ptid, false);
/* Likewise the resumed flag. */
- set_resumed (ecs->target, mark_ptid, 0);
+ set_resumed (ecs->target, mark_ptid, false);
}
switch (ecs->ws.kind)
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.
"infrun: restart threads: "
"[%s] has pending status\n",
target_pid_to_str (tp->ptid).c_str ());
- tp->resumed = 1;
+ tp->resumed = true;
continue;
}
/* This was cleared early, by handle_inferior_event. Set it
so this pending event is considered by
do_target_wait. */
- tp->resumed = 1;
+ tp->resumed = true;
gdb_assert (!tp->executing);
been removed. */
if (random_signal && target_stopped_by_sw_breakpoint ())
{
- if (program_breakpoint_here_p (gdbarch,
- ecs->event_thread->suspend.stop_pc))
+ if (gdbarch_program_breakpoint_here_p (gdbarch,
+ ecs->event_thread->suspend.stop_pc))
{
struct regcache *regcache;
int decr_pc;
get_frame_address_space (frame),
tp->suspend.stop_pc);
- tp->resumed = 1;
+ tp->resumed = true;
resume_ptid = internal_resume_ptid (tp->control.stepping_command);
do_target_resume (resume_ptid, 0, GDB_SIGNAL_0);
}