1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
35 #include "projectexplorerconstants.h"
36 #include "taskwindow.h"
38 #include <QtCore/QDir>
40 using namespace ProjectExplorer;
43 // opt. drive letter + filename: (2 brackets)
44 const char * const FILE_PATTERN = "(([A-Za-z]:)?[^:]+\\.[^:]+):";
45 // line no. or elf segment + offset: (1 bracket)
46 const char * const POSITION_PATTERN = "(\\d+|\\(\\.[a-zA-Z0-9]*.0x[a-fA-F0-9]+\\)):";
47 const char * const COMMAND_PATTERN = "^(.*[\\\\/])?([a-z0-9]+-[a-z0-9]+-[a-z0-9]+-)?(ld|gold)(-[0-9\\.]+)?(\\.exe)?: ";
52 setObjectName(QLatin1String("LdParser"));
53 m_regExpLinker.setPattern(QString('^') +
54 QString::fromLatin1(FILE_PATTERN) + '(' +
55 QString::fromLatin1(FILE_PATTERN) + ")?(" +
56 QLatin1String(POSITION_PATTERN) + ")?\\s(.+)$");
57 m_regExpLinker.setMinimal(true);
59 m_regExpGccNames.setPattern(COMMAND_PATTERN);
60 m_regExpGccNames.setMinimal(true);
62 m_regExpInFunction.setPattern("^In (static |member )*function ");
63 m_regExpInFunction.setMinimal(true);
66 void LdParser::stdError(const QString &line)
68 QString lne = line.trimmed();
69 if (lne.startsWith(QLatin1String("TeamBuilder ")) ||
70 lne.startsWith(QLatin1String("distcc["))) {
71 IOutputParser::stdError(line);
75 if (lne.startsWith(QLatin1String("collect2:"))) {
76 emit addTask(Task(Task::Error,
77 lne /* description */,
78 QString() /* filename */,
80 Constants::TASK_CATEGORY_COMPILE));
82 } else if (m_regExpGccNames.indexIn(lne) > -1) {
83 QString description = lne.mid(m_regExpGccNames.matchedLength());
84 Task task(Task::Error,
86 QString(), /* filename */
88 Constants::TASK_CATEGORY_COMPILE);
89 if (description.startsWith(QLatin1String("warning: "))) {
90 task.type = Task::Warning;
91 task.description = description.mid(9);
92 } else if (description.startsWith(QLatin1String("fatal: "))) {
93 task.description = description.mid(7);
97 } else if (m_regExpLinker.indexIn(lne) > -1) {
99 int lineno = m_regExpLinker.cap(7).toInt(&ok);
102 QString filename = m_regExpLinker.cap(1);
103 if (!m_regExpLinker.cap(4).isEmpty()
104 && !m_regExpLinker.cap(4).startsWith(QLatin1String("(.text+0x")))
105 filename = m_regExpLinker.cap(4);
106 QString description = m_regExpLinker.cap(8).trimmed();
107 Task task(Task::Error, description, QDir::fromNativeSeparators(filename), lineno,
108 Constants::TASK_CATEGORY_COMPILE);
109 if (m_regExpInFunction.indexIn(description) > -1 ||
110 description.startsWith(QLatin1String("At global scope")) ||
111 description.startsWith(QLatin1String("At top level")) ||
112 description.startsWith(QLatin1String("instantiated from ")) ||
113 description.startsWith(QLatin1String("In ")))
114 task.type = Task::Unknown;
119 IOutputParser::stdError(line);