Commit 9e67a945 authored by hjk's avatar hjk

Debugger: Use a somewhat less intrusive hack for 'start at main'

Change-Id: Ie649a4a11c88f3686cd6ed1e73f34c7c78fd0e13
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 5868c1e5
......@@ -74,7 +74,6 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
RunControl::registerWorker<AndroidRunConfiguration, AndroidRunSupport>(NORMAL_RUN_MODE);
RunControl::registerWorker<AndroidRunConfiguration, AndroidDebugSupport>(DEBUG_RUN_MODE);
RunControl::registerWorker<AndroidRunConfiguration, AndroidDebugSupport>(DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
RunControl::registerWorker<AndroidRunConfiguration, AndroidQmlProfilerSupport>(QML_PROFILER_RUN_MODE);
new AndroidConfigurations(this);
......
......@@ -280,9 +280,7 @@ AndroidRunnerWorker::AndroidRunnerWorker(RunControl *runControl, const AndroidRu
auto runConfig = runControl->runConfiguration();
auto aspect = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
Core::Id runMode = runControl->runMode();
const bool debuggingMode =
(runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE
|| runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
const bool debuggingMode = runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE;
m_useCppDebugger = debuggingMode && aspect->useCppDebugger();
if (debuggingMode && aspect->useQmlDebugger())
m_qmlDebugServices = QmlDebug::QmlDebuggerServices;
......
......@@ -80,8 +80,6 @@ bool BareMetalPlugin::initialize(const QStringList &arguments, QString *errorStr
(ProjectExplorer::Constants::NORMAL_RUN_MODE, constraint);
RunControl::registerWorker<BareMetalDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint);
RunControl::registerWorker<BareMetalDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, constraint);
return true;
}
......
......@@ -813,7 +813,8 @@ public:
void handleExecStep()
{
if (currentEngine()->state() == DebuggerNotReady) {
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
DebuggerRunTool::setBreakOnMainNextTime();
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
} else {
currentEngine()->resetLocation();
if (boolSetting(OperateByInstruction))
......@@ -826,7 +827,8 @@ public:
void handleExecNext()
{
if (currentEngine()->state() == DebuggerNotReady) {
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
DebuggerRunTool::setBreakOnMainNextTime();
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
} else {
currentEngine()->resetLocation();
if (boolSetting(OperateByInstruction))
......@@ -2742,19 +2744,16 @@ void DebuggerPluginPrivate::updateDebugActions()
// Step into/next: Start and break at 'main' unless a debugger is running.
if (m_snapshotHandler->currentIndex() < 0) {
QString toolTip;
const bool canRunAndBreakMain
= ProjectExplorerPlugin::canRunStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, &toolTip);
m_stepAction->setEnabled(canRunAndBreakMain);
m_nextAction->setEnabled(canRunAndBreakMain);
if (canRunAndBreakMain) {
m_stepAction->setEnabled(canRun);
m_nextAction->setEnabled(canRun);
if (canRun) {
Project *project = SessionManager::startupProject();
QTC_ASSERT(project, return);
toolTip = tr("Start \"%1\" and break at function \"main()\"")
.arg(project->displayName());
whyNot = tr("Start \"%1\" and break at function \"main()\"")
.arg(project->displayName());
}
m_stepAction->setToolTip(toolTip);
m_nextAction->setToolTip(toolTip);
m_stepAction->setToolTip(whyNot);
m_nextAction->setToolTip(whyNot);
}
}
......@@ -3064,8 +3063,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
RunControl::registerWorker<DebuggerRunTool>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint);
RunControl::registerWorker<DebuggerRunTool>
(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, constraint);
}
DebuggerEngine *currentEngine()
......
......@@ -73,9 +73,6 @@ enum { debug = 0 };
namespace Debugger {
namespace Internal {
const auto DebugRunMode = ProjectExplorer::Constants::DEBUG_RUN_MODE;
const auto DebugRunModeWithBreakOnMain = ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN;
DebuggerEngine *createCdbEngine(QStringList *error, DebuggerStartMode sm);
DebuggerEngine *createGdbEngine(bool useTerminal, DebuggerStartMode sm);
DebuggerEngine *createPdbEngine();
......@@ -86,6 +83,13 @@ DebuggerEngine *createLldbEngine();
} // namespace Internal
static bool breakOnMainNextTime = false;
void DebuggerRunTool::setBreakOnMainNextTime()
{
breakOnMainNextTime = true;
}
static QLatin1String engineTypeName(DebuggerEngineType et)
{
switch (et) {
......@@ -272,7 +276,6 @@ static bool fixupParameters(DebuggerRunParameters &rp, RunControl *runControl, Q
RunConfiguration *runConfig = runControl->runConfiguration();
if (!runConfig)
return false;
Core::Id runMode = runControl->runMode();
const Kit *kit = runConfig->target()->kit();
QTC_ASSERT(kit, return false);
......@@ -449,8 +452,10 @@ static bool fixupParameters(DebuggerRunParameters &rp, RunControl *runControl, Q
if (rp.startMode == NoStartMode)
rp.startMode = StartInternal;
if (runMode == DebugRunModeWithBreakOnMain)
if (breakOnMainNextTime) {
rp.breakOnMain = true;
breakOnMainNextTime = false;
}
return true;
}
......@@ -634,7 +639,7 @@ RunControl *createAndScheduleRun(const DebuggerRunParameters &rp, Kit *kit)
{
RunConfiguration *runConfig = dummyRunConfigForKit(kit);
QTC_ASSERT(runConfig, return nullptr);
auto runControl = new RunControl(runConfig, DebugRunMode);
auto runControl = new RunControl(runConfig, ProjectExplorer::Constants::DEBUG_RUN_MODE);
(void) new DebuggerRunTool(runControl, rp);
ProjectExplorerPlugin::startRunControl(runControl);
return runControl;
......
......@@ -79,6 +79,8 @@ public:
void appendSolibSearchPath(const QString &str);
static void setBreakOnMainNextTime();
signals:
void aboutToNotifyInferiorSetupOk();
......
......@@ -153,7 +153,6 @@ bool IosRunControlFactory::canRun(RunConfiguration *runConfiguration,
{
if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN
&& mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
return false;
}
......
......@@ -2059,8 +2059,7 @@ void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl)
m_outputPane->showTabFor(runControl);
Core::Id runMode = runControl->runMode();
bool popup = (runMode == Constants::NORMAL_RUN_MODE && dd->m_projectExplorerSettings.showRunOutput)
|| ((runMode == Constants::DEBUG_RUN_MODE || runMode == Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN)
&& m_projectExplorerSettings.showDebugOutput);
|| (runMode == Constants::DEBUG_RUN_MODE && m_projectExplorerSettings.showDebugOutput);
m_outputPane->setBehaviorOnOutput(runControl, popup ? AppOutputPane::Popup : AppOutputPane::Flash);
runControl->initiateStart();
emit m_instance->updateRunActions();
......
......@@ -180,7 +180,6 @@ const char NORMAL_RUN_MODE[]="RunConfiguration.NormalRunMode";
const char QML_PROFILER_RUN_MODE[]="RunConfiguration.QmlProfilerRunMode";
const char PERFPROFILER_RUN_MODE[]="PerfProfiler.RunMode";
const char DEBUG_RUN_MODE[]="RunConfiguration.DebugRunMode";
const char DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN[]="RunConfiguration.DebugRunModeWithBreakOnMain";
// Navigation Widget
const char PROJECTTREE_ID[] = "Projects";
......
......@@ -62,8 +62,6 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
RunControl::registerWorker<SimpleTargetRunner>(NORMAL_RUN_MODE, constraint);
RunControl::registerWorker<LinuxDeviceDebugSupport>(DEBUG_RUN_MODE, constraint);
RunControl::registerWorker<LinuxDeviceDebugSupport>(DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN,
constraint);
RunControl::registerWorker<RemoteLinuxQmlProfilerSupport>(QML_PROFILER_RUN_MODE, constraint);
//RunControl::registerWorker<RemoteLinuxPerfSupport>(PERFPROFILER_RUN_MODE, constraint);
......
......@@ -85,8 +85,6 @@ bool WinRtPlugin::initialize(const QStringList &arguments, QString *errorMessage
(ProjectExplorer::Constants::NORMAL_RUN_MODE, runConstraint);
RunControl::registerWorker<WinRtDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, debugConstraint);
RunControl::registerWorker<WinRtDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, debugConstraint);
return true;
}
......
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