Commit ccffed93 authored by hjk's avatar hjk
Browse files

debugger: make F10/F11 start the app if not running and break on main

parent 8dd71a91
...@@ -48,6 +48,7 @@ const char * const C_QMLDEBUGGER = "Qml/JavaScript Debugger"; ...@@ -48,6 +48,7 @@ const char * const C_QMLDEBUGGER = "Qml/JavaScript Debugger";
// Project Explorer run mode (RUN/DEBUG) // Project Explorer run mode (RUN/DEBUG)
const char * const DEBUGMODE = "Debugger.DebugMode"; const char * const DEBUGMODE = "Debugger.DebugMode";
const char * const DEBUGMODE2 = "Debugger.DebugMode2";
// Common actions (accessed by QML inspector) // Common actions (accessed by QML inspector)
const char * const INTERRUPT = "Debugger.Interrupt"; const char * const INTERRUPT = "Debugger.Interrupt";
......
...@@ -682,6 +682,7 @@ public slots: ...@@ -682,6 +682,7 @@ public slots:
void showSettingsDialog(); void showSettingsDialog();
void debugProject(); void debugProject();
void debugProjectBreakMain();
void startExternalApplication(); void startExternalApplication();
void startRemoteCdbSession(); void startRemoteCdbSession();
void startRemoteApplication(); void startRemoteApplication();
...@@ -779,20 +780,28 @@ public slots: ...@@ -779,20 +780,28 @@ public slots:
void handleExecStep() void handleExecStep()
{ {
currentEngine()->resetLocation(); if (currentEngine()->state() == DebuggerNotReady) {
if (boolSetting(OperateByInstruction)) debugProjectBreakMain();
currentEngine()->executeStepI(); } else {
else currentEngine()->resetLocation();
currentEngine()->executeStep(); if (boolSetting(OperateByInstruction))
currentEngine()->executeStepI();
else
currentEngine()->executeStep();
}
} }
void handleExecNext() void handleExecNext()
{ {
currentEngine()->resetLocation(); if (currentEngine()->state() == DebuggerNotReady) {
if (boolSetting(OperateByInstruction)) debugProjectBreakMain();
currentEngine()->executeNextI(); } else {
else currentEngine()->resetLocation();
currentEngine()->executeNext(); if (boolSetting(OperateByInstruction))
currentEngine()->executeNextI();
else
currentEngine()->executeNext();
}
} }
void handleExecStepOut() void handleExecStepOut()
...@@ -1338,6 +1347,13 @@ void DebuggerPluginPrivate::debugProject() ...@@ -1338,6 +1347,13 @@ void DebuggerPluginPrivate::debugProject()
pe->runProject(pro, Constants::DEBUGMODE); pe->runProject(pro, Constants::DEBUGMODE);
} }
void DebuggerPluginPrivate::debugProjectBreakMain()
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
if (Project *pro = pe->startupProject())
pe->runProject(pro, Constants::DEBUGMODE2);
}
void DebuggerPluginPrivate::startExternalApplication() void DebuggerPluginPrivate::startExternalApplication()
{ {
DebuggerStartParameters sp; DebuggerStartParameters sp;
...@@ -1920,13 +1936,13 @@ void DebuggerPluginPrivate::setInitialState() ...@@ -1920,13 +1936,13 @@ void DebuggerPluginPrivate::setInitialState()
m_interruptAction->setEnabled(false); m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
m_stepAction->setEnabled(false); m_stepAction->setEnabled(true);
m_stepOutAction->setEnabled(false); m_stepOutAction->setEnabled(false);
m_runToLineAction->setEnabled(false); m_runToLineAction->setEnabled(false);
m_runToSelectedFunctionAction->setEnabled(true); m_runToSelectedFunctionAction->setEnabled(true);
m_returnFromFunctionAction->setEnabled(false); m_returnFromFunctionAction->setEnabled(false);
m_jumpToLineAction->setEnabled(false); m_jumpToLineAction->setEnabled(false);
m_nextAction->setEnabled(false); m_nextAction->setEnabled(true);
action(AutoDerefPointers)->setEnabled(true); action(AutoDerefPointers)->setEnabled(true);
action(ExpandStack)->setEnabled(false); action(ExpandStack)->setEnabled(false);
...@@ -2041,7 +2057,9 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2041,7 +2057,9 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_resetAction->setEnabled(state != DebuggerNotReady m_resetAction->setEnabled(state != DebuggerNotReady
&& state != DebuggerFinished); && state != DebuggerFinished);
m_stepAction->setEnabled(stopped); m_stepAction->setEnabled(stopped || state == DebuggerNotReady);
m_nextAction->setEnabled(stopped || state == DebuggerNotReady);
m_stepOutAction->setEnabled(stopped); m_stepOutAction->setEnabled(stopped);
m_runToLineAction->setEnabled(stopped); m_runToLineAction->setEnabled(stopped);
m_runToSelectedFunctionAction->setEnabled(stopped); m_runToSelectedFunctionAction->setEnabled(stopped);
...@@ -2051,8 +2069,6 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2051,8 +2069,6 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
const bool canJump = stopped && (caps & JumpToLineCapability); const bool canJump = stopped && (caps & JumpToLineCapability);
m_jumpToLineAction->setEnabled(canJump); m_jumpToLineAction->setEnabled(canJump);
m_nextAction->setEnabled(stopped);
const bool canDeref = actionsEnabled && (caps & AutoDerefPointersCapability); const bool canDeref = actionsEnabled && (caps & AutoDerefPointersCapability);
action(AutoDerefPointers)->setEnabled(canDeref); action(AutoDerefPointers)->setEnabled(canDeref);
action(AutoDerefPointers)->setEnabled(true); action(AutoDerefPointers)->setEnabled(true);
...@@ -2828,13 +2844,13 @@ void DebuggerPluginPrivate::extensionsInitialized() ...@@ -2828,13 +2844,13 @@ void DebuggerPluginPrivate::extensionsInitialized()
debugMenu->addAction(cmd); debugMenu->addAction(cmd);
cmd = am->registerAction(m_nextAction, cmd = am->registerAction(m_nextAction,
Constants::NEXT, cppDebuggercontext); Constants::NEXT, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::NEXT_KEY)); cmd->setDefaultKeySequence(QKeySequence(Constants::NEXT_KEY));
cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_Hide);
debugMenu->addAction(cmd); debugMenu->addAction(cmd);
cmd = am->registerAction(m_stepAction, cmd = am->registerAction(m_stepAction,
Constants::STEP, cppDebuggercontext); Constants::STEP, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::STEP_KEY)); cmd->setDefaultKeySequence(QKeySequence(Constants::STEP_KEY));
cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_Hide);
debugMenu->addAction(cmd); debugMenu->addAction(cmd);
......
...@@ -654,7 +654,7 @@ DebuggerRunControlFactory::DebuggerRunControlFactory(QObject *parent, ...@@ -654,7 +654,7 @@ DebuggerRunControlFactory::DebuggerRunControlFactory(QObject *parent,
bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
{ {
// return mode == ProjectExplorer::Constants::DEBUGMODE; // return mode == ProjectExplorer::Constants::DEBUGMODE;
return mode == Constants::DEBUGMODE return (mode == Constants::DEBUGMODE || mode == Constants::DEBUGMODE2)
&& qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
} }
...@@ -761,8 +761,10 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu ...@@ -761,8 +761,10 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
RunControl *DebuggerRunControlFactory::create RunControl *DebuggerRunControlFactory::create
(RunConfiguration *runConfiguration, const QString &mode) (RunConfiguration *runConfiguration, const QString &mode)
{ {
QTC_ASSERT(mode == Constants::DEBUGMODE, return 0); QTC_ASSERT(mode == Constants::DEBUGMODE || mode == Constants::DEBUGMODE2, return 0);
DebuggerStartParameters sp = localStartParameters(runConfiguration); DebuggerStartParameters sp = localStartParameters(runConfiguration);
if (mode == Constants::DEBUGMODE2)
sp.breakOnMain = true;
return create(sp, runConfiguration); return create(sp, runConfiguration);
} }
......
...@@ -64,6 +64,7 @@ public: ...@@ -64,6 +64,7 @@ public:
: isSnapshot(false), : isSnapshot(false),
attachPID(-1), attachPID(-1),
useTerminal(false), useTerminal(false),
breakOnMain(false),
qmlServerAddress(QLatin1String("127.0.0.1")), qmlServerAddress(QLatin1String("127.0.0.1")),
qmlServerPort(0), qmlServerPort(0),
useServerStartScript(false), useServerStartScript(false),
...@@ -85,6 +86,7 @@ public: ...@@ -85,6 +86,7 @@ public:
QString workingDirectory; QString workingDirectory;
qint64 attachPID; qint64 attachPID;
bool useTerminal; bool useTerminal;
bool breakOnMain;
// Used by AttachCrashedExternal. // Used by AttachCrashedExternal.
QString crashParameter; QString crashParameter;
......
...@@ -4448,6 +4448,12 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint) ...@@ -4448,6 +4448,12 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &settingsIdHint)
postCommand("disassemble 0 0", ConsoleCommand, CB(handleDisassemblerCheck)); postCommand("disassemble 0 0", ConsoleCommand, CB(handleDisassemblerCheck));
if (sp.breakOnMain) {
QByteArray cmd = "tbreak ";
cmd += sp.toolChainAbi.os() == Abi::WindowsOS ? "qMain" : "main";
postCommand(cmd);
}
loadPythonDumpers(); loadPythonDumpers();
QString scriptFileName = debuggerCore()->stringSetting(GdbScriptFile); QString scriptFileName = debuggerCore()->stringSetting(GdbScriptFile);
......
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