45741a9c32
Move infrun.c declarations out of inferior.h to a new infrun.h file. Tested by building on: i686-w64-mingw32, enable-targets=all x86_64-linux, enable-targets=all i586-pc-msdosdjgpp And also grepped the whole tree for each symbol moved to find where infrun.h might be necessary. gdb/ 2014-05-22 Pedro Alves <palves@redhat.com> * inferior.h (debug_infrun, debug_displaced, stop_on_solib_events) (sync_execution, sched_multi, step_stop_if_no_debug, non_stop) (disable_randomization, enum exec_direction_kind) (execution_direction, stop_registers, start_remote) (clear_proceed_status, proceed, resume, user_visible_resume_ptid) (wait_for_inferior, normal_stop, get_last_target_status) (prepare_for_detach, fetch_inferior_event, init_wait_for_inferior) (insert_step_resume_breakpoint_at_sal) (follow_inferior_reset_breakpoints, stepping_past_instruction_at) (set_step_info, print_stop_event, signal_stop_state) (signal_print_state, signal_pass_state, signal_stop_update) (signal_print_update, signal_pass_update) (update_signals_program_target, clear_exit_convenience_vars) (displaced_step_dump_bytes, update_observer_mode) (signal_catch_update, gdb_signal_from_command): Move declarations ... * infrun.h: ... to this new file. * amd64-tdep.c: Include infrun.h. * annotate.c: Include infrun.h. * arch-utils.c: Include infrun.h. * arm-linux-tdep.c: Include infrun.h. * arm-tdep.c: Include infrun.h. * break-catch-sig.c: Include infrun.h. * breakpoint.c: Include infrun.h. * common/agent.c: Include infrun.h instead of inferior.h. * corelow.c: Include infrun.h. * event-top.c: Include infrun.h. * go32-nat.c: Include infrun.h. * i386-tdep.c: Include infrun.h. * inf-loop.c: Include infrun.h. * infcall.c: Include infrun.h. * infcmd.c: Include infrun.h. * infrun.c: Include infrun.h. * linux-fork.c: Include infrun.h. * linux-nat.c: Include infrun.h. * linux-thread-db.c: Include infrun.h. * monitor.c: Include infrun.h. * nto-tdep.c: Include infrun.h. * procfs.c: Include infrun.h. * record-btrace.c: Include infrun.h. * record-full.c: Include infrun.h. * remote-m32r-sdi.c: Include infrun.h. * remote-mips.c: Include infrun.h. * remote-notif.c: Include infrun.h. * remote-sim.c: Include infrun.h. * remote.c: Include infrun.h. * reverse.c: Include infrun.h. * rs6000-tdep.c: Include infrun.h. * s390-linux-tdep.c: Include infrun.h. * solib-irix.c: Include infrun.h. * solib-osf.c: Include infrun.h. * solib-svr4.c: Include infrun.h. * target.c: Include infrun.h. * top.c: Include infrun.h. * windows-nat.c: Include infrun.h. * mi/mi-interp.c: Include infrun.h. * mi/mi-main.c: Include infrun.h. * python/py-threadevent.c: Include infrun.h.
148 lines
4.7 KiB
C
148 lines
4.7 KiB
C
/* Handling of inferior events for the event loop for GDB, the GNU debugger.
|
|
Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
|
Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "defs.h"
|
|
#include "inferior.h"
|
|
#include "infrun.h"
|
|
#include "target.h" /* For enum inferior_event_type. */
|
|
#include "event-loop.h"
|
|
#include "event-top.h"
|
|
#include "inf-loop.h"
|
|
#include "remote.h"
|
|
#include "exceptions.h"
|
|
#include "language.h"
|
|
#include "gdbthread.h"
|
|
#include "continuations.h"
|
|
#include "interps.h"
|
|
#include "top.h"
|
|
|
|
static int fetch_inferior_event_wrapper (gdb_client_data client_data);
|
|
|
|
/* General function to handle events in the inferior. So far it just
|
|
takes care of detecting errors reported by select() or poll(),
|
|
otherwise it assumes that all is OK, and goes on reading data from
|
|
the fd. This however may not always be what we want to do. */
|
|
void
|
|
inferior_event_handler (enum inferior_event_type event_type,
|
|
gdb_client_data client_data)
|
|
{
|
|
struct cleanup *cleanup_if_error = make_bpstat_clear_actions_cleanup ();
|
|
|
|
switch (event_type)
|
|
{
|
|
case INF_REG_EVENT:
|
|
/* Use catch errors for now, until the inner layers of
|
|
fetch_inferior_event (i.e. readchar) can return meaningful
|
|
error status. If an error occurs while getting an event from
|
|
the target, just cancel the current command. */
|
|
if (!catch_errors (fetch_inferior_event_wrapper,
|
|
client_data, "", RETURN_MASK_ALL))
|
|
{
|
|
bpstat_clear_actions ();
|
|
do_all_intermediate_continuations (1);
|
|
do_all_continuations (1);
|
|
async_enable_stdin ();
|
|
display_gdb_prompt (0);
|
|
}
|
|
break;
|
|
|
|
case INF_EXEC_COMPLETE:
|
|
if (!non_stop)
|
|
{
|
|
/* Unregister the inferior from the event loop. This is done
|
|
so that when the inferior is not running we don't get
|
|
distracted by spurious inferior output. */
|
|
if (target_has_execution)
|
|
target_async (NULL, 0);
|
|
}
|
|
|
|
/* Do all continuations associated with the whole inferior (not
|
|
a particular thread). */
|
|
if (!ptid_equal (inferior_ptid, null_ptid))
|
|
do_all_inferior_continuations (0);
|
|
|
|
/* If we were doing a multi-step (eg: step n, next n), but it
|
|
got interrupted by a breakpoint, still do the pending
|
|
continuations. The continuation itself is responsible for
|
|
distinguishing the cases. The continuations are allowed to
|
|
touch the inferior memory, e.g. to remove breakpoints, so run
|
|
them before running breakpoint commands, which may resume the
|
|
target. */
|
|
if (non_stop
|
|
&& target_has_execution
|
|
&& !ptid_equal (inferior_ptid, null_ptid))
|
|
do_all_intermediate_continuations_thread (inferior_thread (), 0);
|
|
else
|
|
do_all_intermediate_continuations (0);
|
|
|
|
/* Always finish the previous command before running any
|
|
breakpoint commands. Any stop cancels the previous command.
|
|
E.g. a "finish" or "step-n" command interrupted by an
|
|
unrelated breakpoint is canceled. */
|
|
if (non_stop
|
|
&& target_has_execution
|
|
&& !ptid_equal (inferior_ptid, null_ptid))
|
|
do_all_continuations_thread (inferior_thread (), 0);
|
|
else
|
|
do_all_continuations (0);
|
|
|
|
/* When running a command list (from a user command, say), these
|
|
are only run when the command list is all done. */
|
|
if (interpreter_async)
|
|
{
|
|
volatile struct gdb_exception e;
|
|
|
|
check_frame_language_change ();
|
|
|
|
/* Don't propagate breakpoint commands errors. Either we're
|
|
stopping or some command resumes the inferior. The user will
|
|
be informed. */
|
|
TRY_CATCH (e, RETURN_MASK_ALL)
|
|
{
|
|
bpstat_do_actions ();
|
|
}
|
|
exception_print (gdb_stderr, e);
|
|
}
|
|
break;
|
|
|
|
case INF_EXEC_CONTINUE:
|
|
/* Is there anything left to do for the command issued to
|
|
complete? */
|
|
|
|
if (non_stop)
|
|
do_all_intermediate_continuations_thread (inferior_thread (), 0);
|
|
else
|
|
do_all_intermediate_continuations (0);
|
|
break;
|
|
|
|
case INF_TIMER:
|
|
default:
|
|
printf_unfiltered (_("Event type not recognized.\n"));
|
|
break;
|
|
}
|
|
|
|
discard_cleanups (cleanup_if_error);
|
|
}
|
|
|
|
static int
|
|
fetch_inferior_event_wrapper (gdb_client_data client_data)
|
|
{
|
|
fetch_inferior_event (client_data);
|
|
return 1;
|
|
}
|