Use RAII to set the per-thread SIGSEGV handler
authorChristian Biesinger <cbiesinger@google.com>
Tue, 9 Mar 2021 14:16:23 +0000 (08:16 -0600)
committerChristian Biesinger <cbiesinger@google.com>
Fri, 12 Mar 2021 17:21:42 +0000 (11:21 -0600)
commitfece451c2aca57b095e7e4063e342781cf74aa75
treeb1b52ba0a7f3399f65b4b416bc4af7f8ad7b754b
parentbe3b926d8d2dde16a55e9e303fadf95164e13ebf
Use RAII to set the per-thread SIGSEGV handler

This avoids using a thread-local extern variable, which causes link errors
on some platforms, notably Cygwin.  But I think this is a better pattern
even outside of working around linker bugs because it encapsulates direct
access to the variable inside the class, instead of having a global extern
variable.

The cygwin link error is:
cp-support.o: in function `gdb_demangle(char const*, int)':
/home/Christian/binutils-gdb/obj/gdb/../../gdb/cp-support.c:1619:(.text+0x6472): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
/home/Christian/binutils-gdb/obj/gdb/../../gdb/cp-support.c:1619:(.text+0x648b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
collect2: error: ld returned 1 exit status

2021-03-12  Christian Biesinger  <cbiesinger@google.com>

PR threads/27239
* cp-support.c: Use scoped_segv_handler_restore.
* event-top.c (thread_local_segv_handler): Made static.
(scoped_segv_handler_restore::scoped_segv_handler_restore):
New function.
(scoped_segv_handler_restore::~scoped_segv_handler_restore): New
function.
* event-top.h (class scoped_segv_handler_restore): New class.
(thread_local_segv_handler): Removed.
gdb/ChangeLog
gdb/cp-support.c
gdb/event-top.c
gdb/event-top.h
This page took 0.026852 seconds and 4 git commands to generate.