Commit ccffed93 authored by hjk's avatar hjk

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