• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision3f772b18309e448aaa253f8e441e4cdd7786257e (tree)
Zeit2017-09-20 22:24:38
AutorWalfred Tedeschi <walfred.tedeschi@yaho...>
CommiterWalfred Tedeschi

Log Message

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>

Ändern Zusammenfassung

Diff

--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -82,6 +82,8 @@
8282 #include <unordered_set>
8383 #include <unordered_map>
8484
85+
86+
8587 typedef struct symbol *symbolp;
8688 DEF_VEC_P (symbolp);
8789
@@ -603,7 +605,7 @@ struct dwarf2_cu
603605 unsigned int checked_producer : 1;
604606 unsigned int producer_is_gxx_lt_4_6 : 1;
605607 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;
607609
608610 /* When set, the file that we're processing is known to have
609611 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)
93489350 &objfile->objfile_obstack);
93499351 }
93509352
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+
93519366 /* Check for possibly missing DW_AT_comp_dir with relative .debug_line
93529367 directory paths. GCC SVN r127613 (new option -fdebug-prefix-map) fixed
93539368 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,
1282912844 }
1283012845 }
1283112846
12847+
12848+
12849+
1283212850 /* Check whether the producer field indicates either of GCC < 4.6, or the
1283312851 Intel C/C++ compiler, and cache the result in CU. */
1283412852
@@ -12853,8 +12871,10 @@ check_producer (struct dwarf2_cu *cu)
1285312871 cu->producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6);
1285412872 cu->producer_is_gcc_lt_4_3 = major < 4 || (major == 4 && minor < 3);
1285512873 }
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+ }
1285812878 else
1285912879 {
1286012880 /* 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)
1359513615 smash_to_methodptr_type (type, new_type);
1359613616 }
1359713617
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-}
1360913618
1361013619 /* Called when we find the DIE that starts a structure or union scope
1361113620 (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)
1371113720 TYPE_LENGTH (type) = 0;
1371213721 }
1371313722
13714- if (producer_is_icc (cu) && (TYPE_LENGTH (type) == 0))
13723+ if (producer_is_icc_lt_14 (cu) && (TYPE_LENGTH (type) == 0))
1371513724 {
1371613725 /* ICC does not output the required DW_AT_declaration
1371713726 on incomplete types, but gives them a size of zero. */
--- a/gdb/dwarf2utils.c
+++ b/gdb/dwarf2utils.c
@@ -31,6 +31,9 @@
3131 #include "common/common-exceptions.h"
3232 #include "common/common-utils.h"
3333
34+#if defined GDB_SELF_TEST
35+#include "selftest.h"
36+#endif
3437
3538 #include "utils.h"
3639
@@ -84,3 +87,149 @@ producer_is_gcc (const char *producer, int *major, int *minor)
8487 /* Not recognized as GCC. */
8588 return 0;
8689 }
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+}
--- a/gdb/dwarf2utils.h
+++ b/gdb/dwarf2utils.h
@@ -25,4 +25,7 @@ extern int producer_is_gcc_ge_4 (const char *producer);
2525 /* See documentation in the utils.c file. */
2626 extern int producer_is_gcc (const char *producer, int *major, int *minor);
2727
28+/* See documentation in the utils.c file. */
29+extern bool producer_is_icc (const char *producer, int *major, int *minor);
30+
2831 #endif
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2945,6 +2945,7 @@ make_bpstat_clear_actions_cleanup (void)
29452945 }
29462946
29472947
2948+
29482949 /* Helper for make_cleanup_free_char_ptr_vec. */
29492950
29502951 static void