return (pc >= lwp->step_range_start && pc < lwp->step_range_end);
}
-struct pending_signals
-{
- int signal;
- siginfo_t info;
- struct pending_signals *prev;
-};
-
/* The read/write ends of the pipe registered as waitable file in the
event loop. */
static int linux_event_pipe[2] = { -1, -1 };
low_delete_thread (lwp->arch_private);
- free (lwp);
+ delete lwp;
}
void
{
struct lwp_info *lwp;
- lwp = XCNEW (struct lwp_info);
+ lwp = new lwp_info {};
lwp->waitstatus.kind = TARGET_WAITKIND_IGNORE;
static void
enqueue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
{
- struct pending_signals *p_sig;
struct thread_info *thread = get_lwp_thread (lwp);
if (debug_threads)
if (debug_threads)
{
- struct pending_signals *sig;
-
- for (sig = lwp->pending_signals_to_report;
- sig != NULL;
- sig = sig->prev)
+ for (const auto &sig : lwp->pending_signals_to_report)
debug_printf (" Already queued %d\n",
- sig->signal);
+ sig.signal);
debug_printf (" (no more currently queued signals)\n");
}
twice) */
if (WSTOPSIG (*wstat) < __SIGRTMIN)
{
- struct pending_signals *sig;
-
- for (sig = lwp->pending_signals_to_report;
- sig != NULL;
- sig = sig->prev)
+ for (const auto &sig : lwp->pending_signals_to_report)
{
- if (sig->signal == WSTOPSIG (*wstat))
+ if (sig.signal == WSTOPSIG (*wstat))
{
if (debug_threads)
debug_printf ("Not requeuing already queued non-RT signal %d"
" for LWP %ld\n",
- sig->signal,
+ sig.signal,
lwpid_of (thread));
return;
}
}
}
- p_sig = XCNEW (struct pending_signals);
- p_sig->prev = lwp->pending_signals_to_report;
- p_sig->signal = WSTOPSIG (*wstat);
+ lwp->pending_signals_to_report.emplace_back (WSTOPSIG (*wstat));
ptrace (PTRACE_GETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
- &p_sig->info);
-
- lwp->pending_signals_to_report = p_sig;
+ &lwp->pending_signals_to_report.back ().info);
}
/* Dequeue one signal from the "signals to report later when out of
{
struct thread_info *thread = get_lwp_thread (lwp);
- if (lwp->pending_signals_to_report != NULL)
+ if (!lwp->pending_signals_to_report.empty ())
{
- struct pending_signals **p_sig;
+ const pending_signal &p_sig = lwp->pending_signals_to_report.front ();
- p_sig = &lwp->pending_signals_to_report;
- while ((*p_sig)->prev != NULL)
- p_sig = &(*p_sig)->prev;
-
- *wstat = W_STOPCODE ((*p_sig)->signal);
- if ((*p_sig)->info.si_signo != 0)
+ *wstat = W_STOPCODE (p_sig.signal);
+ if (p_sig.info.si_signo != 0)
ptrace (PTRACE_SETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
- &(*p_sig)->info);
- free (*p_sig);
- *p_sig = NULL;
+ &p_sig.info);
+
+ lwp->pending_signals_to_report.pop_front ();
if (debug_threads)
debug_printf ("Reporting deferred signal %d for LWP %ld.\n",
if (debug_threads)
{
- struct pending_signals *sig;
-
- for (sig = lwp->pending_signals_to_report;
- sig != NULL;
- sig = sig->prev)
+ for (const auto &sig : lwp->pending_signals_to_report)
debug_printf (" Still queued %d\n",
- sig->signal);
+ sig.signal);
debug_printf (" (no more queued signals)\n");
}
static void
enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info)
{
- struct pending_signals *p_sig = XNEW (struct pending_signals);
-
- p_sig->prev = lwp->pending_signals;
- p_sig->signal = signal;
- if (info == NULL)
- memset (&p_sig->info, 0, sizeof (siginfo_t));
+ lwp->pending_signals.emplace_back (signal);
+ if (info == nullptr)
+ memset (&lwp->pending_signals.back ().info, 0, sizeof (siginfo_t));
else
- memcpy (&p_sig->info, info, sizeof (siginfo_t));
- lwp->pending_signals = p_sig;
+ lwp->pending_signals.back ().info = *info;
}
void
inferior right now. */
if (signal != 0
&& (lwp->status_pending_p
- || lwp->pending_signals != NULL
+ || !lwp->pending_signals.empty ()
|| !lwp_signal_can_be_delivered (lwp)))
{
enqueue_pending_signal (lwp, signal, info);
/* If we have pending signals, consume one if it can be delivered to
the inferior. */
- if (lwp->pending_signals != NULL && lwp_signal_can_be_delivered (lwp))
+ if (!lwp->pending_signals.empty () && lwp_signal_can_be_delivered (lwp))
{
- struct pending_signals **p_sig;
-
- p_sig = &lwp->pending_signals;
- while ((*p_sig)->prev != NULL)
- p_sig = &(*p_sig)->prev;
+ const pending_signal &p_sig = lwp->pending_signals.front ();
- signal = (*p_sig)->signal;
- if ((*p_sig)->info.si_signo != 0)
+ signal = p_sig.signal;
+ if (p_sig.info.si_signo != 0)
ptrace (PTRACE_SETSIGINFO, lwpid_of (thread), (PTRACE_TYPE_ARG3) 0,
- &(*p_sig)->info);
+ &p_sig.info);
- free (*p_sig);
- *p_sig = NULL;
+ lwp->pending_signals.pop_front ();
}
if (debug_threads)
/* On software single step target, resume the inferior with signal
rather than stepping over. */
if (supports_software_single_step ()
- && lwp->pending_signals != NULL
+ && !lwp->pending_signals.empty ()
&& lwp_signal_can_be_delivered (lwp))
{
if (debug_threads)
midway through moving the LWP out of the jumppad, and we
will report the pending signal as soon as that is
finished. */
- if (lwp->pending_signals_to_report == NULL)
+ if (lwp->pending_signals_to_report.empty ())
send_sigstop (lwp);
}
}
if (thread->last_resume_kind == resume_stop
- && lwp->pending_signals_to_report == NULL
+ && lwp->pending_signals_to_report.empty ()
&& (lwp->collecting_fast_tracepoint
== fast_tpoint_collect_result::not_collecting))
{
#include "target/waitstatus.h" /* For enum target_stop_reason. */
#include "tracepoint.h"
+#include <list>
+
#define PTRACE_XFER_TYPE long
#ifdef HAVE_LINUX_REGSETS
#define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
#define get_lwp_thread(lwp) ((lwp)->thread)
+/* Information about a signal that is to be delivered to a thread. */
+
+struct pending_signal
+{
+ pending_signal (int signal)
+ : signal {signal}
+ {};
+
+ int signal;
+ siginfo_t info;
+};
+
/* This struct is recorded in the target_data field of struct thread_info.
On linux ``all_threads'' is keyed by the LWP ID, which we use as the
next time we see this LWP stop. */
int must_set_ptrace_flags;
- /* If this is non-zero, it points to a chain of signals which need to
- be delivered to this process. */
- struct pending_signals *pending_signals;
+ /* A chain of signals that need to be delivered to this process. */
+ std::list<pending_signal> pending_signals;
/* A link used when resuming. It is initialized from the resume request,
and then processed and cleared in linux_resume_one_lwp. */
if a signal arrives to this lwp while it is collecting. */
fast_tpoint_collect_result collecting_fast_tracepoint;
- /* If this is non-zero, it points to a chain of signals which need
- to be reported to GDB. These were deferred because the thread
- was doing a fast tracepoint collect when they arrived. */
- struct pending_signals *pending_signals_to_report;
+ /* A chain of signals that need to be reported to GDB. These were
+ deferred because the thread was doing a fast tracepoint collect
+ when they arrived. */
+ std::list<pending_signal> pending_signals_to_report;
/* When collecting_fast_tracepoint is first found to be 1, we insert
a exit-jump-pad-quickly breakpoint. This is it. */