Automatic date update in version.in
[deliverable/binutils-gdb.git] / gdb / event-top.c
index 63d2295782aeff985dd8a54841a077dd8b6cccc9..fb0df943f650cb3b3a084f50b34033de78d5d18e 100644 (file)
@@ -1,6 +1,6 @@
 /* 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.
 
@@ -415,8 +415,8 @@ display_gdb_prompt (const char *new_prompt)
   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);
     }
@@ -676,8 +676,8 @@ handle_line_of_input (struct buffer *cmd_line_buffer,
   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);
     }
 
@@ -816,7 +816,7 @@ gdb_readline_no_editing_callback (gdb_client_data client_data)
   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)
@@ -850,9 +850,17 @@ gdb_readline_no_editing_callback (gdb_client_data client_data)
 }
 \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);
 
@@ -1288,6 +1296,17 @@ gdb_disable_readline (void)
   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";
This page took 0.024702 seconds and 4 git commands to generate.