From 679b76da478b35012ac309d0c1452a66810bd745 Mon Sep 17 00:00:00 2001 From: charlet Date: Thu, 13 Oct 2011 10:22:28 +0000 Subject: [PATCH] 2011-10-13 Ed Schonberg * sem_ch12.adb (Analyze_Formal_{Floating_Type, Signed_Integer_Type, Decimal_Fixed_Point_Type, Discrete_Type}): Use sloc of defining identifier of farmal type declaration, as sloc of generated internal entity, to prevent misplaced references in ali. 2011-10-13 Ed Schonberg * sem_intr.adb (Check_Intrinsic_Operator): Check that type is fully defined before checking that it is a numeric type. 2011-10-13 Ed Schonberg * sem_aggr.adb (Resolve_Record_Aggregate): If a component association for component X has a box, then X is covered in the aggregate even if there is not default value for X in the type declaration, and X has to be default-initialized. 2011-10-13 Ed Schonberg * sem_attr.adb (Check_Enum_Image, Analyze_Attribute case 'Value): Mark literals as referenced only if reference is in current source unit. 2011-10-13 Matthew Heaney * a-csquin.ads (Enque, Dequeue): Mark interface operations as entries. 2011-10-13 Olivier Hainque * sigtramp.h: New file. Prototype and spec of the signal trampoline to be called by an established handler to provide dwarf call frame info before the real signal processing code. * sigtramp-ppcvxw.c: New file. Implementation of the signal trampoline for ppc-vxworks. * init.c (vxworks section): Use it for ppc. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179899 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 39 +++++++ gcc/ada/a-csquin.ads | 16 ++- gcc/ada/init.c | 19 +++- gcc/ada/sem_aggr.adb | 7 ++ gcc/ada/sem_attr.adb | 12 ++- gcc/ada/sem_ch12.adb | 19 +++- gcc/ada/sem_intr.adb | 6 +- gcc/ada/sigtramp-ppcvxw.c | 256 ++++++++++++++++++++++++++++++++++++++++++++++ gcc/ada/sigtramp.h | 56 ++++++++++ 9 files changed, 415 insertions(+), 15 deletions(-) create mode 100644 gcc/ada/sigtramp-ppcvxw.c create mode 100644 gcc/ada/sigtramp.h diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ffddae3..7abe47a 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,42 @@ +2011-10-13 Ed Schonberg + + * sem_ch12.adb (Analyze_Formal_{Floating_Type, + Signed_Integer_Type, Decimal_Fixed_Point_Type, Discrete_Type}): + Use sloc of defining identifier of farmal type declaration, + as sloc of generated internal entity, to prevent misplaced + references in ali. + +2011-10-13 Ed Schonberg + + * sem_intr.adb (Check_Intrinsic_Operator): Check that type + is fully defined before checking that it is a numeric type. + +2011-10-13 Ed Schonberg + + * sem_aggr.adb (Resolve_Record_Aggregate): If a component + association for component X has a box, then X is covered in the + aggregate even if there is not default value for X in the type + declaration, and X has to be default-initialized. + +2011-10-13 Ed Schonberg + + * sem_attr.adb (Check_Enum_Image, Analyze_Attribute case + 'Value): Mark literals as referenced only if reference is in + current source unit. + +2011-10-13 Matthew Heaney + + * a-csquin.ads (Enque, Dequeue): Mark interface operations as entries. + +2011-10-13 Olivier Hainque + + * sigtramp.h: New file. Prototype and spec of the signal + trampoline to be called by an established handler to provide + dwarf call frame info before the real signal processing code. + * sigtramp-ppcvxw.c: New file. Implementation of the signal + trampoline for ppc-vxworks. + * init.c (vxworks section): Use it for ppc. + 2011-10-13 Thomas Quinot * par-ch2.adb, par.adb, par-util.adb, par-ch3.adb diff --git a/gcc/ada/a-csquin.ads b/gcc/ada/a-csquin.ads index 2a4d0b3..7567444 100644 --- a/gcc/ada/a-csquin.ads +++ b/gcc/ada/a-csquin.ads @@ -42,12 +42,24 @@ package Ada.Containers.Synchronized_Queue_Interfaces is procedure Enqueue (Container : in out Queue; New_Item : Element_Type) is abstract; - -- with Is_Synchronized => By_Entry; ??? + + -- ??? + -- This is the official Ada 2012 syntax: + -- with Synchronization => By_Entry; + + -- This is the temporary work-around: + pragma Implemented (Enqueue, By_Entry); procedure Dequeue (Container : in out Queue; Element : out Element_Type) is abstract; - -- with Is_Synchronized => By_Entry; ??? + + -- ??? + -- This is the official Ada 2012 syntax: + -- with Synchronization => By_Entry; + + -- This is the temporary work-around: + pragma Implemented (Dequeue, By_Entry); function Current_Use (Container : Queue) return Count_Type is abstract; diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 0cf32e8..9b24395 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -1906,7 +1906,8 @@ __gnat_clear_exception_count (void) /* Handle different SIGnal to exception mappings in different VxWorks versions. */ static void -__gnat_map_signal (int sig) +__gnat_map_signal (int sig, void *si ATTRIBUTE_UNUSED, + struct sigcontext *sc ATTRIBUTE_UNUSED) { struct Exception_Data *exception; const char *msg; @@ -2001,9 +2002,7 @@ __gnat_map_signal (int sig) propagation after the required low level adjustments. */ void -__gnat_error_handler (int sig, - void *si ATTRIBUTE_UNUSED, - struct sigcontext *sc ATTRIBUTE_UNUSED) +__gnat_error_handler (int sig, void *si, struct sigcontext *sc) { sigset_t mask; @@ -2015,7 +2014,17 @@ __gnat_error_handler (int sig, sigdelset (&mask, sig); sigprocmask (SIG_SETMASK, &mask, NULL); - __gnat_map_signal (sig); +#if defined (__PPC__) + /* We process signals through a Call Frame Info trampoline, voiding + the need for myriads of fallback_frame_state variants. */ + + #include "sigtramp.h" + + __gnat_sigtramp (sig, si, sc, &__gnat_map_signal); + +#else + __gnat_map_signal (sig, si, sc); +#endif } void diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index f4d2ad8..82c7547 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3121,6 +3121,13 @@ package body Sem_Aggr is Expr := New_Copy_Tree (Expression (Parent (Compon))); + -- Component may have no default, in which case the + -- expression is empty and the component is default- + -- initialized, but an association for the component + -- exists, and it is not covered by an others clause. + + return Expr; + else if Present (Next (Selector_Name)) then Expr := New_Copy_Tree (Expression (Assoc)); diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index caacc45..7b15644 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -264,6 +264,10 @@ package body Sem_Attr is -- If the prefix type is an enumeration type, set all its literals -- as referenced, since the image function could possibly end up -- referencing any of the literals indirectly. Same for Enum_Val. + -- Set the flag only if the reference is in the main code unit. Same + -- restriction when resolving 'Value; otherwise an improperly set + -- reference when analyzing an inlined body will lose a proper warning + -- on a useless with_clause. procedure Check_Fixed_Point_Type; -- Verify that prefix of attribute N is a fixed type @@ -1226,7 +1230,9 @@ package body Sem_Attr is procedure Check_Enum_Image is Lit : Entity_Id; begin - if Is_Enumeration_Type (P_Base_Type) then + if Is_Enumeration_Type (P_Base_Type) + and then In_Extended_Main_Code_Unit (N) + then Lit := First_Literal (P_Base_Type); while Present (Lit) loop Set_Referenced (Lit); @@ -5031,7 +5037,9 @@ package body Sem_Attr is -- Case of enumeration type - if Is_Enumeration_Type (P_Type) then + if Is_Enumeration_Type (P_Type) + and then In_Extended_Main_Code_Unit (N) + then Check_Restriction (No_Enumeration_Maps, N); -- Mark all enumeration literals as referenced, since the use of diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 6dd6e7b..9da8614 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -1565,6 +1565,9 @@ package body Sem_Ch12 is -- static. For all scalar types we introduce an anonymous base type, with -- the same attributes. We choose the corresponding integer type to be -- Standard_Integer. + -- Here and in other similar routines, the Sloc of the generated internal + -- type must be the same as the sloc of the defining identifier of the + -- formal type declaration, to provide proper source navigation. procedure Analyze_Formal_Decimal_Fixed_Point_Type (T : Entity_Id; @@ -1574,7 +1577,8 @@ package body Sem_Ch12 is Base : constant Entity_Id := New_Internal_Entity (E_Decimal_Fixed_Point_Type, - Current_Scope, Sloc (Def), 'G'); + Current_Scope, + Sloc (Defining_Identifier (Parent (Def))), 'G'); Int_Base : constant Entity_Id := Standard_Integer; Delta_Val : constant Ureal := Ureal_1; Digs_Val : constant Uint := Uint_6; @@ -1714,7 +1718,8 @@ package body Sem_Ch12 is Base : constant Entity_Id := New_Internal_Entity - (E_Floating_Point_Type, Current_Scope, Sloc (Def), 'G'); + (E_Floating_Point_Type, Current_Scope, + Sloc (Defining_Identifier (Parent (Def))), 'G'); begin Enter_Name (T); Set_Ekind (T, E_Enumeration_Subtype); @@ -1762,7 +1767,8 @@ package body Sem_Ch12 is procedure Analyze_Formal_Floating_Type (T : Entity_Id; Def : Node_Id) is Base : constant Entity_Id := New_Internal_Entity - (E_Floating_Point_Type, Current_Scope, Sloc (Def), 'G'); + (E_Floating_Point_Type, Current_Scope, + Sloc (Defining_Identifier (Parent (Def))), 'G'); begin -- The various semantic attributes are taken from the predefined type @@ -1980,7 +1986,8 @@ package body Sem_Ch12 is Loc : constant Source_Ptr := Sloc (Def); Base : constant Entity_Id := New_Internal_Entity - (E_Ordinary_Fixed_Point_Type, Current_Scope, Sloc (Def), 'G'); + (E_Ordinary_Fixed_Point_Type, Current_Scope, + Sloc (Defining_Identifier (Parent (Def))), 'G'); begin -- The semantic attributes are set for completeness only, their values -- will never be used, since all properties of the type are non-static. @@ -2403,7 +2410,9 @@ package body Sem_Ch12 is is Base : constant Entity_Id := New_Internal_Entity - (E_Signed_Integer_Type, Current_Scope, Sloc (Def), 'G'); + (E_Signed_Integer_Type, + Current_Scope, + Sloc (Defining_Identifier (Parent (Def))), 'G'); begin Enter_Name (T); diff --git a/gcc/ada/sem_intr.adb b/gcc/ada/sem_intr.adb index 1901682..26f9ff4 100644 --- a/gcc/ada/sem_intr.adb +++ b/gcc/ada/sem_intr.adb @@ -317,7 +317,11 @@ package body Sem_Intr is return; end if; - if not Is_Numeric_Type (Underlying_Type (T1)) then + -- The type must be fully defined and numeric. + + if No (Underlying_Type (T1)) + or else not Is_Numeric_Type (Underlying_Type (T1)) + then Errint ("intrinsic operator can only apply to numeric types", E, N); end if; end Check_Intrinsic_Operator; diff --git a/gcc/ada/sigtramp-ppcvxw.c b/gcc/ada/sigtramp-ppcvxw.c new file mode 100644 index 0000000..57a02a7 --- /dev/null +++ b/gcc/ada/sigtramp-ppcvxw.c @@ -0,0 +1,256 @@ +/**************************************************************************** + * * + * GNAT COMPILER COMPONENTS * + * * + * S I G T R A M P * + * * + * Asm Implementation File * + * * + * Copyright (C) 2011, Free Software Foundation, Inc. * + * * + * GNAT is free software; you can redistribute it and/or modify it under * + * terms of the GNU General Public License as published by the Free Soft- * + * ware Foundation; either version 3, or (at your option) any later ver- * + * sion. GNAT is distributed in the hope that it will be useful, but WITH- * + * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * + * or FITNESS FOR A PARTICULAR PURPOSE. * + * * + * As a special exception under Section 7 of GPL version 3, you are granted * + * additional permissions described in the GCC Runtime Library Exception, * + * version 3.1, as published by the Free Software Foundation. * + * * + * In particular, you can freely distribute your programs built with the * + * GNAT Pro compiler, including any required library run-time units, using * + * any licensing terms of your choosing. See the AdaCore Software License * + * for full details. * + * * + * GNAT was originally developed by the GNAT team at New York University. * + * Extensive contributions were provided by Ada Core Technologies Inc. * + * * + ****************************************************************************/ + +/********************************************************** + * PowerPC-VxWorks version of the __gnat_sigtramp service * + **********************************************************/ + +#include "sigtramp.h" + +#include +#include +#include + +/* ---------------------- + -- General comments -- + ---------------------- + + Stubs are generated from toplevel asms and .cfi directives, much simpler + to use and check for correctness than manual encodings of CFI byte + sequences. The general idea is to establish CFA as sigcontext->sc_pregs + and state where to find the registers as offsets from there. + + As of today, we support a single stub, providing CFI info for common + registers (GPRs, LR, ...). We might need variants with support for floating + point or altivec registers as well at some point. + + Checking which variant should apply and getting at sc_pregs is simpler + to express in C (we can't use offsetof in toplevel asms and hardcoding + constants is not workable with the flurry of VxWorks variants), so this + is the choice for our toplevel interface. */ + +/* ----------------------------------------- + -- Protypes for our internal asm stubs -- + ----------------------------------------- + + SC_PREGS is always expected to be SIGCONTEXT->sc_pregs. Eventhough our + symbols will remain local, the prototype claims "extern" and not + "static" to prevent compiler complaints about a symbol used but never + defined. */ + +/* sigtramp stub providing CFI info for common registers. */ + +extern void __gnat_sigtramp_common +(int signo, void *siginfo, void *sigcontext, + sighandler_t * handler, void * sc_pregs); + + +/* ------------------------------------- + -- Common interface implementation -- + ------------------------------------- + + We enforce optimization to minimize the overhead of the extra layer. */ + +void __gnat_sigtramp (int signo, void *si, void *sc, + sighandler_t * handler) + __attribute__((optimize(2))); + +void __gnat_sigtramp (int signo, void *si, void *sc, + sighandler_t * handler) +{ + struct sigcontext * sctx = (struct sigcontext *) sc; + + __gnat_sigtramp_common (signo, si, sctx, handler, sctx->sc_pregs); +} + + +/* --------------------------- + -- And now the asm stubs -- + --------------------------- + + They all have a common structure with blocks of asm sequences queued one + after the others. Typically: + + SYMBOL_START + + CFI_DIRECTIVES + CFI_DEF_CFA, + CFI_COMMON_REGISTERS, + ... + + STUB_BODY + asm code to establish frame, setup the cfa reg value, + call the real signal handler, ... + + SYMBOL_END +*/ + +/*-------------------------------- + -- Misc constants and helpers -- + -------------------------------- */ + +/* REGNO constants, dwarf column numbers for registers of interest. */ + +#define REGNO_LR 65 +#define REGNO_XER 76 +#define REGNO_CR 70 +#define REGNO_GR(N) (N) + +#define REGNO_PC 67 /* ARG_POINTER_REGNUM */ + +/* asm string contruction helpers. */ + +#define STR(TEXT) #TEXT +/* stringify expanded TEXT, surrounding it with double quotes. */ + +#define S(E) STR(E) +/* stringify E, which will resolve as text but may contain macros + still to be expanded. */ + +/* asm (TEXT) outputs TEXT. These facilitate the output of + multine contents: */ +#define TAB(S) "\t" S +#define CR(S) S "\n" +#define TCR(S) TAB(CR(S)) + +/*------------------------------ + -- Stub construction blocks -- + ------------------------------ */ + +/* CFA setup block + --------------- + Only non-volatile registers are suitable for a CFA base. We use r14 + here and set it to the value we need in stub body that follows. */ + +#define CFI_DEF_CFA \ +CR(".cfi_def_cfa 14, 0") + +/* Register location blocks + ------------------------ + Rules to find registers of interest from the CFA. This should + comprise all the non-volatile registers relevant to the interrupted + context. */ + +#define COMMON_CFI(REG) \ + ".cfi_offset " S(REGNO_##REG) "," S(REG_SET_##REG) + +#define CFI_COMMON_REGS \ +CR("# CFI for common registers\n") \ +TCR(COMMON_CFI(GR(1))) \ +TCR(COMMON_CFI(GR(14))) \ +TCR(COMMON_CFI(GR(15))) \ +TCR(COMMON_CFI(GR(16))) \ +TCR(COMMON_CFI(GR(17))) \ +TCR(COMMON_CFI(GR(18))) \ +TCR(COMMON_CFI(GR(19))) \ +TCR(COMMON_CFI(GR(20))) \ +TCR(COMMON_CFI(GR(21))) \ +TCR(COMMON_CFI(GR(22))) \ +TCR(COMMON_CFI(GR(23))) \ +TCR(COMMON_CFI(GR(24))) \ +TCR(COMMON_CFI(GR(25))) \ +TCR(COMMON_CFI(GR(26))) \ +TCR(COMMON_CFI(GR(27))) \ +TCR(COMMON_CFI(GR(28))) \ +TCR(COMMON_CFI(GR(29))) \ +TCR(COMMON_CFI(GR(30))) \ +TCR(COMMON_CFI(GR(31))) \ +TCR(COMMON_CFI(LR)) \ +TCR(COMMON_CFI(CR)) \ +TCR(COMMON_CFI(PC)) \ +TCR(".cfi_return_column " S(REGNO_PC)) + +/* Trampoline body block + --------------------- */ + +#define SIGTRAMP_BODY \ +CR("") \ +TCR("# Allocate frame and save the non-volatile") \ +TCR("# registers we're going to modify") \ +TCR("stwu %r1,-16(%r1)") \ +TCR("mflr %r0") \ +TCR("stw %r0,20(%r1)") \ +TCR("stw %r14,8(%r1)") \ +TCR("") \ +TCR("# Setup r14 = sc_pregs, that we'll retrieve as our CFA value") \ +TCR("mr %r14, %r7") \ +TCR("") \ +TCR("# Call the real handler. The signo, siginfo and sigcontext") \ +TCR("# arguments are the same as those we received in r3, r4 and r5") \ +TCR("mtctr %r6") \ +TCR("bctrl") \ +TCR("") \ +TCR("# Restore our callee-saved items, release our frame and return") \ +TCR("lwz %r14,8(%r1)") \ +TCR("lwz %r0,20(%r1)") \ +TCR("mtlr %r0") \ +TCR("") \ +TCR("addi %r1,%r1,16") \ +TCR("blr") + +/* Symbol definition block + ----------------------- */ + +#define SIGTRAMP_START(SYM) \ +CR("# " S(SYM) " cfi trampoline") \ +TCR(".type " S(SYM) ", @function") \ +CR("") \ +CR(S(SYM) ":") \ +TCR(".cfi_startproc") \ +TCR(".cfi_signal_frame") + +/* Symbol termination block + ------------------------ */ + +#define SIGTRAMP_END(SYM) \ +CR(".cfi_endproc") \ +TCR(".size " S(SYM) ", .-" S(SYM)) + +/*---------------------------- + -- And now, the real code -- + ---------------------------- */ + +/* Text section start. The compiler isn't aware of that switch. */ + +asm (".text\n" + TCR(".align 2")); + +/* sigtramp stub for common registers. */ + +#define TRAMP_COMMON __gnat_sigtramp_common + +asm (SIGTRAMP_START(TRAMP_COMMON)); +asm (CFI_DEF_CFA); +asm (CFI_COMMON_REGS); +asm (SIGTRAMP_BODY); +asm (SIGTRAMP_END(TRAMP_COMMON)); + + diff --git a/gcc/ada/sigtramp.h b/gcc/ada/sigtramp.h new file mode 100644 index 0000000..5e3cc5b --- /dev/null +++ b/gcc/ada/sigtramp.h @@ -0,0 +1,56 @@ +/**************************************************************************** + * * + * GNAT COMPILER COMPONENTS * + * * + * S I G T R A M P * + * * + * C Header File * + * * + * Copyright (C) 2011, Free Software Foundation, Inc. * + * * + * GNAT is free software; you can redistribute it and/or modify it under * + * terms of the GNU General Public License as published by the Free Soft- * + * ware Foundation; either version 3, or (at your option) any later ver- * + * sion. GNAT is distributed in the hope that it will be useful, but WITH- * + * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * + * or FITNESS FOR A PARTICULAR PURPOSE. * + * * + * As a special exception under Section 7 of GPL version 3, you are granted * + * additional permissions described in the GCC Runtime Library Exception, * + * version 3.1, as published by the Free Software Foundation. * + * * + * In particular, you can freely distribute your programs built with the * + * GNAT Pro compiler, including any required library run-time units, using * + * any licensing terms of your choosing. See the AdaCore Software License * + * for full details. * + * * + * GNAT was originally developed by the GNAT team at New York University. * + * Extensive contributions were provided by Ada Core Technologies Inc. * + * * + ****************************************************************************/ + +/* On targets where this is implemented, we resort to a signal handler + trampoline to set-up the DWARF Call Frame Information that let unwinders + walk through the signal frame up into the interrupted application code. + This file introduces the relevant declarations. */ + +/* This file should only be #included on targets that do implement the + trampoline, which needs to expose the following interface: */ + +#ifdef __cplusplus +extern "C" { +#endif + + typedef void sighandler_t (int signo, void *siginfo, void *sigcontext); + + void __gnat_sigtramp (int signo, void *siginfo, void *sigcontext, + sighandler_t * handler); + + /* To be called from an established signal handler. Setup the DWARF CFI + bits letting unwinders walk through the signal frame up into the + interrupted application code, and then call HANDLER (SIGNO, SIGINFO, + SIGCONTEXT). */ + +#ifdef __cplusplus +} +#endif -- 2.7.4