pc = (*the_low_target.get_pc) (regcache);
if (debug_threads)
- fprintf (stderr, "pc is 0x%lx\n", (long) pc);
+ debug_printf ("pc is 0x%lx\n", (long) pc);
current_inferior = saved_inferior;
return pc;
stop_pc -= the_low_target.decr_pc_after_break;
if (debug_threads)
- fprintf (stderr, "stop pc is 0x%lx\n", (long) stop_pc);
+ debug_printf ("stop pc is 0x%lx\n", (long) stop_pc);
return stop_pc;
}
if (linux_proc_pid_is_stopped (lwpid))
{
if (debug_threads)
- fprintf (stderr,
- "Attached to a stopped process\n");
+ debug_printf ("Attached to a stopped process\n");
/* The process is definitely stopped. It is in a job control
stop, unless the kernel predates the TASK_STOPPED /
new_threads_found++;
if (debug_threads)
- fprintf (stderr, "\
-Found and attached to new lwp %ld\n", lwp);
+ debug_printf ("Found and attached to new lwp %ld\n",
+ lwp);
}
}
errno = 0;
kill (pid, SIGKILL);
if (debug_threads)
- fprintf (stderr,
- "LKL: kill (SIGKILL) %s, 0, 0 (%s)\n",
- target_pid_to_str (ptid_of (lwp)),
- errno ? strerror (errno) : "OK");
+ debug_printf ("LKL: kill (SIGKILL) %s, 0, 0 (%s)\n",
+ target_pid_to_str (ptid_of (lwp)),
+ errno ? strerror (errno) : "OK");
errno = 0;
ptrace (PTRACE_KILL, pid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0);
if (debug_threads)
- fprintf (stderr,
- "LKL: PTRACE_KILL %s, 0, 0 (%s)\n",
- target_pid_to_str (ptid_of (lwp)),
- errno ? strerror (errno) : "OK");
+ debug_printf ("LKL: PTRACE_KILL %s, 0, 0 (%s)\n",
+ target_pid_to_str (ptid_of (lwp)),
+ errno ? strerror (errno) : "OK");
}
/* Callback for `find_inferior'. Kills an lwp of a given process,
if (lwpid_of (lwp) == pid)
{
if (debug_threads)
- fprintf (stderr, "lkop: is last of process %s\n",
- target_pid_to_str (entry->id));
+ debug_printf ("lkop: is last of process %s\n",
+ target_pid_to_str (entry->id));
return 0;
}
if (lwp == NULL)
{
if (debug_threads)
- fprintf (stderr, "lk_1: cannot find lwp %ld, for pid: %d\n",
- lwpid_of (lwp), pid);
+ debug_printf ("lk_1: cannot find lwp %ld, for pid: %d\n",
+ lwpid_of (lwp), pid);
}
else
{
if (debug_threads)
- fprintf (stderr, "lk_1: killing lwp %ld, for pid: %d\n",
- lwpid_of (lwp), pid);
+ debug_printf ("lk_1: killing lwp %ld, for pid: %d\n",
+ lwpid_of (lwp), pid);
do
{
if (!WIFSTOPPED (status))
{
if (debug_threads)
- fprintf (stderr,
- "GPS: lwp %s hasn't stopped: no pending signal\n",
- target_pid_to_str (ptid_of (lp)));
+ debug_printf ("GPS: lwp %s hasn't stopped: no pending signal\n",
+ target_pid_to_str (ptid_of (lp)));
return 0;
}
if (WSTOPSIG (status) == SIGTRAP && status >> 16 != 0)
{
if (debug_threads)
- fprintf (stderr,
- "GPS: lwp %s had stopped with extended "
- "status: no pending signal\n",
- target_pid_to_str (ptid_of (lp)));
+ debug_printf ("GPS: lwp %s had stopped with extended "
+ "status: no pending signal\n",
+ target_pid_to_str (ptid_of (lp)));
return 0;
}
if (program_signals_p && !program_signals[signo])
{
if (debug_threads)
- fprintf (stderr,
- "GPS: lwp %s had signal %s, but it is in nopass state\n",
- target_pid_to_str (ptid_of (lp)),
- gdb_signal_to_string (signo));
+ debug_printf ("GPS: lwp %s had signal %s, but it is in nopass state\n",
+ target_pid_to_str (ptid_of (lp)),
+ gdb_signal_to_string (signo));
return 0;
}
else if (!program_signals_p
&& (signo == GDB_SIGNAL_TRAP || signo == GDB_SIGNAL_INT))
{
if (debug_threads)
- fprintf (stderr,
- "GPS: lwp %s had signal %s, "
- "but we don't know if we should pass it. Default to not.\n",
- target_pid_to_str (ptid_of (lp)),
- gdb_signal_to_string (signo));
+ debug_printf ("GPS: lwp %s had signal %s, "
+ "but we don't know if we should pass it. "
+ "Default to not.\n",
+ target_pid_to_str (ptid_of (lp)),
+ gdb_signal_to_string (signo));
return 0;
}
else
{
if (debug_threads)
- fprintf (stderr,
- "GPS: lwp %s has pending signal %s: delivering it.\n",
- target_pid_to_str (ptid_of (lp)),
- gdb_signal_to_string (signo));
+ debug_printf ("GPS: lwp %s has pending signal %s: delivering it.\n",
+ target_pid_to_str (ptid_of (lp)),
+ gdb_signal_to_string (signo));
return WSTOPSIG (status);
}
if (lwp->stop_expected)
{
if (debug_threads)
- fprintf (stderr,
- "Sending SIGCONT to %s\n",
- target_pid_to_str (ptid_of (lwp)));
+ debug_printf ("Sending SIGCONT to %s\n",
+ target_pid_to_str (ptid_of (lwp)));
kill_lwp (lwpid_of (lwp), SIGCONT);
lwp->stop_expected = 0;
struct lwp_info *child = NULL;
if (debug_threads)
- fprintf (stderr, "linux_wait_for_lwp: %s\n", target_pid_to_str (ptid));
+ debug_printf ("linux_wait_for_lwp: %s\n", target_pid_to_str (ptid));
if (ptid_equal (ptid, minus_one_ptid))
to_wait_for = -1; /* any child */
&& (!WIFSTOPPED (*wstatp)
|| (WSTOPSIG (*wstatp) != 32
&& WSTOPSIG (*wstatp) != 33)))
- fprintf (stderr, "Got an event from %d (%x)\n", ret, *wstatp);
+ debug_printf ("Got an event from %d (%x)\n", ret, *wstatp);
child = find_lwp_pid (pid_to_ptid (ret));
current_inferior = get_lwp_thread (child);
regcache = get_thread_regcache (current_inferior, 1);
pc = (*the_low_target.get_pc) (regcache);
- fprintf (stderr, "linux_wait_for_lwp: pc is 0x%lx\n", (long) pc);
+ debug_printf ("linux_wait_for_lwp: pc is 0x%lx\n", (long) pc);
current_inferior = saved_inferior;
}
if (tpoint_related_event)
{
if (debug_threads)
- fprintf (stderr, "got a tracepoint event\n");
+ debug_printf ("got a tracepoint event\n");
return 1;
}
int r;
if (debug_threads)
- fprintf (stderr, "\
-Checking whether LWP %ld needs to move out of the jump pad.\n",
- lwpid_of (lwp));
+ debug_printf ("Checking whether LWP %ld needs to move out of the "
+ "jump pad.\n",
+ lwpid_of (lwp));
r = linux_fast_tracepoint_collecting (lwp, &status);
}
if (debug_threads)
- fprintf (stderr, "\
-Checking whether LWP %ld needs to move out of the jump pad...it does\n",
- lwpid_of (lwp));
+ debug_printf ("Checking whether LWP %ld needs to move out of "
+ "the jump pad...it does\n",
+ lwpid_of (lwp));
current_inferior = saved_inferior;
return 1;
if (lwp->exit_jump_pad_bkpt != NULL)
{
if (debug_threads)
- fprintf (stderr,
- "Cancelling fast exit-jump-pad: removing bkpt. "
- "stopping all threads momentarily.\n");
+ debug_printf ("Cancelling fast exit-jump-pad: removing bkpt. "
+ "stopping all threads momentarily.\n");
stop_all_lwps (1, lwp);
cancel_breakpoints ();
}
if (debug_threads)
- fprintf (stderr, "\
-Checking whether LWP %ld needs to move out of the jump pad...no\n",
- lwpid_of (lwp));
+ debug_printf ("Checking whether LWP %ld needs to move out of the "
+ "jump pad...no\n",
+ lwpid_of (lwp));
current_inferior = saved_inferior;
return 0;
struct pending_signals *p_sig;
if (debug_threads)
- fprintf (stderr, "\
-Deferring signal %d for LWP %ld.\n", WSTOPSIG (*wstat), lwpid_of (lwp));
+ debug_printf ("Deferring signal %d for LWP %ld.\n",
+ WSTOPSIG (*wstat), lwpid_of (lwp));
if (debug_threads)
{
for (sig = lwp->pending_signals_to_report;
sig != NULL;
sig = sig->prev)
- fprintf (stderr,
- " Already queued %d\n",
- sig->signal);
+ debug_printf (" Already queued %d\n",
+ sig->signal);
- fprintf (stderr, " (no more currently queued signals)\n");
+ debug_printf (" (no more currently queued signals)\n");
}
/* Don't enqueue non-RT signals if they are already in the deferred
if (sig->signal == WSTOPSIG (*wstat))
{
if (debug_threads)
- fprintf (stderr,
- "Not requeuing already queued non-RT signal %d"
- " for LWP %ld\n",
- sig->signal,
- lwpid_of (lwp));
+ debug_printf ("Not requeuing already queued non-RT signal %d"
+ " for LWP %ld\n",
+ sig->signal,
+ lwpid_of (lwp));
return;
}
}
*p_sig = NULL;
if (debug_threads)
- fprintf (stderr, "Reporting deferred signal %d for LWP %ld.\n",
- WSTOPSIG (*wstat), lwpid_of (lwp));
+ debug_printf ("Reporting deferred signal %d for LWP %ld.\n",
+ WSTOPSIG (*wstat), lwpid_of (lwp));
if (debug_threads)
{
for (sig = lwp->pending_signals_to_report;
sig != NULL;
sig = sig->prev)
- fprintf (stderr,
- " Still queued %d\n",
- sig->signal);
+ debug_printf (" Still queued %d\n",
+ sig->signal);
- fprintf (stderr, " (no more queued signals)\n");
+ debug_printf (" (no more queued signals)\n");
}
return 1;
if ((*the_low_target.breakpoint_at) (lwp->stop_pc))
{
if (debug_threads)
- fprintf (stderr,
- "CB: Push back breakpoint for %s\n",
- target_pid_to_str (ptid_of (lwp)));
+ debug_printf ("CB: Push back breakpoint for %s\n",
+ target_pid_to_str (ptid_of (lwp)));
/* Back up the PC if necessary. */
if (the_low_target.decr_pc_after_break)
else
{
if (debug_threads)
- fprintf (stderr,
- "CB: No breakpoint found at %s for [%s]\n",
- paddress (lwp->stop_pc),
- target_pid_to_str (ptid_of (lwp)));
+ debug_printf ("CB: No breakpoint found at %s for [%s]\n",
+ paddress (lwp->stop_pc),
+ target_pid_to_str (ptid_of (lwp)));
}
current_inferior = saved_inferior;
event_child = (struct lwp_info *)
find_inferior (&all_lwps, status_pending_p_callback, &ptid);
if (debug_threads && event_child)
- fprintf (stderr, "Got a pending child %ld\n", lwpid_of (event_child));
+ debug_printf ("Got a pending child %ld\n", lwpid_of (event_child));
}
else
{
if (event_child != NULL)
{
if (debug_threads)
- fprintf (stderr, "Got an event from pending child %ld (%04x)\n",
- lwpid_of (event_child), event_child->status_pending);
+ debug_printf ("Got an event from pending child %ld (%04x)\n",
+ lwpid_of (event_child), event_child->status_pending);
*wstat = event_child->status_pending;
event_child->status_pending_p = 0;
event_child->status_pending = 0;
if ((options & WNOHANG) && event_child == NULL)
{
if (debug_threads)
- fprintf (stderr, "WNOHANG set, no event found\n");
+ debug_printf ("WNOHANG set, no event found\n");
return 0;
}
if (! WIFSTOPPED (*wstat))
{
if (debug_threads)
- fprintf (stderr, "LWP %ld exiting\n", lwpid_of (event_child));
+ debug_printf ("LWP %ld exiting\n", lwpid_of (event_child));
/* If the last thread is exiting, just return. */
if (last_thread_of_process_p (current_inferior))
{
if (debug_threads)
- fprintf (stderr, "LWP %ld is last lwp of process\n",
- lwpid_of (event_child));
+ debug_printf ("LWP %ld is last lwp of process\n",
+ lwpid_of (event_child));
return lwpid_of (event_child);
}
{
current_inferior = (struct thread_info *) all_threads.head;
if (debug_threads)
- fprintf (stderr, "Current inferior is now %ld\n",
- lwpid_of (get_thread_lwp (current_inferior)));
+ debug_printf ("Current inferior is now %ld\n",
+ lwpid_of (get_thread_lwp (current_inferior)));
}
else
{
current_inferior = NULL;
if (debug_threads)
- fprintf (stderr, "Current inferior is now <NULL>\n");
+ debug_printf ("Current inferior is now <NULL>\n");
}
/* If we were waiting for this particular child to do something...
int should_stop;
if (debug_threads)
- fprintf (stderr, "Expected stop.\n");
+ debug_printf ("Expected stop.\n");
event_child->stop_expected = 0;
should_stop = (current_inferior->last_resume_kind == resume_stop
if (event_lp != NULL)
{
if (debug_threads)
- fprintf (stderr,
- "SEL: Select single-step %s\n",
- target_pid_to_str (ptid_of (event_lp)));
+ debug_printf ("SEL: Select single-step %s\n",
+ target_pid_to_str (ptid_of (event_lp)));
}
else
{
((num_events * (double) rand ()) / (RAND_MAX + 1.0));
if (debug_threads && num_events > 1)
- fprintf (stderr,
- "SEL: Found %d SIGTRAP events, selecting #%d\n",
- num_events, random_selector);
+ debug_printf ("SEL: Found %d SIGTRAP events, selecting #%d\n",
+ num_events, random_selector);
event_lp = (struct lwp_info *) find_inferior (&all_lwps,
select_event_lwp_callback,
if (lwp_stuck != NULL)
{
if (debug_threads)
- fprintf (stderr, "can't stabilize, LWP %ld is stuck in jump pad\n",
- lwpid_of (lwp_stuck));
+ debug_printf ("can't stabilize, LWP %ld is stuck in jump pad\n",
+ lwpid_of (lwp_stuck));
return;
}
= (struct lwp_info *) find_inferior (&all_lwps,
stuck_in_jump_pad_callback, NULL);
if (lwp_stuck != NULL)
- fprintf (stderr, "couldn't stabilize, LWP %ld got stuck in jump pad\n",
- lwpid_of (lwp_stuck));
+ debug_printf ("couldn't stabilize, LWP %ld got stuck in jump pad\n",
+ lwpid_of (lwp_stuck));
}
}
int trace_event;
int in_step_range;
+ if (debug_threads)
+ {
+ debug_enter ();
+ debug_printf ("linux_wait_1: [%s]\n", target_pid_to_str (ptid));
+ }
+
/* Translate generic target options into linux options. */
options = __WALL;
if (target_options & TARGET_WNOHANG)
else
{
if (debug_threads)
- fprintf (stderr, "step_over_bkpt set [%s], doing a blocking wait\n",
- target_pid_to_str (step_over_bkpt));
+ debug_printf ("step_over_bkpt set [%s], doing a blocking wait\n",
+ target_pid_to_str (step_over_bkpt));
pid = linux_wait_for_event (step_over_bkpt, &w, options & ~WNOHANG);
}
if (pid == 0) /* only if TARGET_WNOHANG */
- return null_ptid;
+ {
+ if (debug_threads)
+ {
+ debug_printf ("linux_wait_1 ret = null_ptid\n");
+ debug_exit ();
+ }
+ return null_ptid;
+ }
event_child = get_thread_lwp (current_inferior);
ourstatus->value.integer = WEXITSTATUS (w);
if (debug_threads)
- fprintf (stderr,
- "\nChild exited with retcode = %x \n",
- WEXITSTATUS (w));
+ {
+ debug_printf ("linux_wait_1 ret = %s, exited with "
+ "retcode %d\n",
+ target_pid_to_str (ptid_of (event_child)),
+ WEXITSTATUS (w));
+ debug_exit ();
+ }
}
else
{
ourstatus->value.sig = gdb_signal_from_host (WTERMSIG (w));
if (debug_threads)
- fprintf (stderr,
- "\nChild terminated with signal = %x \n",
- WTERMSIG (w));
-
+ {
+ debug_printf ("linux_wait_1 ret = %s, terminated with "
+ "signal %d\n",
+ target_pid_to_str (ptid_of (event_child)),
+ WTERMSIG (w));
+ debug_exit ();
+ }
}
return ptid_of (event_child);
already handled it. So next time we resume (from this
PC), we should step over it. */
if (debug_threads)
- fprintf (stderr, "Hit a gdbserver breakpoint.\n");
+ debug_printf ("Hit a gdbserver breakpoint.\n");
if (breakpoint_here (event_child->stop_pc))
event_child->need_step_over = 1;
&& agent_loaded_p ())
{
if (debug_threads)
- fprintf (stderr,
- "Got signal %d for LWP %ld. Check if we need "
- "to defer or adjust it.\n",
- WSTOPSIG (w), lwpid_of (event_child));
+ debug_printf ("Got signal %d for LWP %ld. Check if we need "
+ "to defer or adjust it.\n",
+ WSTOPSIG (w), lwpid_of (event_child));
/* Allow debugging the jump pad itself. */
if (current_inferior->last_resume_kind != resume_step
enqueue_one_deferred_signal (event_child, &w);
if (debug_threads)
- fprintf (stderr,
- "Signal %d for LWP %ld deferred (in jump pad)\n",
- WSTOPSIG (w), lwpid_of (event_child));
+ debug_printf ("Signal %d for LWP %ld deferred (in jump pad)\n",
+ WSTOPSIG (w), lwpid_of (event_child));
linux_resume_one_lwp (event_child, 0, 0, NULL);
goto retry;
if (event_child->collecting_fast_tracepoint)
{
if (debug_threads)
- fprintf (stderr, "\
-LWP %ld was trying to move out of the jump pad (%d). \
-Check if we're already there.\n",
- lwpid_of (event_child),
- event_child->collecting_fast_tracepoint);
+ debug_printf ("LWP %ld was trying to move out of the jump pad (%d). "
+ "Check if we're already there.\n",
+ lwpid_of (event_child),
+ event_child->collecting_fast_tracepoint);
trace_event = 1;
if (event_child->exit_jump_pad_bkpt != NULL)
{
if (debug_threads)
- fprintf (stderr,
- "No longer need exit-jump-pad bkpt; removing it."
- "stopping all threads momentarily.\n");
+ debug_printf ("No longer need exit-jump-pad bkpt; removing it."
+ "stopping all threads momentarily.\n");
/* Other running threads could hit this breakpoint.
We don't handle moribund locations like GDB does,
if (event_child->collecting_fast_tracepoint == 0)
{
if (debug_threads)
- fprintf (stderr,
- "fast tracepoint finished "
- "collecting successfully.\n");
+ debug_printf ("fast tracepoint finished "
+ "collecting successfully.\n");
/* We may have a deferred signal to report. */
if (dequeue_one_deferred_signal (event_child, &w))
{
if (debug_threads)
- fprintf (stderr, "dequeued one signal.\n");
+ debug_printf ("dequeued one signal.\n");
}
else
{
if (debug_threads)
- fprintf (stderr, "no deferred signals.\n");
+ debug_printf ("no deferred signals.\n");
if (stabilizing_threads)
{
ourstatus->kind = TARGET_WAITKIND_STOPPED;
ourstatus->value.sig = GDB_SIGNAL_0;
+
+ if (debug_threads)
+ {
+ debug_printf ("linux_wait_1 ret = %s, stopped "
+ "while stabilizing threads\n",
+ target_pid_to_str (ptid_of (event_child)));
+ debug_exit ();
+ }
+
return ptid_of (event_child);
}
}
siginfo_t info, *info_p;
if (debug_threads)
- fprintf (stderr, "Ignored signal %d for LWP %ld.\n",
- WSTOPSIG (w), lwpid_of (event_child));
+ debug_printf ("Ignored signal %d for LWP %ld.\n",
+ WSTOPSIG (w), lwpid_of (event_child));
if (ptrace (PTRACE_GETSIGINFO, lwpid_of (event_child),
(PTRACE_TYPE_ARG3) 0, &info) == 0)
if (debug_threads)
{
if (bp_explains_trap)
- fprintf (stderr, "Hit a gdbserver breakpoint.\n");
+ debug_printf ("Hit a gdbserver breakpoint.\n");
if (step_over_finished)
- fprintf (stderr, "Step-over finished.\n");
+ debug_printf ("Step-over finished.\n");
if (trace_event)
- fprintf (stderr, "Tracepoint event.\n");
+ debug_printf ("Tracepoint event.\n");
if (lwp_in_step_range (event_child))
- fprintf (stderr, "Range stepping pc 0x%s [0x%s, 0x%s).\n",
- paddress (event_child->stop_pc),
- paddress (event_child->step_range_start),
- paddress (event_child->step_range_end));
+ debug_printf ("Range stepping pc 0x%s [0x%s, 0x%s).\n",
+ paddress (event_child->stop_pc),
+ paddress (event_child->step_range_start),
+ paddress (event_child->step_range_end));
}
/* We're not reporting this breakpoint to GDB, so apply the
going to keep waiting, so use proceed, which handles stepping
over the next breakpoint. */
if (debug_threads)
- fprintf (stderr, "proceeding all threads.\n");
+ debug_printf ("proceeding all threads.\n");
if (step_over_finished)
unsuspend_all_lwps (event_child);
if (current_inferior->last_resume_kind == resume_step)
{
if (event_child->step_range_start == event_child->step_range_end)
- fprintf (stderr, "GDB wanted to single-step, reporting event.\n");
+ debug_printf ("GDB wanted to single-step, reporting event.\n");
else if (!lwp_in_step_range (event_child))
- fprintf (stderr, "Out of step range, reporting event.\n");
+ debug_printf ("Out of step range, reporting event.\n");
}
if (event_child->stopped_by_watchpoint)
- fprintf (stderr, "Stopped by watchpoint.\n");
+ debug_printf ("Stopped by watchpoint.\n");
if (gdb_breakpoint_here (event_child->stop_pc))
- fprintf (stderr, "Stopped by GDB breakpoint.\n");
+ debug_printf ("Stopped by GDB breakpoint.\n");
if (debug_threads)
- fprintf (stderr, "Hit a non-gdbserver trap event.\n");
+ debug_printf ("Hit a non-gdbserver trap event.\n");
}
/* Alright, we're going to report a stop. */
gdb_assert (ptid_equal (step_over_bkpt, null_ptid));
if (debug_threads)
- fprintf (stderr, "linux_wait ret = %s, %d, %d\n",
- target_pid_to_str (ptid_of (event_child)),
- ourstatus->kind,
- ourstatus->value.sig);
+ {
+ debug_printf ("linux_wait_1 ret = %s, %d, %d\n",
+ target_pid_to_str (ptid_of (event_child)),
+ ourstatus->kind, ourstatus->value.sig);
+ debug_exit ();
+ }
return ptid_of (event_child);
}
{
ptid_t event_ptid;
- if (debug_threads)
- fprintf (stderr, "linux_wait: [%s]\n", target_pid_to_str (ptid));
-
/* Flush the async file first. */
if (target_is_async_p ())
async_file_flush ();
if (lwp->stop_expected)
{
if (debug_threads)
- fprintf (stderr, "Have pending sigstop for lwp %d\n", pid);
+ debug_printf ("Have pending sigstop for lwp %d\n", pid);
return;
}
if (debug_threads)
- fprintf (stderr, "Sending sigstop to lwp %d\n", pid);
+ debug_printf ("Sending sigstop to lwp %d\n", pid);
lwp->stop_expected = 1;
kill_lwp (pid, SIGSTOP);
if (lwp->stopped)
{
if (debug_threads)
- fprintf (stderr, "wait_for_sigstop: LWP %ld already stopped\n",
- lwpid_of (lwp));
+ debug_printf ("wait_for_sigstop: LWP %ld already stopped\n",
+ lwpid_of (lwp));
return;
}
ptid = lwp->head.id;
if (debug_threads)
- fprintf (stderr, "wait_for_sigstop: pulling one event\n");
+ debug_printf ("wait_for_sigstop: pulling one event\n");
pid = linux_wait_for_event (ptid, &wstat, __WALL);
if (WIFSTOPPED (wstat))
{
if (debug_threads)
- fprintf (stderr, "LWP %ld stopped with signal %d\n",
- lwpid_of (lwp), WSTOPSIG (wstat));
+ debug_printf ("LWP %ld stopped with signal %d\n",
+ lwpid_of (lwp), WSTOPSIG (wstat));
if (WSTOPSIG (wstat) != SIGSTOP)
{
if (debug_threads)
- fprintf (stderr, "LWP %ld stopped with non-sigstop status %06x\n",
- lwpid_of (lwp), wstat);
+ debug_printf ("LWP %ld stopped with non-sigstop status %06x\n",
+ lwpid_of (lwp), wstat);
lwp->status_pending_p = 1;
lwp->status_pending = wstat;
else
{
if (debug_threads)
- fprintf (stderr, "Process %d exited while stopping LWPs\n", pid);
+ debug_printf ("Process %d exited while stopping LWPs\n", pid);
lwp = find_lwp_pid (pid_to_ptid (pid));
if (lwp)
else
{
if (debug_threads)
- fprintf (stderr, "Previously current thread died.\n");
+ debug_printf ("Previously current thread died.\n");
if (non_stop)
{
&& maybe_move_out_of_jump_pad (lwp, wstat))
{
if (debug_threads)
- fprintf (stderr,
- "LWP %ld needs stabilizing (in jump pad)\n",
- lwpid_of (lwp));
+ debug_printf ("LWP %ld needs stabilizing (in jump pad)\n",
+ lwpid_of (lwp));
if (wstat)
{
enqueue_one_deferred_signal (lwp, wstat);
if (debug_threads)
- fprintf (stderr,
- "Signal %d for LWP %ld deferred "
- "(in jump pad)\n",
- WSTOPSIG (*wstat), lwpid_of (lwp));
+ debug_printf ("Signal %d for LWP %ld deferred "
+ "(in jump pad)\n",
+ WSTOPSIG (*wstat), lwpid_of (lwp));
}
linux_resume_one_lwp (lwp, 0, 0, NULL);
/* Should not be called recursively. */
gdb_assert (stopping_threads == NOT_STOPPING_THREADS);
+ if (debug_threads)
+ {
+ debug_enter ();
+ debug_printf ("stop_all_lwps (%s, except=%s)\n",
+ suspend ? "stop-and-suspend" : "stop",
+ except != NULL
+ ? target_pid_to_str (ptid_of (except))
+ : "none");
+ }
+
stopping_threads = (suspend
? STOPPING_AND_SUSPENDING_THREADS
: STOPPING_THREADS);
find_inferior (&all_lwps, send_sigstop_callback, except);
for_each_inferior (&all_lwps, wait_for_sigstop);
stopping_threads = NOT_STOPPING_THREADS;
+
+ if (debug_threads)
+ {
+ debug_printf ("stop_all_lwps done, setting stopping_threads "
+ "back to !stopping\n");
+ debug_exit ();
+ }
}
/* Resume execution of the inferior process.
if (lwp->status_pending_p)
{
if (debug_threads)
- fprintf (stderr, "Not resuming lwp %ld (%s, signal %d, stop %s);"
- " has pending status\n",
- lwpid_of (lwp), step ? "step" : "continue", signal,
- lwp->stop_expected ? "expected" : "not expected");
+ debug_printf ("Not resuming lwp %ld (%s, signal %d, stop %s);"
+ " has pending status\n",
+ lwpid_of (lwp), step ? "step" : "continue", signal,
+ lwp->stop_expected ? "expected" : "not expected");
return;
}
current_inferior = get_lwp_thread (lwp);
if (debug_threads)
- fprintf (stderr, "Resuming lwp %ld (%s, signal %d, stop %s)\n",
- lwpid_of (lwp), step ? "step" : "continue", signal,
- lwp->stop_expected ? "expected" : "not expected");
+ debug_printf ("Resuming lwp %ld (%s, signal %d, stop %s)\n",
+ lwpid_of (lwp), step ? "step" : "continue", signal,
+ lwp->stop_expected ? "expected" : "not expected");
/* This bit needs some thinking about. If we get a signal that
we must report while a single-step reinsert is still pending,
if (lwp->bp_reinsert != 0)
{
if (debug_threads)
- fprintf (stderr, " pending reinsert at 0x%s\n",
- paddress (lwp->bp_reinsert));
+ debug_printf (" pending reinsert at 0x%s\n",
+ paddress (lwp->bp_reinsert));
if (can_hardware_single_step ())
{
if (fast_tp_collecting == 1)
{
if (debug_threads)
- fprintf (stderr, "\
-lwp %ld wants to get out of fast tracepoint jump pad (exit-jump-pad-bkpt)\n",
- lwpid_of (lwp));
+ debug_printf ("lwp %ld wants to get out of fast tracepoint jump pad"
+ " (exit-jump-pad-bkpt)\n",
+ lwpid_of (lwp));
/* Postpone any pending signal. It was enqueued above. */
signal = 0;
else if (fast_tp_collecting == 2)
{
if (debug_threads)
- fprintf (stderr, "\
-lwp %ld wants to get out of fast tracepoint jump pad single-stepping\n",
- lwpid_of (lwp));
+ debug_printf ("lwp %ld wants to get out of fast tracepoint jump pad"
+ " single-stepping\n",
+ lwpid_of (lwp));
if (can_hardware_single_step ())
step = 1;
&& can_hardware_single_step ())
{
if (debug_threads)
- fprintf (stderr,
- "lwp %ld has a while-stepping action -> forcing step.\n",
- lwpid_of (lwp));
+ debug_printf ("lwp %ld has a while-stepping action -> forcing step.\n",
+ lwpid_of (lwp));
step = 1;
}
{
struct regcache *regcache = get_thread_regcache (current_inferior, 1);
CORE_ADDR pc = (*the_low_target.get_pc) (regcache);
- fprintf (stderr, " resuming from pc 0x%lx\n", (long) pc);
+ debug_printf (" resuming from pc 0x%lx\n", (long) pc);
}
/* If we have pending signals, consume one unless we are trying to
&& thread->last_resume_kind == resume_stop)
{
if (debug_threads)
- fprintf (stderr, "already %s LWP %ld at GDB's request\n",
- thread->last_status.kind == TARGET_WAITKIND_STOPPED
- ? "stopped"
- : "stopping",
- lwpid_of (lwp));
+ debug_printf ("already %s LWP %ld at GDB's request\n",
+ (thread->last_status.kind
+ == TARGET_WAITKIND_STOPPED)
+ ? "stopped"
+ : "stopping",
+ lwpid_of (lwp));
continue;
}
lwp->status_pending_p = 1;
if (debug_threads)
- fprintf (stderr,
- "Dequeueing deferred signal %d for LWP %ld, "
- "leaving status pending.\n",
- WSTOPSIG (lwp->status_pending), lwpid_of (lwp));
+ debug_printf ("Dequeueing deferred signal %d for LWP %ld, "
+ "leaving status pending.\n",
+ WSTOPSIG (lwp->status_pending), lwpid_of (lwp));
}
return 0;
if (!lwp->stopped)
{
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? Ignoring, not stopped\n",
- lwpid_of (lwp));
+ debug_printf ("Need step over [LWP %ld]? Ignoring, not stopped\n",
+ lwpid_of (lwp));
return 0;
}
if (thread->last_resume_kind == resume_stop)
{
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? Ignoring, should remain stopped\n",
- lwpid_of (lwp));
+ debug_printf ("Need step over [LWP %ld]? Ignoring, should remain"
+ " stopped\n",
+ lwpid_of (lwp));
return 0;
}
if (lwp->suspended)
{
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? Ignoring, suspended\n",
- lwpid_of (lwp));
+ debug_printf ("Need step over [LWP %ld]? Ignoring, suspended\n",
+ lwpid_of (lwp));
return 0;
}
if (!lwp->need_step_over)
{
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? No\n", lwpid_of (lwp));
+ debug_printf ("Need step over [LWP %ld]? No\n", lwpid_of (lwp));
}
if (lwp->status_pending_p)
{
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? Ignoring, has pending status.\n",
- lwpid_of (lwp));
+ debug_printf ("Need step over [LWP %ld]? Ignoring, has pending"
+ " status.\n",
+ lwpid_of (lwp));
return 0;
}
if (pc != lwp->stop_pc)
{
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? Cancelling, PC was changed. "
- "Old stop_pc was 0x%s, PC is now 0x%s\n",
- lwpid_of (lwp), paddress (lwp->stop_pc), paddress (pc));
+ debug_printf ("Need step over [LWP %ld]? Cancelling, PC was changed. "
+ "Old stop_pc was 0x%s, PC is now 0x%s\n",
+ lwpid_of (lwp), paddress (lwp->stop_pc), paddress (pc));
lwp->need_step_over = 0;
return 0;
&& gdb_no_commands_at_breakpoint (pc))
{
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? yes, but found"
- " GDB breakpoint at 0x%s; skipping step over\n",
- lwpid_of (lwp), paddress (pc));
+ debug_printf ("Need step over [LWP %ld]? yes, but found"
+ " GDB breakpoint at 0x%s; skipping step over\n",
+ lwpid_of (lwp), paddress (pc));
current_inferior = saved_inferior;
return 0;
else
{
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? yes, "
- "found breakpoint at 0x%s\n",
- lwpid_of (lwp), paddress (pc));
+ debug_printf ("Need step over [LWP %ld]? yes, "
+ "found breakpoint at 0x%s\n",
+ lwpid_of (lwp), paddress (pc));
/* We've found an lwp that needs stepping over --- return 1 so
that find_inferior stops looking. */
current_inferior = saved_inferior;
if (debug_threads)
- fprintf (stderr,
- "Need step over [LWP %ld]? No, no breakpoint found at 0x%s\n",
- lwpid_of (lwp), paddress (pc));
+ debug_printf ("Need step over [LWP %ld]? No, no breakpoint found"
+ " at 0x%s\n",
+ lwpid_of (lwp), paddress (pc));
return 0;
}
int step;
if (debug_threads)
- fprintf (stderr,
- "Starting step-over on LWP %ld. Stopping all threads\n",
- lwpid_of (lwp));
+ debug_printf ("Starting step-over on LWP %ld. Stopping all threads\n",
+ lwpid_of (lwp));
stop_all_lwps (1, lwp);
gdb_assert (lwp->suspended == 0);
if (debug_threads)
- fprintf (stderr, "Done stopping all threads for step-over.\n");
+ debug_printf ("Done stopping all threads for step-over.\n");
/* Note, we should always reach here with an already adjusted PC,
either by GDB (if we're resuming due to GDB's request), or by our
if (lwp->bp_reinsert != 0)
{
if (debug_threads)
- fprintf (stderr, "Finished step over.\n");
+ debug_printf ("Finished step over.\n");
/* Reinsert any breakpoint at LWP->BP_REINSERT. Note that there
may be no breakpoint to reinsert there by now. */
if (lwp->resume->kind == resume_stop)
{
if (debug_threads)
- fprintf (stderr, "resume_stop request for LWP %ld\n", lwpid_of (lwp));
+ debug_printf ("resume_stop request for LWP %ld\n", lwpid_of (lwp));
if (!lwp->stopped)
{
if (debug_threads)
- fprintf (stderr, "stopping LWP %ld\n", lwpid_of (lwp));
+ debug_printf ("stopping LWP %ld\n", lwpid_of (lwp));
/* Stop the thread, and wait for the event asynchronously,
through the event loop. */
else
{
if (debug_threads)
- fprintf (stderr, "already stopped LWP %ld\n",
- lwpid_of (lwp));
+ debug_printf ("already stopped LWP %ld\n",
+ lwpid_of (lwp));
/* The LWP may have been stopped in an internal event that
was not meant to be notified back to GDB (e.g., gdbserver
if (!leave_pending)
{
if (debug_threads)
- fprintf (stderr, "resuming LWP %ld\n", lwpid_of (lwp));
+ debug_printf ("resuming LWP %ld\n", lwpid_of (lwp));
step = (lwp->resume->kind == resume_step);
linux_resume_one_lwp (lwp, step, lwp->resume->sig, NULL);
else
{
if (debug_threads)
- fprintf (stderr, "leaving LWP %ld stopped\n", lwpid_of (lwp));
+ debug_printf ("leaving LWP %ld stopped\n", lwpid_of (lwp));
/* If we have a new signal, enqueue the signal. */
if (lwp->resume->sig != 0)
int any_pending;
int leave_all_stopped;
+ if (debug_threads)
+ {
+ debug_enter ();
+ debug_printf ("linux_resume:\n");
+ }
+
find_inferior (&all_threads, linux_set_resume_request, &array);
/* If there is a thread which would otherwise be resumed, which has
if (debug_threads)
{
if (need_step_over != NULL)
- fprintf (stderr, "Not resuming all, need step over\n");
+ debug_printf ("Not resuming all, need step over\n");
else if (any_pending)
- fprintf (stderr,
- "Not resuming, all-stop and found "
- "an LWP with pending status\n");
+ debug_printf ("Not resuming, all-stop and found "
+ "an LWP with pending status\n");
else
- fprintf (stderr, "Resuming, no pending status or step over needed\n");
+ debug_printf ("Resuming, no pending status or step over needed\n");
}
/* Even if we're leaving threads stopped, queue all signals we'd
if (need_step_over)
start_step_over (need_step_over);
+
+ if (debug_threads)
+ {
+ debug_printf ("linux_resume done\n");
+ debug_exit ();
+ }
}
/* This function is called once per thread. We check the thread's
return 0;
if (debug_threads)
- fprintf (stderr,
- "proceed_one_lwp: lwp %ld\n", lwpid_of (lwp));
+ debug_printf ("proceed_one_lwp: lwp %ld\n", lwpid_of (lwp));
if (!lwp->stopped)
{
if (debug_threads)
- fprintf (stderr, " LWP %ld already running\n", lwpid_of (lwp));
+ debug_printf (" LWP %ld already running\n", lwpid_of (lwp));
return 0;
}
&& thread->last_status.kind != TARGET_WAITKIND_IGNORE)
{
if (debug_threads)
- fprintf (stderr, " client wants LWP to remain %ld stopped\n",
- lwpid_of (lwp));
+ debug_printf (" client wants LWP to remain %ld stopped\n",
+ lwpid_of (lwp));
return 0;
}
if (lwp->status_pending_p)
{
if (debug_threads)
- fprintf (stderr, " LWP %ld has pending status, leaving stopped\n",
- lwpid_of (lwp));
+ debug_printf (" LWP %ld has pending status, leaving stopped\n",
+ lwpid_of (lwp));
return 0;
}
if (lwp->suspended)
{
if (debug_threads)
- fprintf (stderr, " LWP %ld is suspended\n", lwpid_of (lwp));
+ debug_printf (" LWP %ld is suspended\n", lwpid_of (lwp));
return 0;
}
pending, this is a no-op. */
if (debug_threads)
- fprintf (stderr,
- "Client wants LWP %ld to stop. "
- "Making sure it has a SIGSTOP pending\n",
- lwpid_of (lwp));
+ debug_printf ("Client wants LWP %ld to stop. "
+ "Making sure it has a SIGSTOP pending\n",
+ lwpid_of (lwp));
send_sigstop (lwp);
}
if (need_step_over != NULL)
{
if (debug_threads)
- fprintf (stderr, "proceed_all_lwps: found "
- "thread %ld needing a step-over\n",
- lwpid_of (need_step_over));
+ debug_printf ("proceed_all_lwps: found "
+ "thread %ld needing a step-over\n",
+ lwpid_of (need_step_over));
start_step_over (need_step_over);
return;
}
if (debug_threads)
- fprintf (stderr, "Proceeding, no step-over needed\n");
+ debug_printf ("Proceeding, no step-over needed\n");
find_inferior (&all_lwps, proceed_one_lwp, NULL);
}
{
if (debug_threads)
{
+ debug_enter ();
if (except)
- fprintf (stderr,
- "unstopping all lwps, except=(LWP %ld)\n", lwpid_of (except));
+ debug_printf ("unstopping all lwps, except=(LWP %ld)\n",
+ lwpid_of (except));
else
- fprintf (stderr,
- "unstopping all lwps\n");
+ debug_printf ("unstopping all lwps\n");
}
if (unsuspend)
find_inferior (&all_lwps, unsuspend_and_proceed_one_lwp, except);
else
find_inferior (&all_lwps, proceed_one_lwp, except);
+
+ if (debug_threads)
+ {
+ debug_printf ("unstop_all_lwps done\n");
+ debug_exit ();
+ }
}
val = val & 0xffff;
else if (len == 3)
val = val & 0xffffff;
- fprintf (stderr, "Writing %0*x to 0x%08lx\n", 2 * ((len < 4) ? len : 4),
- val, (long)memaddr);
+ debug_printf ("Writing %0*x to 0x%08lx\n", 2 * ((len < 4) ? len : 4),
+ val, (long)memaddr);
}
/* Fill start and end extra bytes of buffer with existing memory data. */
pid = lwpid_of (get_thread_lwp (current_inferior));
if (debug_threads)
- fprintf (stderr, "%s siginfo for lwp %d.\n",
- readbuf != NULL ? "Reading" : "Writing",
- pid);
+ debug_printf ("%s siginfo for lwp %d.\n",
+ readbuf != NULL ? "Reading" : "Writing",
+ pid);
if (offset >= sizeof (siginfo))
return -1;
int previous = (linux_event_pipe[0] != -1);
if (debug_threads)
- fprintf (stderr, "linux_async (%d), previous=%d\n",
- enable, previous);
+ debug_printf ("linux_async (%d), previous=%d\n",
+ enable, previous);
if (previous != enable)
{