Some get_last_target_status tweaks
- Make get_last_target_status arguments optional. A following patch will add another argument to get_last_target_status (the event's target), and passing nullptr when we don't care for some piece of info is handier than creating dummy local variables. - Declare nullify_last_target_wait_ptid in a header, and remove the local extern declaration from linux-fork.c. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * break-catch-sig.c (signal_catchpoint_print_it): Don't pass a ptid to get_last_target_status. * break-catch-syscall.c (print_it_catch_syscall): Don't pass a ptid to get_last_target_status. * infcmd.c (continue_command): Don't pass a target_waitstatus to get_last_target_status. (info_program_command): Don't pass a target_waitstatus to get_last_target_status. * infrun.c (init_wait_for_inferior): Use nullify_last_target_wait_ptid. (get_last_target_status): Handle nullptr arguments. (nullify_last_target_wait_ptid): Clear target_last_waitstatus. (print_stop_event): Don't pass a ptid to get_last_target_status. (normal_stop): Don't pass a ptid to get_last_target_status. * infrun.h (get_last_target_status, set_last_target_status): Move comments here and update. (nullify_last_target_wait_ptid): Declare. * linux-fork.c (fork_load_infrun_state): Remove local extern declaration of nullify_last_target_wait_ptid. * linux-nat.c (get_detach_signal): Don't pass a target_waitstatus to get_last_target_status.
This commit is contained in:
parent
f3f8ece4b1
commit
ab1ddbcf11
8 changed files with 51 additions and 29 deletions
|
@ -1,3 +1,27 @@
|
||||||
|
2020-01-10 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* break-catch-sig.c (signal_catchpoint_print_it): Don't pass a
|
||||||
|
ptid to get_last_target_status.
|
||||||
|
* break-catch-syscall.c (print_it_catch_syscall): Don't pass a
|
||||||
|
ptid to get_last_target_status.
|
||||||
|
* infcmd.c (continue_command): Don't pass a target_waitstatus to
|
||||||
|
get_last_target_status.
|
||||||
|
(info_program_command): Don't pass a target_waitstatus to
|
||||||
|
get_last_target_status.
|
||||||
|
* infrun.c (init_wait_for_inferior): Use
|
||||||
|
nullify_last_target_wait_ptid.
|
||||||
|
(get_last_target_status): Handle nullptr arguments.
|
||||||
|
(nullify_last_target_wait_ptid): Clear target_last_waitstatus.
|
||||||
|
(print_stop_event): Don't pass a ptid to get_last_target_status.
|
||||||
|
(normal_stop): Don't pass a ptid to get_last_target_status.
|
||||||
|
* infrun.h (get_last_target_status, set_last_target_status): Move
|
||||||
|
comments here and update.
|
||||||
|
(nullify_last_target_wait_ptid): Declare.
|
||||||
|
* linux-fork.c (fork_load_infrun_state): Remove local extern
|
||||||
|
declaration of nullify_last_target_wait_ptid.
|
||||||
|
* linux-nat.c (get_detach_signal): Don't pass a target_waitstatus
|
||||||
|
to get_last_target_status.
|
||||||
|
|
||||||
2020-01-10 Pedro Alves <palves@redhat.com>
|
2020-01-10 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* gdbthread.h (scoped_restore_current_thread)
|
* gdbthread.h (scoped_restore_current_thread)
|
||||||
|
|
|
@ -181,12 +181,11 @@ static enum print_stop_action
|
||||||
signal_catchpoint_print_it (bpstat bs)
|
signal_catchpoint_print_it (bpstat bs)
|
||||||
{
|
{
|
||||||
struct breakpoint *b = bs->breakpoint_at;
|
struct breakpoint *b = bs->breakpoint_at;
|
||||||
ptid_t ptid;
|
|
||||||
struct target_waitstatus last;
|
struct target_waitstatus last;
|
||||||
const char *signal_name;
|
const char *signal_name;
|
||||||
struct ui_out *uiout = current_uiout;
|
struct ui_out *uiout = current_uiout;
|
||||||
|
|
||||||
get_last_target_status (&ptid, &last);
|
get_last_target_status (nullptr, &last);
|
||||||
|
|
||||||
signal_name = signal_to_name_or_int (last.value.sig);
|
signal_name = signal_to_name_or_int (last.value.sig);
|
||||||
|
|
||||||
|
|
|
@ -182,12 +182,11 @@ print_it_catch_syscall (bpstat bs)
|
||||||
syscall is. It can be in the TARGET_WAITKIND_SYSCALL_ENTRY
|
syscall is. It can be in the TARGET_WAITKIND_SYSCALL_ENTRY
|
||||||
or TARGET_WAITKIND_SYSCALL_RETURN, and depending on it we
|
or TARGET_WAITKIND_SYSCALL_RETURN, and depending on it we
|
||||||
must print "called syscall" or "returned from syscall". */
|
must print "called syscall" or "returned from syscall". */
|
||||||
ptid_t ptid;
|
|
||||||
struct target_waitstatus last;
|
struct target_waitstatus last;
|
||||||
struct syscall s;
|
struct syscall s;
|
||||||
struct gdbarch *gdbarch = bs->bp_location_at->gdbarch;
|
struct gdbarch *gdbarch = bs->bp_location_at->gdbarch;
|
||||||
|
|
||||||
get_last_target_status (&ptid, &last);
|
get_last_target_status (nullptr, &last);
|
||||||
|
|
||||||
get_syscall_by_number (gdbarch, last.value.syscall_number, &s);
|
get_syscall_by_number (gdbarch, last.value.syscall_number, &s);
|
||||||
|
|
||||||
|
|
|
@ -851,9 +851,8 @@ continue_command (const char *args, int from_tty)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptid_t last_ptid;
|
ptid_t last_ptid;
|
||||||
struct target_waitstatus ws;
|
|
||||||
|
|
||||||
get_last_target_status (&last_ptid, &ws);
|
get_last_target_status (&last_ptid, nullptr);
|
||||||
tp = find_thread_ptid (last_ptid);
|
tp = find_thread_ptid (last_ptid);
|
||||||
}
|
}
|
||||||
if (tp != NULL)
|
if (tp != NULL)
|
||||||
|
@ -1993,11 +1992,7 @@ info_program_command (const char *args, int from_tty)
|
||||||
if (non_stop)
|
if (non_stop)
|
||||||
ptid = inferior_ptid;
|
ptid = inferior_ptid;
|
||||||
else
|
else
|
||||||
{
|
get_last_target_status (&ptid, nullptr);
|
||||||
struct target_waitstatus ws;
|
|
||||||
|
|
||||||
get_last_target_status (&ptid, &ws);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ptid == null_ptid || ptid == minus_one_ptid)
|
if (ptid == null_ptid || ptid == minus_one_ptid)
|
||||||
error (_("No selected thread."));
|
error (_("No selected thread."));
|
||||||
|
|
26
gdb/infrun.c
26
gdb/infrun.c
|
@ -78,8 +78,6 @@ static void follow_inferior_reset_breakpoints (void);
|
||||||
|
|
||||||
static int currently_stepping (struct thread_info *tp);
|
static int currently_stepping (struct thread_info *tp);
|
||||||
|
|
||||||
void nullify_last_target_wait_ptid (void);
|
|
||||||
|
|
||||||
static void insert_hp_step_resume_breakpoint_at_frame (struct frame_info *);
|
static void insert_hp_step_resume_breakpoint_at_frame (struct frame_info *);
|
||||||
|
|
||||||
static void insert_step_resume_breakpoint_at_caller (struct frame_info *);
|
static void insert_step_resume_breakpoint_at_caller (struct frame_info *);
|
||||||
|
@ -3103,7 +3101,7 @@ init_wait_for_inferior (void)
|
||||||
|
|
||||||
clear_proceed_status (0);
|
clear_proceed_status (0);
|
||||||
|
|
||||||
target_last_wait_ptid = minus_one_ptid;
|
nullify_last_target_wait_ptid ();
|
||||||
|
|
||||||
previous_inferior_ptid = inferior_ptid;
|
previous_inferior_ptid = inferior_ptid;
|
||||||
}
|
}
|
||||||
|
@ -3847,7 +3845,7 @@ init_thread_stepping_state (struct thread_info *tss)
|
||||||
tss->step_after_step_resume_breakpoint = 0;
|
tss->step_after_step_resume_breakpoint = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the cached copy of the last ptid/waitstatus. */
|
/* See infrun.h. */
|
||||||
|
|
||||||
void
|
void
|
||||||
set_last_target_status (ptid_t ptid, struct target_waitstatus status)
|
set_last_target_status (ptid_t ptid, struct target_waitstatus status)
|
||||||
|
@ -3856,22 +3854,24 @@ set_last_target_status (ptid_t ptid, struct target_waitstatus status)
|
||||||
target_last_waitstatus = status;
|
target_last_waitstatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the cached copy of the last pid/waitstatus returned by
|
/* See infrun.h. */
|
||||||
target_wait()/deprecated_target_wait_hook(). The data is actually
|
|
||||||
cached by handle_inferior_event(), which gets called immediately
|
|
||||||
after target_wait()/deprecated_target_wait_hook(). */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
get_last_target_status (ptid_t *ptidp, struct target_waitstatus *status)
|
get_last_target_status (ptid_t *ptid, struct target_waitstatus *status)
|
||||||
{
|
{
|
||||||
*ptidp = target_last_wait_ptid;
|
if (ptid != nullptr)
|
||||||
|
*ptid = target_last_wait_ptid;
|
||||||
|
if (status != nullptr)
|
||||||
*status = target_last_waitstatus;
|
*status = target_last_waitstatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See infrun.h. */
|
||||||
|
|
||||||
void
|
void
|
||||||
nullify_last_target_wait_ptid (void)
|
nullify_last_target_wait_ptid (void)
|
||||||
{
|
{
|
||||||
target_last_wait_ptid = minus_one_ptid;
|
target_last_wait_ptid = minus_one_ptid;
|
||||||
|
target_last_waitstatus = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Switch thread contexts. */
|
/* Switch thread contexts. */
|
||||||
|
@ -7876,10 +7876,9 @@ void
|
||||||
print_stop_event (struct ui_out *uiout, bool displays)
|
print_stop_event (struct ui_out *uiout, bool displays)
|
||||||
{
|
{
|
||||||
struct target_waitstatus last;
|
struct target_waitstatus last;
|
||||||
ptid_t last_ptid;
|
|
||||||
struct thread_info *tp;
|
struct thread_info *tp;
|
||||||
|
|
||||||
get_last_target_status (&last_ptid, &last);
|
get_last_target_status (nullptr, &last);
|
||||||
|
|
||||||
{
|
{
|
||||||
scoped_restore save_uiout = make_scoped_restore (¤t_uiout, uiout);
|
scoped_restore save_uiout = make_scoped_restore (¤t_uiout, uiout);
|
||||||
|
@ -7998,9 +7997,8 @@ int
|
||||||
normal_stop (void)
|
normal_stop (void)
|
||||||
{
|
{
|
||||||
struct target_waitstatus last;
|
struct target_waitstatus last;
|
||||||
ptid_t last_ptid;
|
|
||||||
|
|
||||||
get_last_target_status (&last_ptid, &last);
|
get_last_target_status (nullptr, &last);
|
||||||
|
|
||||||
new_stop_id ();
|
new_stop_id ();
|
||||||
|
|
||||||
|
|
|
@ -101,12 +101,21 @@ extern void wait_for_inferior (void);
|
||||||
target, false otherwise. */
|
target, false otherwise. */
|
||||||
extern int normal_stop (void);
|
extern int normal_stop (void);
|
||||||
|
|
||||||
|
/* Return the cached copy of the last ptid/waitstatus returned
|
||||||
|
by target_wait()/deprecated_target_wait_hook(). The data is
|
||||||
|
actually cached by handle_inferior_event(), which gets called
|
||||||
|
immediately after target_wait()/deprecated_target_wait_hook(). */
|
||||||
extern void get_last_target_status (ptid_t *ptid,
|
extern void get_last_target_status (ptid_t *ptid,
|
||||||
struct target_waitstatus *status);
|
struct target_waitstatus *status);
|
||||||
|
|
||||||
|
/* Set the cached copy of the last ptid/waitstatus. */
|
||||||
extern void set_last_target_status (ptid_t ptid,
|
extern void set_last_target_status (ptid_t ptid,
|
||||||
struct target_waitstatus status);
|
struct target_waitstatus status);
|
||||||
|
|
||||||
|
/* Clear the cached copy of the last ptid/waitstatus returned by
|
||||||
|
target_wait(). */
|
||||||
|
extern void nullify_last_target_wait_ptid ();
|
||||||
|
|
||||||
/* Stop all threads. Only returns after everything is halted. */
|
/* Stop all threads. Only returns after everything is halted. */
|
||||||
extern void stop_all_threads (void);
|
extern void stop_all_threads (void);
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,6 @@ call_lseek (int fd, off_t offset, int whence)
|
||||||
static void
|
static void
|
||||||
fork_load_infrun_state (struct fork_info *fp)
|
fork_load_infrun_state (struct fork_info *fp)
|
||||||
{
|
{
|
||||||
extern void nullify_last_target_wait_ptid ();
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
linux_nat_switch_fork (fp->ptid);
|
linux_nat_switch_fork (fp->ptid);
|
||||||
|
|
|
@ -1315,10 +1315,9 @@ get_detach_signal (struct lwp_info *lp)
|
||||||
}
|
}
|
||||||
else if (!target_is_non_stop_p ())
|
else if (!target_is_non_stop_p ())
|
||||||
{
|
{
|
||||||
struct target_waitstatus last;
|
|
||||||
ptid_t last_ptid;
|
ptid_t last_ptid;
|
||||||
|
|
||||||
get_last_target_status (&last_ptid, &last);
|
get_last_target_status (&last_ptid, nullptr);
|
||||||
|
|
||||||
if (lp->ptid.lwp () == last_ptid.lwp ())
|
if (lp->ptid.lwp () == last_ptid.lwp ())
|
||||||
signo = tp->suspend.stop_signal;
|
signo = tp->suspend.stop_signal;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue