From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 741AF3858012; Tue, 13 Apr 2021 15:12:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 741AF3858012 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9347] Further increase the limit on the size of accepted Ada files X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: e268afb4a89d172244ef46d999be97b1dd8343d8 X-Git-Newrev: 877951468f86631351821222dcc372f1b1d26de9 Message-Id: <20210413151200.741AF3858012@sourceware.org> Date: Tue, 13 Apr 2021 15:12:00 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Apr 2021 15:12:00 -0000 https://gcc.gnu.org/g:877951468f86631351821222dcc372f1b1d26de9 commit r9-9347-g877951468f86631351821222dcc372f1b1d26de9 Author: Eric Botcazou Date: Tue Apr 13 17:10:45 2021 +0200 Further increase the limit on the size of accepted Ada files It turns out that the limit on the size of accepted Ada files had been already lowered earlier, namely when location ranges had been introduced. Now we do not make use of location ranges in Ada so we can recoup the loss. gcc/ada/ * gcc-interface/misc.c (gnat_init): Set default range bits to 0. * gcc-interface/trans.c (extract_encoding): Delete. (decode_name): Likewise. (File_Name_to_gnu): New function. (gigi): Call it to translate file names. Replace assertion on 1-1 mapping between files and line maps with conditional error. Diff: --- gcc/ada/gcc-interface/misc.c | 3 +++ gcc/ada/gcc-interface/trans.c | 62 ++++++++++++++++--------------------------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 5737165949e..89ec5c8bd93 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -368,6 +368,9 @@ gnat_init (void) sbitsize_one_node = sbitsize_int (1); sbitsize_unit_node = sbitsize_int (BITS_PER_UNIT); + /* In Ada, we do not use location ranges. */ + line_table->default_range_bits = 0; + /* Register our internal error function. */ global_dc->internal_error = &internal_error_function; diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 32351bf0f9b..d2e554a747b 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -250,17 +250,27 @@ static tree build_raise_check (int, enum exception_info_kind); static tree create_init_temporary (const char *, tree, tree *, Node_Id); static bool maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk); -/* Hooks for debug info back-ends, only supported and used in a restricted set - of configurations. */ -static const char *extract_encoding (const char *) ATTRIBUTE_UNUSED; -static const char *decode_name (const char *) ATTRIBUTE_UNUSED; - /* This makes gigi's file_info_ptr visible in this translation unit, so that Sloc_to_locus can look it up when deciding whether to map decls to instances. */ static struct File_Info_Type *file_map; +/* Return the string of the identifier allocated for the file name Id. */ + +static const char* +File_Name_to_gnu (Name_Id Id) +{ + /* __gnat_to_canonical_file_spec translates file names from pragmas + Source_Reference that contain host style syntax not understood by GDB. */ + const char *name = __gnat_to_canonical_file_spec (Get_Name_String (Id)); + + /* Use the identifier table to make a permanent copy of the file name as + the name table gets reallocated after Gigi returns but before all the + debugging information is output. */ + return IDENTIFIER_POINTER (get_identifier (name)); +} + /* This is the main program of the back-end. It sets up all the table structures and then generates code. */ @@ -314,23 +324,18 @@ gigi (Node_Id gnat_root, for (i = 0; i < number_file; i++) { - /* Use the identifier table to make a permanent copy of the filename as - the name table gets reallocated after Gigi returns but before all the - debugging information is output. The __gnat_to_canonical_file_spec - call translates filenames from pragmas Source_Reference that contain - host style syntax not understood by gdb. */ - const char *filename - = IDENTIFIER_POINTER - (get_identifier - (__gnat_to_canonical_file_spec - (Get_Name_String (file_info_ptr[i].File_Name)))); - /* We rely on the order isomorphism between files and line maps. */ - gcc_assert ((int) LINEMAPS_ORDINARY_USED (line_table) == i); + if ((int) LINEMAPS_ORDINARY_USED (line_table) != i) + { + gcc_assert (i > 0); + error ("%s contains too many lines", + File_Name_to_gnu (file_info_ptr[i - 1].File_Name)); + } /* We create the line map for a source file at once, with a fixed number of columns chosen to avoid jumping over the next power of 2. */ - linemap_add (line_table, LC_ENTER, 0, filename, 1); + linemap_add (line_table, LC_ENTER, 0, + File_Name_to_gnu (file_info_ptr[i].File_Name), 1); linemap_line_start (line_table, file_info_ptr[i].Num_Source_Lines, 252); linemap_position_for_column (line_table, 252 - 1); linemap_add (line_table, LC_LEAVE, 0, NULL, 0); @@ -10914,28 +10919,7 @@ set_end_locus_from_node (tree gnu_node, Node_Id gnat_node) return false; } } - -/* Return a colon-separated list of encodings contained in encoded Ada - name. */ - -static const char * -extract_encoding (const char *name) -{ - char *encoding = (char *) ggc_alloc_atomic (strlen (name)); - get_encoding (name, encoding); - return encoding; -} -/* Extract the Ada name from an encoded name. */ - -static const char * -decode_name (const char *name) -{ - char *decoded = (char *) ggc_alloc_atomic (strlen (name) * 2 + 60); - __gnat_decode (name, decoded, 0); - return decoded; -} - /* Post an error message. MSG is the error message, properly annotated. NODE is the node at which to post the error and the node to use for the '&' substitution. */