From: Jonathan Lebon Date: Thu, 27 Feb 2014 19:43:11 +0000 (-0500) Subject: dwflpp/prologue: fix DW_AT_producer parsing X-Git-Tag: release-2.5~240 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=7db8343aa7b1e6c5d5fd7c25cd95f6b72e5b2931;p=systemtap.git dwflpp/prologue: fix DW_AT_producer parsing --- diff --git a/dwflpp.cxx b/dwflpp.cxx index bf40a278b..280e5241d 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -2081,23 +2081,27 @@ dwflpp::resolve_prologue_endings (func_info_map_t & funcs) Dwarf_Attribute producer_attr; if (dwarf_attr_integrate(cu, DW_AT_producer, &producer_attr)) { - // GNU C x.x.x YYYYMMDD ... + // GNU C[++] x.x.x YYYYMMDD ... const char* producer = dwarf_formstring(&producer_attr); const char* gnuc = strstr(producer, "GNU C"); if (gnuc) { - string version; - - // skip to the version number - gnuc += 6; + // skip over GNU C[++] + gnuc += 4; // skip to C const char *space = strchr(gnuc, ' '); - if (!space) - version.assign(gnuc); - else - version.assign(gnuc, space-gnuc); - - if (strverscmp(version.c_str(), "4.4.0") < 0) - consider_decl_line = true; + if (space && *(space+1) != '\0') + { + string version; + const char* vers = space+1; + space = strchr(vers, ' '); + if (!space) + version.assign(vers); + else + version.assign(vers, space-vers); + + if (strverscmp(version.c_str(), "4.4.0") < 0) + consider_decl_line = true; + } } }