From decb95fccf1417e1dfc71bd515b5be472b1b4145 Mon Sep 17 00:00:00 2001 From: charlet Date: Wed, 25 Nov 2015 15:09:38 +0000 Subject: [PATCH] 2015-11-25 Jerome Lambourg * init.c: Enable the signal trampoline on x86_64-vx7 * sigtramp-vxworks-target.inc: Implement the signal trampoline for x86_64 * tracebak.c: Remove the hook to use the generic unwinder on x86_64-vx7. 2015-11-25 Vincent Celier * gnatcmd.adb: When "gnat name -P" is called, invoke gprname directly if available. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230875 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 13 +++++++ gcc/ada/gnatcmd.adb | 14 ++++++- gcc/ada/init.c | 20 ++++++---- gcc/ada/sigtramp-vxworks-target.inc | 77 +++++++++++++++++++++++++++++++++++++ gcc/ada/tracebak.c | 2 +- 5 files changed, 116 insertions(+), 10 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 64c43fb3dad..b7be5a5202b 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,16 @@ +2015-11-25 Jerome Lambourg + + * init.c: Enable the signal trampoline on x86_64-vx7 + * sigtramp-vxworks-target.inc: Implement the signal trampoline + for x86_64 + * tracebak.c: Remove the hook to use the generic + unwinder on x86_64-vx7. + +2015-11-25 Vincent Celier + + * gnatcmd.adb: When "gnat name -P" is called, invoke gprname + directly if available. + 2015-11-25 Tristan Gingold * init.c (__gnat_is_stack_guard): Do not use mach calls for diff --git a/gcc/ada/gnatcmd.adb b/gcc/ada/gnatcmd.adb index dcc3a85f539..df648319c5f 100644 --- a/gcc/ada/gnatcmd.adb +++ b/gcc/ada/gnatcmd.adb @@ -63,6 +63,9 @@ procedure GNATCmd is Gprclean : constant String := "gprclean"; Gnatclean : constant String := "gnatclean"; + Gprname : constant String := "gprname"; + Gnatname : constant String := "gnatname"; + Normal_Exit : exception; -- Raise this exception for normal program termination @@ -1183,8 +1186,12 @@ begin -- If we want to invoke gnatmake/gnatclean with -P, then check if -- gprbuild/gprclean is available; if it is, use gprbuild/gprclean -- instead of gnatmake/gnatclean. + -- Ditto for gnatname -> gprname. - if Program.all = Gnatmake or else Program.all = Gnatclean then + if Program.all = Gnatmake + or else Program.all = Gnatclean + or else Program.all = Gnatname + then declare Project_File_Used : Boolean := False; Switch : String_Access; @@ -1209,6 +1216,11 @@ begin and then Locate_Exec_On_Path (Gprclean) /= null then Program := new String'(Gprclean); + + elsif Program.all = Gnatname + and then Locate_Exec_On_Path (Gprname) /= null + then + Program := new String'(Gprname); end if; end if; end; diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 57b02a1475d..06e366d7856 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -1974,7 +1974,7 @@ __gnat_error_handler (int sig, siginfo_t *si, void *sc) sigdelset (&mask, sig); sigprocmask (SIG_SETMASK, &mask, NULL); -#if defined (__ARMEL__) || defined (__PPC__) || (defined (__i386__) && _WRS_VXWORKS_MAJOR < 7) +#if defined (__ARMEL__) || defined (__PPC__) || defined (__i386__) || defined (__x86_64__) /* On certain targets, kernel mode, we process signals through a Call Frame Info trampoline, voiding the need for myriads of fallback_frame_state variants in the ZCX runtime. We have no simple way to distinguish ZCX @@ -1982,19 +1982,23 @@ __gnat_error_handler (int sig, siginfo_t *si, void *sc) necessary. This only incurs a few extra instructions and a tiny amount of extra stack usage. */ -#if defined (__i386__) && !defined (VTHREADS) +#ifdef HAVE_GNAT_ADJUST_CONTEXT_FOR_RAISE + /* We need to sometimes to adjust the PC in case of signals so that it + doesn't reference the exception that actually raised the signal but the + instruction before it. */ + __gnat_adjust_context_for_raise (sig, sc); +#endif + +#if defined (__i386__) && !defined (VTHREADS) && (__WRS_VXWORKS_MAJOR < 7) /* On x86, the vxsim signal context is subtly different and is processeed - by a handler compiled especially for vxsim. */ + by a handler compiled especially for vxsim. + Vxsim is not supported anymore on our vxworks-7 port. */ if (is_vxsim) __gnat_vxsim_error_handler (sig, si, sc); #endif -#ifdef HAVE_GNAT_ADJUST_CONTEXT_FOR_RAISE - __gnat_adjust_context_for_raise (sig, sc); -#endif - -#include "sigtramp.h" +# include "sigtramp.h" __gnat_sigtramp (sig, (void *)si, (void *)sc, (__sigtramphandler_t *)&__gnat_map_signal); diff --git a/gcc/ada/sigtramp-vxworks-target.inc b/gcc/ada/sigtramp-vxworks-target.inc index f31594d68b9..fbb708ba2ca 100644 --- a/gcc/ada/sigtramp-vxworks-target.inc +++ b/gcc/ada/sigtramp-vxworks-target.inc @@ -139,6 +139,32 @@ the latter depends on the platform. */ +#elif defined (__x86_64__) + +/* These are the cfi colunm numbers */ + +#define REGNO_RAX 0 +#define REGNO_RDX 1 +#define REGNO_RCX 2 +#define REGNO_RBX 3 +#define REGNO_RSI 4 +#define REGNO_RDI 5 +#define REGNO_RBP 6 +#define REGNO_RSP 7 +#define REGNO_R8 8 +#define REGNO_R9 9 +#define REGNO_R10 10 +#define REGNO_R11 11 +#define REGNO_R12 12 +#define REGNO_R13 13 +#define REGNO_R14 14 +#define REGNO_R15 15 +#define REGNO_SET_PC 16 /* aka %rip */ +#define REGNO_EFLAGS 49 +#define REGNO_FS 54 + +#define FUNCTION "@function" + #else Not_implemented; #endif /* REGNO constants */ @@ -174,6 +200,11 @@ Not_implemented; #define CFA_REG 7 +#elif defined (__x86_64__) + +/* R15 register */ +#define CFA_REG 15 + #else Not_implemented; #endif /* CFA setup block */ @@ -366,6 +397,52 @@ TCR("popl %edi") \ TCR("leave") \ TCR("ret") +#elif defined (__x86_64__) + +#define COMMON_CFI(REG) \ + ".cfi_offset " S(REGNO_##REG) "," S(REG_##REG) +#define PC_CFI(REG) \ + ".cfi_offset " S(REGNO_##REG) "," S(REG_##REG) + +#define CFI_COMMON_REGS \ +CR("# CFI for common registers\n") \ +TCR(COMMON_CFI(R15)) \ +TCR(COMMON_CFI(R14)) \ +TCR(COMMON_CFI(R13)) \ +TCR(COMMON_CFI(R12)) \ +TCR(COMMON_CFI(R11)) \ +TCR(COMMON_CFI(R10)) \ +TCR(COMMON_CFI(R9)) \ +TCR(COMMON_CFI(R8)) \ +TCR(COMMON_CFI(RDI)) \ +TCR(COMMON_CFI(RSI)) \ +TCR(COMMON_CFI(RBP)) \ +TCR(COMMON_CFI(RSP)) \ +TCR(COMMON_CFI(RBX)) \ +TCR(COMMON_CFI(RDX)) \ +TCR(COMMON_CFI(RCX)) \ +TCR(COMMON_CFI(RAX)) \ +TCR(COMMON_CFI(EFLAGS)) \ +TCR(COMMON_CFI(SET_PC)) \ +TCR(COMMON_CFI(FS)) \ +TCR(".cfi_return_column " S(REGNO_SET_PC)) + +/* Trampoline body block + --------------------- */ + +#define SIGTRAMP_BODY \ +CR("") \ +TCR("# Allocate frame and save the non-volatile") \ +TCR("# registers we're going to modify") \ +TCR("subq $8, %rsp") \ +TCR("# Setup CFA_REG = context, which we'll retrieve as our CFA value") \ +TCR("movq %r8, %r15") \ +TCR("# Call the real handler. The signo, siginfo and sigcontext") \ +TCR("# arguments are the same as those we received") \ +TCR("call *%rcx") \ +TCR("# This part should never be executed") \ +TCR("ret") + #else Not_implemented; #endif /* CFI_COMMON_REGS and SIGTRAMP_BODY */ diff --git a/gcc/ada/tracebak.c b/gcc/ada/tracebak.c index 3f40ae40c18..ff85ca5baf5 100644 --- a/gcc/ada/tracebak.c +++ b/gcc/ada/tracebak.c @@ -433,7 +433,7 @@ struct layout but our only alternative is the generic unwinder which requires compilation forcing a frame pointer to be reliable. */ -#if (defined (__x86_64__) || defined (__linux__)) && !defined (__USING_SJLJ_EXCEPTIONS__) && !defined (__vxworks) +#if (defined (__x86_64__) || defined (__linux__)) && !defined (__USING_SJLJ_EXCEPTIONS__) #define USE_GCC_UNWINDER #else #define USE_GENERIC_UNWINDER -- 2.11.4.GIT