aboutsummaryrefslogtreecommitdiff
path: root/gdb/producer.c
diff options
context:
space:
mode:
authorFelix Willgerodt <felix.willgerodt@intel.com>2021-04-08 09:15:58 +0200
committerFelix Willgerodt <felix.willgerodt@intel.com>2021-04-08 09:18:55 +0200
commitfbb3bcfcd8810ecf25a47e71c2f7d46d7a74a6be (patch)
tree85085533c98238fa8634419f6ac92bb902ba414c /gdb/producer.c
parent05385fc777d642f4cf3455fc7e0b26faafa4e0f6 (diff)
downloadgdb-fbb3bcfcd8810ecf25a47e71c2f7d46d7a74a6be.zip
gdb-fbb3bcfcd8810ecf25a47e71c2f7d46d7a74a6be.tar.gz
gdb-fbb3bcfcd8810ecf25a47e71c2f7d46d7a74a6be.tar.bz2
gdb: Update producer check for Intel compilers.
The main goal of this patch is to get rid of a warning for the new Fortran compiler: (gdb) b 9 warning: Could not recognize version of Intel Compiler in: "Intel(R) Fortran 21.0-2087b" Breakpoint 1 at 0x4048cf: file comp.f90, line 9. While trying to fix this I analyzed DW_AT_producer of all latest Intel compilers for C, C++ and Fortran. They do no longer necessarily start with "Intel (R)" nor do they follow the internal and external version number scheme that the original patch for this check assumed. Some newer compilers even contradict the "intermediate" digit in the old version scheme and have the MINOR number as the second digit, even when having 3 or 4 digits overall. Therefore I rewrote the check to consider the first MAJOR.MINOR string found as the version number. This might not be 100% correct for some older internal compilers, but the only current user of this function is only checking for the major version anyway. Hence this should be reliable enough and extendable enough going forward. gdb/ChangeLog: 2021-04-08 Felix Willgerodt <felix.willgerodt@intel.com> * producer.c: (producer_is_icc): Update for new version scheme. (producer_parsing_tests): Update names and expected results. * producer.h: (producer_is_icc): Update comment accordingly.
Diffstat (limited to 'gdb/producer.c')
-rw-r--r--gdb/producer.c51
1 files changed, 16 insertions, 35 deletions
diff --git a/gdb/producer.c b/gdb/producer.c
index fcfd7b9..1cda48c 100644
--- a/gdb/producer.c
+++ b/gdb/producer.c
@@ -20,6 +20,7 @@
#include "defs.h"
#include "producer.h"
#include "gdbsupport/selftest.h"
+#include <regex>
/* See producer.h. */
@@ -78,50 +79,30 @@ producer_is_gcc (const char *producer, int *major, int *minor)
bool
producer_is_icc (const char *producer, int *major, int *minor)
{
- if (producer == NULL || !startswith (producer, "Intel(R)"))
+ std::regex i_re ("Intel\\(R\\)");
+ std::cmatch i_m;
+ if ((producer == nullptr) || !std::regex_search (producer, i_m, i_re))
return false;
/* Prepare the used fields. */
int maj, min;
- if (major == NULL)
+ if (major == nullptr)
major = &maj;
- if (minor == NULL)
+ if (minor == nullptr)
minor = &min;
*minor = 0;
*major = 0;
- /* Consumes the string till a "Version" is found. */
- const char *cs = strstr (producer, "Version");
- if (cs != NULL)
- {
- cs = skip_to_space (cs);
-
- int intermediate = 0;
- int nof = sscanf (cs, "%d.%d.%d.%*d", major, &intermediate, minor);
-
- /* Internal versions are represented only as MAJOR.MINOR, where
- minor is usually 0.
- Public versions have 3 fields as described with the command
- above. */
- if (nof == 3)
- return true;
-
- if (nof == 2)
- {
- *minor = intermediate;
- return true;
- }
- }
+ std::regex re ("[0-9]+\\.[0-9]+");
+ std::cmatch version;
- static bool warning_printed = false;
- /* Not recognized as Intel, let the user know. */
- if (!warning_printed)
+ if (std::regex_search (producer, version, re))
{
- warning (_("Could not recognize version of Intel Compiler in: \"%s\""),
- producer);
- warning_printed = true;
+ sscanf (version.str ().c_str (), "%d.%d", major, minor);
+ return true;
}
+
return false;
}
@@ -152,15 +133,15 @@ producer_parsing_tests ()
}
{
- static const char extern_f_14_1[] = "\
+ static const char extern_f_14_0[] = "\
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on \
Intel(R) 64, \
Version 14.0.1.074 Build 20130716";
int major = 0, minor = 0;
- SELF_CHECK (producer_is_icc (extern_f_14_1, &major, &minor)
- && major == 14 && minor == 1);
- SELF_CHECK (!producer_is_gcc (extern_f_14_1, &major, &minor));
+ SELF_CHECK (producer_is_icc (extern_f_14_0, &major, &minor)
+ && major == 14 && minor == 0);
+ SELF_CHECK (!producer_is_gcc (extern_f_14_0, &major, &minor));
}
{