/* Top level stuff for GDB, the GNU debugger.
- Copyright (C) 1999-2020 Free Software Foundation, Inc.
+ Copyright (C) 1999-2021 Free Software Foundation, Inc.
Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
#include "main.h"
#include "gdbthread.h"
#include "observable.h"
-#include "continuations.h"
#include "gdbcmd.h" /* for dont_repeat() */
#include "annotate.h"
#include "maint.h"
else
{
/* Don't use a _filtered function here. It causes the assumed
- character position to be off, since the newline we read from
- the user is not accounted for. */
+ character position to be off, since the newline we read from
+ the user is not accounted for. */
fprintf_unfiltered (gdb_stdout, "%s", actual_gdb_prompt.c_str ());
gdb_flush (gdb_stdout);
}
if (server_command)
{
/* Note that we don't call `save_command_line'. Between this
- and the check in dont_repeat, this insures that repeating
- will still do the right thing. */
+ and the check in dont_repeat, this insures that repeating
+ will still do the right thing. */
return cmd + strlen (SERVER_COMMAND_PREFIX);
}
while (1)
{
/* Read from stdin if we are executing a user defined command.
- This is the right thing for prompt_for_continue, at least. */
+ This is the right thing for prompt_for_continue, at least. */
c = fgetc (ui->instream != NULL ? ui->instream : ui->stdin_stream);
if (c == EOF)
}
\f
-/* See event-top.h. */
+/* The SIGSEGV handler for this thread, or NULL if there is none. GDB
+ always installs a global SIGSEGV handler, and then lets threads
+ indicate their interest in handling the signal by setting this
+ thread-local variable.
-thread_local void (*thread_local_segv_handler) (int);
+ This is a static variable instead of extern because on various platforms
+ (notably Cygwin) extern thread_local variables cause link errors. So
+ instead, we have scoped_segv_handler_restore, which also makes it impossible
+ to accidentally forget to restore it to the original value. */
+
+static thread_local void (*thread_local_segv_handler) (int);
static void handle_sigsegv (int sig);
delete_file_handler (ui->input_fd);
}
+scoped_segv_handler_restore::scoped_segv_handler_restore (segv_handler_t new_handler)
+{
+ m_old_handler = thread_local_segv_handler;
+ thread_local_segv_handler = new_handler;
+}
+
+scoped_segv_handler_restore::~scoped_segv_handler_restore()
+{
+ thread_local_segv_handler = m_old_handler;
+}
+
static const char debug_event_loop_off[] = "off";
static const char debug_event_loop_all_except_ui[] = "all-except-ui";
static const char debug_event_loop_all[] = "all";