Commit 69377f0d authored by Ulf Hermann's avatar Ulf Hermann

Introduce Profile build mode

We define a Profile build to be a Release build with separate debug
info. You can thus change a given build from Release to Profile of vice
versa by toggling the separate debug info checkbox. The messaging for
future user interaction about Profile builds has to take this into
account.

Task-number: QTCREATORBUG-14009
Change-Id: I62a5b13993b20bf36329b1eefa8b1b6096f31644
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 703ce02d
...@@ -70,15 +70,15 @@ bool AnalyzerAction::isRunnable(QString *reason) const ...@@ -70,15 +70,15 @@ bool AnalyzerAction::isRunnable(QString *reason) const
return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), m_runMode, reason); return ProjectExplorerPlugin::canRun(SessionManager::startupProject(), m_runMode, reason);
} }
static bool buildTypeAccepted(ToolMode toolMode, BuildConfiguration::BuildType buildType) static bool buildTypeAccepted(QFlags<ToolMode> toolMode, BuildConfiguration::BuildType buildType)
{ {
if (toolMode == AnyMode)
return true;
if (buildType == BuildConfiguration::Unknown) if (buildType == BuildConfiguration::Unknown)
return true; return true;
if (buildType == BuildConfiguration::Debug && toolMode == DebugMode) if (buildType == BuildConfiguration::Debug && (toolMode & DebugMode))
return true;
if (buildType == BuildConfiguration::Release && (toolMode & ReleaseMode))
return true; return true;
if (buildType == BuildConfiguration::Release && toolMode == ReleaseMode) if (buildType == BuildConfiguration::Profile && (toolMode & ProfileMode))
return true; return true;
return false; return false;
} }
...@@ -114,17 +114,37 @@ void AnalyzerAction::startTool() ...@@ -114,17 +114,37 @@ void AnalyzerAction::startTool()
// Check the project for whether the build config is in the correct mode // Check the project for whether the build config is in the correct mode
// if not, notify the user and urge him to use the correct mode. // if not, notify the user and urge him to use the correct mode.
if (!buildTypeAccepted(m_toolMode, buildType)) { if (!buildTypeAccepted(m_toolMode, buildType)) {
const QString currentMode = buildType == BuildConfiguration::Debug QString currentMode;
? AnalyzerManager::tr("Debug") switch (buildType) {
: AnalyzerManager::tr("Release"); case BuildConfiguration::Debug:
currentMode = AnalyzerManager::tr("Debug");
break;
case BuildConfiguration::Profile:
currentMode = AnalyzerManager::tr("Profile");
break;
case BuildConfiguration::Release:
currentMode = AnalyzerManager::tr("Release");
break;
default:
QTC_CHECK(false);
}
QString toolModeString; QString toolModeString;
switch (m_toolMode) { switch (m_toolMode) {
case DebugMode: case DebugMode:
toolModeString = AnalyzerManager::tr("Debug"); toolModeString = AnalyzerManager::tr("in Debug mode");
break;
case ProfileMode:
toolModeString = AnalyzerManager::tr("in Profile mode");
break; break;
case ReleaseMode: case ReleaseMode:
toolModeString = AnalyzerManager::tr("Release"); toolModeString = AnalyzerManager::tr("in Release mode");
break;
case SymbolsMode:
toolModeString = AnalyzerManager::tr("with debug symbols (Debug or Profile mode)");
break;
case OptimizedMode:
toolModeString = AnalyzerManager::tr("on optimized code (Profile or Release mode)");
break; break;
default: default:
QTC_CHECK(false); QTC_CHECK(false);
...@@ -133,10 +153,14 @@ void AnalyzerAction::startTool() ...@@ -133,10 +153,14 @@ void AnalyzerAction::startTool()
const QString title = AnalyzerManager::tr("Run %1 in %2 Mode?").arg(toolName).arg(currentMode); const QString title = AnalyzerManager::tr("Run %1 in %2 Mode?").arg(toolName).arg(currentMode);
const QString message = AnalyzerManager::tr("<html><head/><body><p>You are trying " const QString message = AnalyzerManager::tr("<html><head/><body><p>You are trying "
"to run the tool \"%1\" on an application in %2 mode. " "to run the tool \"%1\" on an application in %2 mode. "
"The tool is designed to be used in %3 mode.</p><p>" "The tool is designed to be used %3.</p><p>"
"Debug and Release mode run-time characteristics differ " "Run-time characteristics differ significantly between "
"significantly, analytical findings for one mode may or " "optimized and non-optimized binaries. Analytical "
"may not be relevant for the other.</p><p>" "findings for one mode may or may not be relevant for "
"the other.</p><p>"
"Running tools that need debug symbols on binaries that "
"don't provide any may lead to missing function names "
"or otherwise insufficient output.</p><p>"
"Do you want to continue and run the tool in %2 mode?</p></body></html>") "Do you want to continue and run the tool in %2 mode?</p></body></html>")
.arg(toolName).arg(currentMode).arg(toolModeString); .arg(toolName).arg(currentMode).arg(toolModeString);
if (Utils::CheckableMessageBox::doNotAskAgainQuestion(ICore::mainWindow(), if (Utils::CheckableMessageBox::doNotAskAgainQuestion(ICore::mainWindow(),
......
...@@ -53,15 +53,20 @@ class AnalyzerRunControl; ...@@ -53,15 +53,20 @@ class AnalyzerRunControl;
/** /**
* The mode in which this tool should preferably be run * The mode in which this tool should preferably be run
* *
* The memcheck tool, for example, requires debug symbols, hence DebugMode * Debugging tools which try to show stack traces as close as possible to what the source code
* is preferred. On the other hand, callgrind should look at optimized code, * looks like will prefer SymbolsMode. Profiling tools which need optimized code for realistic
* hence ReleaseMode. * performance, but still want to show analytical output that depends on debug symbols, will prefer
* ProfileMode.
*/ */
enum ToolMode { enum ToolMode {
DebugMode, DebugMode = 0x1,
ReleaseMode, ProfileMode = 0x2,
AnyMode ReleaseMode = 0x4,
SymbolsMode = DebugMode | ProfileMode,
OptimizedMode = ProfileMode | ReleaseMode,
AnyMode = DebugMode | ProfileMode | ReleaseMode
}; };
Q_DECLARE_FLAGS(ToolModes, ToolMode)
/** /**
* This class represents an analyzation action, i.e. a tool that runs in a specific mode. * This class represents an analyzation action, i.e. a tool that runs in a specific mode.
...@@ -84,7 +89,7 @@ public: ...@@ -84,7 +89,7 @@ public:
Core::Id toolId() const { return m_toolId; } Core::Id toolId() const { return m_toolId; }
void setToolId(Core::Id id) { m_toolId = id; } void setToolId(Core::Id id) { m_toolId = id; }
void setToolMode(ToolMode mode) { m_toolMode = mode; } void setToolMode(QFlags<ToolMode> mode) { m_toolMode = mode; }
Core::Id runMode() const { return m_runMode; } Core::Id runMode() const { return m_runMode; }
void setRunMode(Core::Id mode) { m_runMode = mode; } void setRunMode(Core::Id mode) { m_runMode = mode; }
...@@ -118,7 +123,7 @@ protected: ...@@ -118,7 +123,7 @@ protected:
Core::Id m_menuGroup; Core::Id m_menuGroup;
Core::Id m_actionId; Core::Id m_actionId;
Core::Id m_toolId; Core::Id m_toolId;
ToolMode m_toolMode; QFlags<ToolMode> m_toolMode;
Core::Id m_runMode; Core::Id m_runMode;
WidgetCreator m_widgetCreator; WidgetCreator m_widgetCreator;
RunControlCreator m_runControlCreator; RunControlCreator m_runControlCreator;
......
...@@ -114,8 +114,9 @@ bool AndroidBuildApkStep::init() ...@@ -114,8 +114,9 @@ bool AndroidBuildApkStep::init()
} }
if (bc->buildType() == ProjectExplorer::BuildConfiguration::Debug) if (bc->buildType() != ProjectExplorer::BuildConfiguration::Release)
emit addOutput(tr("Warning: Signing a debug package."), BuildStep::ErrorMessageOutput); emit addOutput(tr("Warning: Signing a debug or profile package."),
BuildStep::ErrorMessageOutput);
} }
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
......
...@@ -237,8 +237,9 @@ void AndroidBuildApkWidget::verboseOutputCheckBoxToggled(bool checked) ...@@ -237,8 +237,9 @@ void AndroidBuildApkWidget::verboseOutputCheckBoxToggled(bool checked)
void AndroidBuildApkWidget::updateSigningWarning() void AndroidBuildApkWidget::updateSigningWarning()
{ {
bool debug = m_step->buildConfiguration()->buildType() == ProjectExplorer::BuildConfiguration::Debug; bool nonRelease = m_step->buildConfiguration()->buildType()
if (m_step->signPackage() && debug) { != ProjectExplorer::BuildConfiguration::Release;
if (m_step->signPackage() && nonRelease) {
m_ui->signingDebugWarningIcon->setVisible(true); m_ui->signingDebugWarningIcon->setVisible(true);
m_ui->signingDebugWarningLabel->setVisible(true); m_ui->signingDebugWarningLabel->setVisible(true);
} else { } else {
......
...@@ -345,14 +345,13 @@ ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildTyp ...@@ -345,14 +345,13 @@ ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildTyp
// Cover all common CMake build types // Cover all common CMake build types
if (cmakeBuildType.compare(QLatin1String("Release"), Qt::CaseInsensitive) == 0 if (cmakeBuildType.compare(QLatin1String("Release"), Qt::CaseInsensitive) == 0
|| cmakeBuildType.compare(QLatin1String("MinSizeRel"), Qt::CaseInsensitive) == 0) || cmakeBuildType.compare(QLatin1String("MinSizeRel"), Qt::CaseInsensitive) == 0) {
{
return Release; return Release;
} else if (cmakeBuildType.compare(QLatin1String("Debug"), Qt::CaseInsensitive) == 0 } else if (cmakeBuildType.compare(QLatin1String("Debug"), Qt::CaseInsensitive) == 0
|| cmakeBuildType.compare(QLatin1String("DebugFull"), Qt::CaseInsensitive) == 0 || cmakeBuildType.compare(QLatin1String("DebugFull"), Qt::CaseInsensitive) == 0) {
|| cmakeBuildType.compare(QLatin1String("RelWithDebInfo"), Qt::CaseInsensitive) == 0)
{
return Debug; return Debug;
} else if (cmakeBuildType.compare(QLatin1String("RelWithDebInfo"), Qt::CaseInsensitive) == 0) {
return Profile;
} }
return Unknown; return Unknown;
......
...@@ -187,6 +187,7 @@ QStringList IosBuildStep::defaultArguments() const ...@@ -187,6 +187,7 @@ QStringList IosBuildStep::defaultArguments() const
res << QLatin1String("-configuration") << QLatin1String("Debug"); res << QLatin1String("-configuration") << QLatin1String("Debug");
break; break;
case BuildConfiguration::Release : case BuildConfiguration::Release :
case BuildConfiguration::Profile :
res << QLatin1String("-configuration") << QLatin1String("Release"); res << QLatin1String("-configuration") << QLatin1String("Release");
break; break;
case BuildConfiguration::Unknown : case BuildConfiguration::Unknown :
......
...@@ -244,6 +244,7 @@ FileName IosRunConfiguration::bundleDirectory() const ...@@ -244,6 +244,7 @@ FileName IosRunConfiguration::bundleDirectory() const
else else
res.appendPath(QLatin1String("Debug-iphonesimulator")); res.appendPath(QLatin1String("Debug-iphonesimulator"));
break; break;
case BuildConfiguration::Profile :
case BuildConfiguration::Release : case BuildConfiguration::Release :
if (isDevice) if (isDevice)
res.appendPath(QLatin1String("Release-iphoneos")); res.appendPath(QLatin1String("Release-iphoneos"));
......
...@@ -86,6 +86,7 @@ public: ...@@ -86,6 +86,7 @@ public:
enum BuildType { enum BuildType {
Unknown, Unknown,
Debug, Debug,
Profile,
Release Release
}; };
virtual BuildType buildType() const = 0; virtual BuildType buildType() const = 0;
......
...@@ -1377,6 +1377,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er ...@@ -1377,6 +1377,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
return tr("debug"); return tr("debug");
if (type == BuildConfiguration::Release) if (type == BuildConfiguration::Release)
return tr("release"); return tr("release");
if (type == BuildConfiguration::Profile)
return tr("profile");
} }
return tr("unknown"); return tr("unknown");
}); });
......
...@@ -445,9 +445,9 @@ BuildConfiguration *QbsBuildConfigurationFactory::create(Target *parent, const B ...@@ -445,9 +445,9 @@ BuildConfiguration *QbsBuildConfigurationFactory::create(Target *parent, const B
QVariantMap configData; QVariantMap configData;
configData.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY), configData.insert(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY),
(qbsInfo->type == BuildConfiguration::Release) (qbsInfo->type == BuildConfiguration::Debug)
? QLatin1String(Constants::QBS_VARIANT_RELEASE) ? QLatin1String(Constants::QBS_VARIANT_DEBUG)
: QLatin1String(Constants::QBS_VARIANT_DEBUG)); : QLatin1String(Constants::QBS_VARIANT_RELEASE));
Utils::FileName buildDir = info->buildDirectory; Utils::FileName buildDir = info->buildDirectory;
if (buildDir.isEmpty()) if (buildDir.isEmpty())
......
...@@ -97,6 +97,7 @@ static Utils::FileName defaultBuildDirectory(const QString &projectPath, ...@@ -97,6 +97,7 @@ static Utils::FileName defaultBuildDirectory(const QString &projectPath,
const char QMAKE_BC_ID[] = "Qt4ProjectManager.Qt4BuildConfiguration"; const char QMAKE_BC_ID[] = "Qt4ProjectManager.Qt4BuildConfiguration";
const char USE_SHADOW_BUILD_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"; const char USE_SHADOW_BUILD_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild";
const char BUILD_CONFIGURATION_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration"; const char BUILD_CONFIGURATION_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration";
const char PROFILE_BUILD_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration.ProfileBuild";
enum { debug = 0 }; enum { debug = 0 };
...@@ -566,10 +567,18 @@ QmakeBuildInfo *QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k, ...@@ -566,10 +567,18 @@ QmakeBuildInfo *QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
//: Non-ASCII characters in directory suffix may cause build issues. //: Non-ASCII characters in directory suffix may cause build issues.
suffix = tr("Release", "Shadow build directory suffix"); suffix = tr("Release", "Shadow build directory suffix");
} else { } else {
//: The name of the debug build configuration created by default for a qmake project. if (type == BuildConfiguration::Debug) {
info->displayName = tr("Debug"); //: The name of the debug build configuration created by default for a qmake project.
//: Non-ASCII characters in directory suffix may cause build issues. info->displayName = tr("Debug");
suffix = tr("Debug", "Shadow build directory suffix"); //: Non-ASCII characters in directory suffix may cause build issues.
suffix = tr("Debug", "Shadow build directory suffix");
} else if (type == BuildConfiguration::Profile) {
//: The name of the profile build configuration created by default for a qmake project.
info->displayName = tr("Profile");
//: Non-ASCII characters in directory suffix may cause build issues.
suffix = tr("Profile", "Shadow build directory suffix");
info->config.separateDebugInfo = true;
}
if (version && version->qtVersion().majorVersion >= 5) if (version && version->qtVersion().majorVersion >= 5)
info->config.linkQmlDebuggingQQ2 = true; info->config.linkQmlDebuggingQQ2 = true;
} }
...@@ -607,6 +616,7 @@ QList<BuildInfo *> QmakeBuildConfigurationFactory::availableBuilds(const Target ...@@ -607,6 +616,7 @@ QList<BuildInfo *> QmakeBuildConfigurationFactory::availableBuilds(const Target
const QString projectFilePath = parent->project()->projectFilePath().toString(); const QString projectFilePath = parent->project()->projectFilePath().toString();
for (BuildConfiguration::BuildType buildType : { BuildConfiguration::Debug, for (BuildConfiguration::BuildType buildType : { BuildConfiguration::Debug,
BuildConfiguration::Profile,
BuildConfiguration::Release }) { BuildConfiguration::Release }) {
QmakeBuildInfo *info = createBuildInfo(parent->kit(), projectFilePath, QmakeBuildInfo *info = createBuildInfo(parent->kit(), projectFilePath,
buildType); buildType);
...@@ -633,6 +643,7 @@ QList<BuildInfo *> QmakeBuildConfigurationFactory::availableSetups(const Kit *k, ...@@ -633,6 +643,7 @@ QList<BuildInfo *> QmakeBuildConfigurationFactory::availableSetups(const Kit *k,
if (!qtVersion || !qtVersion->isValid()) if (!qtVersion || !qtVersion->isValid())
return result; return result;
result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Debug); result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Debug);
result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Profile);
result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Release); result << createBuildInfo(k, projectPath, ProjectExplorer::BuildConfiguration::Release);
return result; return result;
} }
...@@ -644,10 +655,10 @@ void QmakeBuildConfigurationFactory::configureBuildConfiguration(Target *parent, ...@@ -644,10 +655,10 @@ void QmakeBuildConfigurationFactory::configureBuildConfiguration(Target *parent,
BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(parent->kit()); BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(parent->kit());
BaseQtVersion::QmakeBuildConfigs config = version->defaultBuildConfig(); BaseQtVersion::QmakeBuildConfigs config = version->defaultBuildConfig();
if (qmakeInfo->type == BuildConfiguration::Release) if (qmakeInfo->type == BuildConfiguration::Debug)
config &= ~QtSupport::BaseQtVersion::DebugBuild;
else
config |= QtSupport::BaseQtVersion::DebugBuild; config |= QtSupport::BaseQtVersion::DebugBuild;
else
config &= ~QtSupport::BaseQtVersion::DebugBuild;
bc->setDefaultDisplayName(qmakeInfo->displayName); bc->setDefaultDisplayName(qmakeInfo->displayName);
bc->setDisplayName(qmakeInfo->displayName); bc->setDisplayName(qmakeInfo->displayName);
...@@ -733,6 +744,8 @@ BuildConfiguration::BuildType QmakeBuildConfiguration::buildType() const ...@@ -733,6 +744,8 @@ BuildConfiguration::BuildType QmakeBuildConfiguration::buildType() const
{ {
if (qmakeBuildConfiguration() & BaseQtVersion::DebugBuild) if (qmakeBuildConfiguration() & BaseQtVersion::DebugBuild)
return Debug; return Debug;
else if (qmakeStep()->separateDebugInfo())
return Profile;
else else
return Release; return Release;
} }
......
...@@ -164,7 +164,7 @@ void ValgrindPlugin::extensionsInitialized() ...@@ -164,7 +164,7 @@ void ValgrindPlugin::extensionsInitialized()
action->setToolId("Memcheck"); action->setToolId("Memcheck");
action->setWidgetCreator(mcWidgetCreator); action->setWidgetCreator(mcWidgetCreator);
action->setRunControlCreator(mcRunControlCreator); action->setRunControlCreator(mcRunControlCreator);
action->setToolMode(DebugMode); action->setToolMode(SymbolsMode);
action->setRunMode(MEMCHECK_RUN_MODE); action->setRunMode(MEMCHECK_RUN_MODE);
action->setText(tr("Valgrind Memory Analyzer")); action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(memcheckToolTip); action->setToolTip(memcheckToolTip);
...@@ -180,7 +180,7 @@ void ValgrindPlugin::extensionsInitialized() ...@@ -180,7 +180,7 @@ void ValgrindPlugin::extensionsInitialized()
action->setWidgetCreator([mcgTool] { return mcgTool->createWidgets(); }); action->setWidgetCreator([mcgTool] { return mcgTool->createWidgets(); });
action->setRunControlCreator(std::bind(&MemcheckWithGdbTool::createRunControl, action->setRunControlCreator(std::bind(&MemcheckWithGdbTool::createRunControl,
mcgTool, _1, _2)); mcgTool, _1, _2));
action->setToolMode(DebugMode); action->setToolMode(SymbolsMode);
action->setRunMode(MEMCHECK_WITH_GDB_RUN_MODE); action->setRunMode(MEMCHECK_WITH_GDB_RUN_MODE);
action->setText(tr("Valgrind Memory Analyzer with GDB")); action->setText(tr("Valgrind Memory Analyzer with GDB"));
action->setToolTip(tr("Valgrind Analyze Memory with GDB uses the " action->setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
...@@ -195,7 +195,7 @@ void ValgrindPlugin::extensionsInitialized() ...@@ -195,7 +195,7 @@ void ValgrindPlugin::extensionsInitialized()
action->setToolId(CallgrindToolId); action->setToolId(CallgrindToolId);
action->setWidgetCreator(cgWidgetCreator); action->setWidgetCreator(cgWidgetCreator);
action->setRunControlCreator(cgRunControlCreator); action->setRunControlCreator(cgRunControlCreator);
action->setToolMode(ReleaseMode); action->setToolMode(OptimizedMode);
action->setRunMode(CALLGRIND_RUN_MODE); action->setRunMode(CALLGRIND_RUN_MODE);
action->setText(tr("Valgrind Function Profiler")); action->setText(tr("Valgrind Function Profiler"));
action->setToolTip(callgrindToolTip); action->setToolTip(callgrindToolTip);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment