projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Introduce common/common-defs.h
[deliverable/binutils-gdb.git]
/
gdb
/
event-top.c
diff --git
a/gdb/event-top.c
b/gdb/event-top.c
index a2766906e46c8b7c03487d60654b713cb5392b4a..833f49db08b568c735b68e1f244d6fe00b303eec 100644
(file)
--- a/
gdb/event-top.c
+++ b/
gdb/event-top.c
@@
-1,7
+1,6
@@
/* Top level stuff for GDB, the GNU debugger.
/* Top level stuff for GDB, the GNU debugger.
- Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009, 2010,
- 2011 Free Software Foundation, Inc.
+ Copyright (C) 1999-2014 Free Software Foundation, Inc.
Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
@@
-23,6
+22,7
@@
#include "defs.h"
#include "top.h"
#include "inferior.h"
#include "defs.h"
#include "top.h"
#include "inferior.h"
+#include "infrun.h"
#include "target.h"
#include "terminal.h" /* for job_control */
#include "event-loop.h"
#include "target.h"
#include "terminal.h" /* for job_control */
#include "event-loop.h"
@@
-36,6
+36,8
@@
#include "observer.h"
#include "continuations.h"
#include "gdbcmd.h" /* for dont_repeat() */
#include "observer.h"
#include "continuations.h"
#include "gdbcmd.h" /* for dont_repeat() */
+#include "annotate.h"
+#include "maint.h"
/* readline include files. */
#include "readline/readline.h"
/* readline include files. */
#include "readline/readline.h"
@@
-58,9
+60,6
@@
static void handle_sigquit (int sig);
static void handle_sighup (int sig);
#endif
static void handle_sigfpe (int sig);
static void handle_sighup (int sig);
#endif
static void handle_sigfpe (int sig);
-#if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
-static void handle_sigwinch (int sig);
-#endif
/* Functions to be invoked by the event loop in response to
signals. */
/* Functions to be invoked by the event loop in response to
signals. */
@@
-74,6
+73,7
@@
static void async_float_handler (gdb_client_data);
#ifdef STOP_SIGNAL
static void async_stop_sig (gdb_client_data);
#endif
#ifdef STOP_SIGNAL
static void async_stop_sig (gdb_client_data);
#endif
+static void async_sigterm_handler (gdb_client_data arg);
/* Readline offers an alternate interface, via callback
functions. These are all included in the file callback.c in the
/* Readline offers an alternate interface, via callback
functions. These are all included in the file callback.c in the
@@
-126,20
+126,18
@@
int input_fd;
handlers mark these functions as ready to be executed and the event
loop, in a later iteration, calls them. See the function
invoke_async_signal_handler. */
handlers mark these functions as ready to be executed and the event
loop, in a later iteration, calls them. See the function
invoke_async_signal_handler. */
-
void
*sigint_token;
+
static struct async_signal_handler
*sigint_token;
#ifdef SIGHUP
#ifdef SIGHUP
-
void
*sighup_token;
+
static struct async_signal_handler
*sighup_token;
#endif
#ifdef SIGQUIT
#endif
#ifdef SIGQUIT
-void *sigquit_token;
-#endif
-void *sigfpe_token;
-#if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
-void *sigwinch_token;
+static struct async_signal_handler *sigquit_token;
#endif
#endif
+static struct async_signal_handler *sigfpe_token;
#ifdef STOP_SIGNAL
#ifdef STOP_SIGNAL
-
void
*sigtstp_token;
+
static struct async_signal_handler
*sigtstp_token;
#endif
#endif
+static struct async_signal_handler *async_sigterm_token;
/* Structure to save a partially entered command. This is used when
the user types '\' at the end of a command line. This is necessary
/* Structure to save a partially entered command. This is used when
the user types '\' at the end of a command line. This is necessary
@@
-172,9
+170,11
@@
rl_callback_read_char_wrapper (gdb_client_data client_data)
}
/* Initialize all the necessary variables, start the event loop,
}
/* Initialize all the necessary variables, start the event loop,
- register readline, and stdin, start the loop. */
+ register readline, and stdin, start the loop. The DATA is the
+ interpreter data cookie, ignored for now. */
+
void
void
-cli_command_loop (void)
+cli_command_loop (void
*data
)
{
display_gdb_prompt (0);
{
display_gdb_prompt (0);
@@
-238,14
+238,11
@@
display_gdb_prompt (char *new_prompt)
char *actual_gdb_prompt = NULL;
struct cleanup *old_chain;
char *actual_gdb_prompt = NULL;
struct cleanup *old_chain;
+ annotate_display_prompt ();
+
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
- /* Each interpreter has its own rules on displaying the command
- prompt. */
- if (!current_interp_display_prompt_p ())
- return;
-
old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
/* Do not call the python hook on an explicit prompt change as
old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
/* Do not call the python hook on an explicit prompt change as
@@
-272,6
+269,7
@@
display_gdb_prompt (char *new_prompt)
rl_callback_handler_remove(), does the job. */
rl_callback_handler_remove ();
rl_callback_handler_remove(), does the job. */
rl_callback_handler_remove ();
+ do_cleanups (old_chain);
return;
}
else
return;
}
else
@@
-415,7
+413,7
@@
command_handler (char *command)
int stdin_is_tty = ISATTY (stdin);
struct cleanup *stat_chain;
int stdin_is_tty = ISATTY (stdin);
struct cleanup *stat_chain;
-
quit_flag = 0
;
+
clear_quit_flag ()
;
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
@@
-457,8
+455,6
@@
command_line_handler (char *rl)
char *p;
char *p1;
char *nline;
char *p;
char *p1;
char *nline;
- char got_eof = 0;
-
int repeat = (instream == stdin);
if (annotation_level > 1 && instream == stdin)
int repeat = (instream == stdin);
if (annotation_level > 1 && instream == stdin)
@@
-503,7
+499,6
@@
command_line_handler (char *rl)
and exit from gdb. */
if (!rl || rl == (char *) EOF)
{
and exit from gdb. */
if (!rl || rl == (char *) EOF)
{
- got_eof = 1;
command_handler (0);
return; /* Lint. */
}
command_handler (0);
return; /* Lint. */
}
@@
-609,8
+604,7
@@
command_line_handler (char *rl)
*p = 0;
/* Add line to history if appropriate. */
*p = 0;
/* Add line to history if appropriate. */
- if (instream == stdin
- && ISATTY (stdin) && *linebuffer)
+ if (*linebuffer && input_from_terminal_p ())
add_history (linebuffer);
/* Note: lines consisting solely of comments are added to the command
add_history (linebuffer);
/* Note: lines consisting solely of comments are added to the command
@@
-737,6
+731,8
@@
async_init_signals (void)
sigint_token =
create_async_signal_handler (async_request_quit, NULL);
signal (SIGTERM, handle_sigterm);
sigint_token =
create_async_signal_handler (async_request_quit, NULL);
signal (SIGTERM, handle_sigterm);
+ async_sigterm_token
+ = create_async_signal_handler (async_sigterm_handler, NULL);
/* If SIGTRAP was set to SIG_IGN, then the SIG_IGN will get passed
to the inferior and breakpoints will be ignored. */
/* If SIGTRAP was set to SIG_IGN, then the SIG_IGN will get passed
to the inferior and breakpoints will be ignored. */
@@
-769,22
+765,10
@@
async_init_signals (void)
sigfpe_token =
create_async_signal_handler (async_float_handler, NULL);
sigfpe_token =
create_async_signal_handler (async_float_handler, NULL);
-#if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
- signal (SIGWINCH, handle_sigwinch);
- sigwinch_token =
- create_async_signal_handler (SIGWINCH_HANDLER, NULL);
-#endif
#ifdef STOP_SIGNAL
sigtstp_token =
create_async_signal_handler (async_stop_sig, NULL);
#endif
#ifdef STOP_SIGNAL
sigtstp_token =
create_async_signal_handler (async_stop_sig, NULL);
#endif
-
-}
-
-void
-mark_async_signal_handler_wrapper (void *token)
-{
- mark_async_signal_handler ((struct async_signal_handler *) token);
}
/* Tell the event loop what to do if SIGINT is received.
}
/* Tell the event loop what to do if SIGINT is received.
@@
-799,7
+783,7
@@
handle_sigint (int sig)
set quit_flag to 1 here. Then if QUIT is called before we get to
the event loop, we will unwind as expected. */
set quit_flag to 1 here. Then if QUIT is called before we get to
the event loop, we will unwind as expected. */
-
quit_flag = 1
;
+
set_quit_flag ()
;
/* If immediate_quit is set, we go ahead and process the SIGINT right
away, even if we usually would defer this to the event loop. The
/* If immediate_quit is set, we go ahead and process the SIGINT right
away, even if we usually would defer this to the event loop. The
@@
-812,13
+796,33
@@
handle_sigint (int sig)
gdb_call_async_signal_handler (sigint_token, immediate_quit);
}
gdb_call_async_signal_handler (sigint_token, immediate_quit);
}
+/* Handle GDB exit upon receiving SIGTERM if target_can_async_p (). */
+
+static void
+async_sigterm_handler (gdb_client_data arg)
+{
+ quit_force (NULL, stdin == instream);
+}
+
+/* See defs.h. */
+volatile int sync_quit_force_run;
+
/* Quit GDB if SIGTERM is received.
GDB would quit anyway, but this way it will clean up properly. */
void
handle_sigterm (int sig)
{
signal (sig, handle_sigterm);
/* Quit GDB if SIGTERM is received.
GDB would quit anyway, but this way it will clean up properly. */
void
handle_sigterm (int sig)
{
signal (sig, handle_sigterm);
- quit_force ((char *) 0, stdin == instream);
+
+ /* Call quit_force in a signal safe way.
+ quit_force itself is not signal safe. */
+ if (target_can_async_p ())
+ mark_async_signal_handler (async_sigterm_token);
+ else
+ {
+ sync_quit_force_run = 1;
+ set_quit_flag ();
+ }
}
/* Do the quit. All the checks have been done by the caller. */
}
/* Do the quit. All the checks have been done by the caller. */
@@
-828,10
+832,9
@@
async_request_quit (gdb_client_data arg)
/* If the quit_flag has gotten reset back to 0 by the time we get
back here, that means that an exception was thrown to unwind the
current command before we got back to the event loop. So there
/* If the quit_flag has gotten reset back to 0 by the time we get
back here, that means that an exception was thrown to unwind the
current command before we got back to the event loop. So there
- is no reason to call quit again here, unless immediate_quit is
- set. */
+ is no reason to call quit again here. */
- if (
quit_flag || immediate_quit
)
+ if (
check_quit_flag ()
)
quit ();
}
quit ();
}
@@
-841,7
+844,7
@@
async_request_quit (gdb_client_data arg)
static void
handle_sigquit (int sig)
{
static void
handle_sigquit (int sig)
{
- mark_async_signal_handler
_wrapper
(sigquit_token);
+ mark_async_signal_handler (sigquit_token);
signal (sig, handle_sigquit);
}
#endif
signal (sig, handle_sigquit);
}
#endif
@@
-862,7
+865,7
@@
async_do_nothing (gdb_client_data arg)
static void
handle_sighup (int sig)
{
static void
handle_sighup (int sig)
{
- mark_async_signal_handler
_wrapper
(sighup_token);
+ mark_async_signal_handler (sighup_token);
signal (sig, handle_sighup);
}
signal (sig, handle_sighup);
}
@@
-886,7
+889,7
@@
async_disconnect (gdb_client_data arg)
TRY_CATCH (exception, RETURN_MASK_ALL)
{
TRY_CATCH (exception, RETURN_MASK_ALL)
{
- pop_all_targets (
1
);
+ pop_all_targets ();
}
signal (SIGHUP, SIG_DFL); /*FIXME: ??????????? */
}
signal (SIGHUP, SIG_DFL); /*FIXME: ??????????? */
@@
-898,7
+901,7
@@
async_disconnect (gdb_client_data arg)
void
handle_stop_sig (int sig)
{
void
handle_stop_sig (int sig)
{
- mark_async_signal_handler
_wrapper
(sigtstp_token);
+ mark_async_signal_handler (sigtstp_token);
signal (sig, handle_stop_sig);
}
signal (sig, handle_stop_sig);
}
@@
-938,7
+941,7
@@
async_stop_sig (gdb_client_data arg)
static void
handle_sigfpe (int sig)
{
static void
handle_sigfpe (int sig)
{
- mark_async_signal_handler
_wrapper
(sigfpe_token);
+ mark_async_signal_handler (sigfpe_token);
signal (sig, handle_sigfpe);
}
signal (sig, handle_sigfpe);
}
@@
-950,17
+953,6
@@
async_float_handler (gdb_client_data arg)
divide by zero causes this, so "float" is a misnomer. */
error (_("Erroneous arithmetic operation."));
}
divide by zero causes this, so "float" is a misnomer. */
error (_("Erroneous arithmetic operation."));
}
-
-/* Tell the event loop what to do if SIGWINCH is received.
- See event-signal.c. */
-#if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
-static void
-handle_sigwinch (int sig)
-{
- mark_async_signal_handler_wrapper (sigwinch_token);
- signal (sig, handle_sigwinch);
-}
-#endif
\f
/* Called by do_setshow_command. */
\f
/* Called by do_setshow_command. */
@@
-983,7
+975,7
@@
gdb_setup_readline (void)
time. */
if (!batch_silent)
gdb_stdout = stdio_fileopen (stdout);
time. */
if (!batch_silent)
gdb_stdout = stdio_fileopen (stdout);
- gdb_stderr = std
io_fileopen (stderr
);
+ gdb_stderr = std
err_fileopen (
);
gdb_stdlog = gdb_stderr; /* for moment */
gdb_stdtarg = gdb_stderr; /* for moment */
gdb_stdtargerr = gdb_stderr; /* for moment */
gdb_stdlog = gdb_stderr; /* for moment */
gdb_stdtarg = gdb_stderr; /* for moment */
gdb_stdtargerr = gdb_stderr; /* for moment */
This page took
0.027168 seconds
and
4
git commands to generate.