GNU Binutils with patches for OS216
Revisión | 3f772b18309e448aaa253f8e441e4cdd7786257e (tree) |
---|---|
Tiempo | 2017-09-20 22:24:38 |
Autor | Walfred Tedeschi <walfred.tedeschi@yaho...> |
Commiter | Walfred Tedeschi |
icc: allow code path for newer versions of icc.
Patch adds a version checkin for workaround an icc problem.
Icc problem was fixed in version 14, and gdb code has to
reflect the fix.
This patch contains a parser for the icc string version and conditional
workaround execution. Adds also gdb self tests for the dwarf producers.
2017-06-28 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* dwarf2read.c (dwarf2_cu): Remove field producer_is_icc and add
producer_is_icc_lt_14.
(producer_is_icc_lt_14): New function.
(check_producer): Add code for checking version of icc.
(producer_is_icc): Move to dwarf2utils.
(read_structure_type): Add a check for the later version of icc
where the issue was still not fixed.
(dwarf_producer_test): Add new unit test.
(_initialize_dwarf2_read): Register the unit test.
* dwarf2utils.c (producer_is_icc): New function.
* dwarf2utils.h (producer_is_icc): Declaration of a new function.
* dwarf2utils.c (_initialize_dwarf2utils): New function.
Change-Id: I70871846be4b70df477a63e700a52c41da81b92a
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
@@ -82,6 +82,8 @@ | ||
82 | 82 | #include <unordered_set> |
83 | 83 | #include <unordered_map> |
84 | 84 | |
85 | + | |
86 | + | |
85 | 87 | typedef struct symbol *symbolp; |
86 | 88 | DEF_VEC_P (symbolp); |
87 | 89 |
@@ -603,7 +605,7 @@ struct dwarf2_cu | ||
603 | 605 | unsigned int checked_producer : 1; |
604 | 606 | unsigned int producer_is_gxx_lt_4_6 : 1; |
605 | 607 | unsigned int producer_is_gcc_lt_4_3 : 1; |
606 | - unsigned int producer_is_icc : 1; | |
608 | + unsigned int producer_is_icc_lt_14 : 1; | |
607 | 609 | |
608 | 610 | /* When set, the file that we're processing is known to have |
609 | 611 | debugging info for C++ namespaces. GCC 3.3.x did not produce |
@@ -9348,6 +9350,19 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu) | ||
9348 | 9350 | &objfile->objfile_obstack); |
9349 | 9351 | } |
9350 | 9352 | |
9353 | +/* For versions older than 14 ICC did not output the required DW_AT_declaration | |
9354 | + on incomplete types, but gives them a size of zero. Starting on version 14 | |
9355 | + ICC is compatible with GCC. */ | |
9356 | + | |
9357 | +static int | |
9358 | +producer_is_icc_lt_14 (struct dwarf2_cu *cu) | |
9359 | +{ | |
9360 | + if (!cu->checked_producer) | |
9361 | + check_producer (cu); | |
9362 | + | |
9363 | + return cu->producer_is_icc_lt_14; | |
9364 | +} | |
9365 | + | |
9351 | 9366 | /* Check for possibly missing DW_AT_comp_dir with relative .debug_line |
9352 | 9367 | directory paths. GCC SVN r127613 (new option -fdebug-prefix-map) fixed |
9353 | 9368 | this, it was first present in GCC release 4.3.0. */ |
@@ -12829,6 +12844,9 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block, | ||
12829 | 12844 | } |
12830 | 12845 | } |
12831 | 12846 | |
12847 | + | |
12848 | + | |
12849 | + | |
12832 | 12850 | /* Check whether the producer field indicates either of GCC < 4.6, or the |
12833 | 12851 | Intel C/C++ compiler, and cache the result in CU. */ |
12834 | 12852 |
@@ -12853,8 +12871,10 @@ check_producer (struct dwarf2_cu *cu) | ||
12853 | 12871 | cu->producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6); |
12854 | 12872 | cu->producer_is_gcc_lt_4_3 = major < 4 || (major == 4 && minor < 3); |
12855 | 12873 | } |
12856 | - else if (startswith (cu->producer, "Intel(R) C")) | |
12857 | - cu->producer_is_icc = 1; | |
12874 | + else if (producer_is_icc (cu->producer, &major, &minor)) | |
12875 | + { | |
12876 | + cu->producer_is_icc_lt_14 = major < 14 ; | |
12877 | + } | |
12858 | 12878 | else |
12859 | 12879 | { |
12860 | 12880 | /* For other non-GCC compilers, expect their behavior is DWARF version |
@@ -13595,17 +13615,6 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) | ||
13595 | 13615 | smash_to_methodptr_type (type, new_type); |
13596 | 13616 | } |
13597 | 13617 | |
13598 | -/* Return non-zero if the CU's PRODUCER string matches the Intel C/C++ compiler | |
13599 | - (icc). */ | |
13600 | - | |
13601 | -static int | |
13602 | -producer_is_icc (struct dwarf2_cu *cu) | |
13603 | -{ | |
13604 | - if (!cu->checked_producer) | |
13605 | - check_producer (cu); | |
13606 | - | |
13607 | - return cu->producer_is_icc; | |
13608 | -} | |
13609 | 13618 | |
13610 | 13619 | /* Called when we find the DIE that starts a structure or union scope |
13611 | 13620 | (definition) to create a type for the structure or union. Fill in |
@@ -13711,7 +13720,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) | ||
13711 | 13720 | TYPE_LENGTH (type) = 0; |
13712 | 13721 | } |
13713 | 13722 | |
13714 | - if (producer_is_icc (cu) && (TYPE_LENGTH (type) == 0)) | |
13723 | + if (producer_is_icc_lt_14 (cu) && (TYPE_LENGTH (type) == 0)) | |
13715 | 13724 | { |
13716 | 13725 | /* ICC does not output the required DW_AT_declaration |
13717 | 13726 | on incomplete types, but gives them a size of zero. */ |
@@ -31,6 +31,9 @@ | ||
31 | 31 | #include "common/common-exceptions.h" |
32 | 32 | #include "common/common-utils.h" |
33 | 33 | |
34 | +#if defined GDB_SELF_TEST | |
35 | +#include "selftest.h" | |
36 | +#endif | |
34 | 37 | |
35 | 38 | #include "utils.h" |
36 | 39 |
@@ -84,3 +87,149 @@ producer_is_gcc (const char *producer, int *major, int *minor) | ||
84 | 87 | /* Not recognized as GCC. */ |
85 | 88 | return 0; |
86 | 89 | } |
90 | + | |
91 | +/* Returns nonzero if the given PRODUCER string is Intel or zero | |
92 | + otherwise. Sets the MAJOR and MINOR versions when not NULL. | |
93 | + | |
94 | + Internal and external versions have to be taken into account. | |
95 | + Before a public release string for the PRODUCER is slightly | |
96 | + different than the public one. Internal releases have mainly | |
97 | + a major release number and 0 as minor release. External | |
98 | + releases have 4 fields, 3 of them are not 0 and only two | |
99 | + are of interest, major and update. | |
100 | + | |
101 | + Examples are: | |
102 | + | |
103 | + Public release: | |
104 | + "Intel(R) Fortran Intel(R) 64 Compiler XE for applications | |
105 | + running on Intel(R) 64, Version 14.0.1.074 Build 20130716"; | |
106 | + "Intel(R) C++ Intel(R) 64 Compiler XE for applications | |
107 | + running on Intel(R) 64, Version 14.0.1.074 Build 20130716"; | |
108 | + | |
109 | + Internal releases: | |
110 | + "Intel(R) C++ Intel(R) 64 Compiler for applications | |
111 | + running on Intel(R) 64, Version 18.0 Beta ....". */ | |
112 | + | |
113 | +bool | |
114 | +producer_is_icc (const char *producer, int *major, int *minor) | |
115 | +{ | |
116 | + if (producer == NULL || !startswith (producer, "Intel(R)")) | |
117 | + return 0; | |
118 | + | |
119 | +/* Preparing the used fields. */ | |
120 | + int maj, min; | |
121 | + if (major == NULL) | |
122 | + major = &maj; | |
123 | + if (minor == NULL) | |
124 | + minor = &min; | |
125 | + | |
126 | + *minor = 0; | |
127 | + *major = 0; | |
128 | + | |
129 | + /* Consumes the string till a "Version" is found. */ | |
130 | + const char *cs = strstr(producer, "Version"); | |
131 | + cs = skip_to_space (cs); | |
132 | + | |
133 | + int intermediate = 0; | |
134 | + int nof = sscanf (cs, "%d.%d.%d.%*d", major, &intermediate, minor); | |
135 | + | |
136 | + /* Internal versions are represented only as MAJOR.MINOR, whereas | |
137 | + minor is usually 0. | |
138 | + Public versions have 4 fields as described with the command above. */ | |
139 | + if (nof == 3) | |
140 | + return TRUE; | |
141 | + | |
142 | + if (nof == 2) | |
143 | + { | |
144 | + *minor = intermediate; | |
145 | + return TRUE; | |
146 | + } | |
147 | + | |
148 | + static bool warning_printed = FALSE; | |
149 | + /* Not recognized as Intel, let user know. */ | |
150 | + if (warning_printed == FALSE) | |
151 | + { | |
152 | + warning (_("Could not recognize version of Intel Compiler in:%s"), producer); | |
153 | + warning_printed = TRUE; | |
154 | + } | |
155 | + return FALSE; | |
156 | +} | |
157 | + | |
158 | +#if defined GDB_SELF_TEST | |
159 | +namespace selftests { | |
160 | +namespace dwarf2utils { | |
161 | + | |
162 | +static void | |
163 | +dwarf_producer_test () | |
164 | +{ | |
165 | + int major = 0, minor = 0; | |
166 | + | |
167 | + const char *extern_f_14_1 = "Intel(R) Fortran Intel(R) 64 Compiler \ | |
168 | +XE for applications running on Intel(R) 64, Version \ | |
169 | +14.0.1.074 Build 20130716"; | |
170 | + | |
171 | + bool retval = producer_is_icc (extern_f_14_1, &major, &minor); | |
172 | + SELF_CHECK (retval == 1 && major == 14 && minor == 1); | |
173 | + retval = producer_is_gcc (extern_f_14_1, &major, &minor); | |
174 | + SELF_CHECK (retval == 0); | |
175 | + | |
176 | + const char *intern_f_14 = "Intel(R) Fortran Intel(R) 64 Compiler \ | |
177 | +XE for applications running on Intel(R) 64, Version \ | |
178 | +14.0"; | |
179 | + | |
180 | + major = 0; | |
181 | + minor = 0; | |
182 | + retval = producer_is_icc (intern_f_14, &major, &minor); | |
183 | + SELF_CHECK (retval == 1 && major == 14 && minor == 0); | |
184 | + retval = producer_is_gcc (intern_f_14, &major, &minor); | |
185 | + SELF_CHECK (retval == 0); | |
186 | + | |
187 | + const char *intern_c_14 = "Intel(R) C++ Intel(R) 64 Compiler \ | |
188 | +XE for applications running on Intel(R) 64, Version \ | |
189 | +14.0"; | |
190 | + major = 0; | |
191 | + minor = 0; | |
192 | + retval = producer_is_icc (intern_c_14, &major, &minor); | |
193 | + SELF_CHECK (retval == 1 && major == 14 && minor == 0); | |
194 | + retval = producer_is_gcc (intern_c_14, &major, &minor); | |
195 | + SELF_CHECK (retval == 0); | |
196 | + | |
197 | + const char *intern_c_18 = "Intel(R) C++ Intel(R) 64 Compiler \ | |
198 | +for applications running on Intel(R) 64, Version 18.0 Beta"; | |
199 | + major = 0; | |
200 | + minor = 0; | |
201 | + retval = producer_is_icc (intern_c_18, &major, &minor); | |
202 | + SELF_CHECK (retval == 1 && major == 18 && minor == 0); | |
203 | + | |
204 | + const char *gnu = "GNU C 4.7.2"; | |
205 | + major = 0; | |
206 | + minor = 0; | |
207 | + retval = producer_is_icc (gnu, &major, &minor); | |
208 | + SELF_CHECK (retval == 0); | |
209 | + retval = producer_is_gcc (gnu, &major, &minor); | |
210 | + SELF_CHECK (retval == 1 && major == 4 && minor == 7); | |
211 | + | |
212 | + const char *gnu_exp ="GNU C++14 5.0.0 20150123 (experimental)"; | |
213 | + major = 0; | |
214 | + minor = 0; | |
215 | + retval = producer_is_icc (gnu_exp, &major, &minor); | |
216 | + SELF_CHECK (retval == 0); | |
217 | + retval = producer_is_gcc (gnu_exp, &major, &minor); | |
218 | + SELF_CHECK (retval == 1 && major == 5 && minor == 0); | |
219 | +} | |
220 | +} | |
221 | +} | |
222 | +#endif | |
223 | + | |
224 | + | |
225 | + | |
226 | +/* Provide a prototype to silence -Wmissing-prototypes. */ | |
227 | +extern initialize_file_ftype _initialize_dwarf2utils; | |
228 | + | |
229 | +void | |
230 | +_initialize_dwarf2utils (void) | |
231 | +{ | |
232 | +#if defined GDB_SELF_TEST | |
233 | + selftests::register_test (selftests::dwarf2utils::dwarf_producer_test); | |
234 | +#endif | |
235 | +} |
@@ -25,4 +25,7 @@ extern int producer_is_gcc_ge_4 (const char *producer); | ||
25 | 25 | /* See documentation in the utils.c file. */ |
26 | 26 | extern int producer_is_gcc (const char *producer, int *major, int *minor); |
27 | 27 | |
28 | +/* See documentation in the utils.c file. */ | |
29 | +extern bool producer_is_icc (const char *producer, int *major, int *minor); | |
30 | + | |
28 | 31 | #endif |
@@ -2945,6 +2945,7 @@ make_bpstat_clear_actions_cleanup (void) | ||
2945 | 2945 | } |
2946 | 2946 | |
2947 | 2947 | |
2948 | + | |
2948 | 2949 | /* Helper for make_cleanup_free_char_ptr_vec. */ |
2949 | 2950 | |
2950 | 2951 | static void |