Debugger: Finalize moving Operate by Instruction to engines

Fixes: QTCREATORBUG-21211
Fixes: QTCREATORBUG-21212
Change-Id: I6c0259052336f2141462157c319abeaec9a1e483
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-10-05 12:03:19 +02:00
parent e0d7d03720
commit 36b654567d
11 changed files with 47 additions and 54 deletions

View File

@@ -201,8 +201,6 @@ CdbEngine::CdbEngine() :
wh->addTypeFormats("QImage", imageFormats);
wh->addTypeFormats("QImage *", imageFormats);
connect(action(OperateByInstruction), &QAction::triggered,
this, &CdbEngine::operateByInstructionTriggered);
connect(action(CreateFullBacktrace), &QAction::triggered,
this, &CdbEngine::createFullBacktrace);
connect(&m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
@@ -270,6 +268,7 @@ CdbEngine::~CdbEngine() = default;
void CdbEngine::operateByInstructionTriggered(bool operateByInstruction)
{
DebuggerEngine::operateByInstructionTriggered(operateByInstruction);
if (m_operateByInstruction == operateByInstruction)
return;
m_operateByInstruction = operateByInstruction;
@@ -522,7 +521,7 @@ void CdbEngine::handleInitialSessionIdle()
const DebuggerRunParameters &rp = runParameters();
if (!rp.commandsAfterConnect.isEmpty())
runCommand({rp.commandsAfterConnect, NoFlags});
operateByInstructionTriggered(action(OperateByInstruction)->isChecked());
operateByInstructionTriggered(operatesByInstruction());
// QmlCppEngine expects the QML engine to be connected before any breakpoints are hit
// (attemptBreakpointSynchronization() will be directly called then)
if (rp.breakOnMain) {

View File

@@ -113,7 +113,7 @@ private:
void processError();
void processFinished();
void runCommand(const DebuggerCommand &cmd) override;
void operateByInstructionTriggered(bool);
void operateByInstructionTriggered(bool) override;
void createFullBacktrace();

View File

@@ -165,18 +165,6 @@ DebuggerSettings::DebuggerSettings()
item->setDefaultValue(false);
insertItem(LogTimeStamps, item);
item = new SavedAction(this);
item->setText(tr("Operate by Instruction"));
item->setCheckable(true);
item->setDefaultValue(false);
item->setIcon(Debugger::Icons::SINGLE_INSTRUCTION_MODE.icon());
item->setToolTip(tr("<p>This switches the debugger to instruction-wise "
"operation mode. In this mode, stepping operates on single "
"instructions and the source location view also shows the "
"disassembled instructions."));
item->setIconVisibleInMenu(false);
insertItem(OperateByInstruction, item);
item = new SavedAction(this);
item->setText(tr("Dereference Pointers Automatically"));
item->setCheckable(true);

View File

@@ -82,7 +82,6 @@ enum DebuggerActionCode
AutoQuit,
LockView,
LogTimeStamps,
OperateByInstruction,
CloseSourceBuffersOnExit,
CloseMemoryBuffersOnExit,
SwitchModeOnExit,

View File

@@ -393,23 +393,6 @@ public:
m_toolTipManager.resetLocation();
}
void handleOperateByInstructionTriggered(bool on)
{
// Go to source only if we have the file.
// if (DebuggerEngine *cppEngine = m_engine->cppEngine()) {
if (m_stackHandler.currentIndex() >= 0) {
const StackFrame frame = m_stackHandler.currentFrame();
if (on || frame.isUsable())
m_engine->gotoLocation(Location(frame, true));
}
// }
}
bool operatesByInstruction() const
{
return m_operateByInstructionAction.isChecked();
}
public:
void setInitialActionStates();
void setBusyCursor(bool on);
@@ -542,9 +525,15 @@ void DebuggerEnginePrivate::setupViews()
m_operateByInstructionAction.setVisible(m_engine->hasCapability(DisassemblerCapability));
m_operateByInstructionAction.setIcon(Debugger::Icons::SINGLE_INSTRUCTION_MODE.icon());
m_operateByInstructionAction.setCheckable(true);
m_operateByInstructionAction.setChecked(boolSetting(OperateByInstruction));
m_operateByInstructionAction.setChecked(false);
m_operateByInstructionAction.setToolTip("<p>" + tr("This switches the debugger to instruction-wise "
"operation mode. In this mode, stepping operates on single "
"instructions and the source location view also shows the "
"disassembled instructions."));
m_operateByInstructionAction.setIconVisibleInMenu(false);
connect(&m_operateByInstructionAction, &QAction::triggered,
this, &DebuggerEnginePrivate::handleOperateByInstructionTriggered);
m_engine, &DebuggerEngine::operateByInstructionTriggered);
QTC_ASSERT(m_state == DebuggerNotReady || m_state == DebuggerFinished, qDebug() << m_state);
m_progress.setProgressValue(200);
@@ -977,7 +966,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
d->resetLocation();
if (loc.canBeDisassembled()
&& ((hasCapability(OperateByInstructionCapability) && d->operatesByInstruction())
&& ((hasCapability(OperateByInstructionCapability) && operatesByInstruction())
|| !loc.hasDebugInfo()) )
{
d->m_disassemblerAgent.setLocation(loc);
@@ -1803,6 +1792,24 @@ bool DebuggerEngine::debuggerActionsEnabled() const
return debuggerActionsEnabledHelper(d->m_state);
}
bool DebuggerEngine::operatesByInstruction() const
{
return d->m_operateByInstructionAction.isChecked();
}
void DebuggerEngine::operateByInstructionTriggered(bool on)
{
// Go to source only if we have the file.
// if (DebuggerEngine *cppEngine = m_engine->cppEngine()) {
d->m_stackHandler.resetModel();
if (d->m_stackHandler.currentIndex() >= 0) {
const StackFrame frame = d->m_stackHandler.currentFrame();
if (on || frame.isUsable())
gotoLocation(Location(frame, true));
}
// }
}
bool DebuggerEngine::companionPreventsActions() const
{
return false;
@@ -2291,7 +2298,7 @@ void DebuggerEngine::handleExecStep()
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
} else {
resetLocation();
if (d->operatesByInstruction())
if (operatesByInstruction())
executeStepI();
else
executeStep();
@@ -2305,7 +2312,7 @@ void DebuggerEngine::handleExecNext()
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
} else {
resetLocation();
if (d->operatesByInstruction())
if (operatesByInstruction())
executeNextI();
else
executeNext();

View File

@@ -338,6 +338,9 @@ public:
bool debuggerActionsEnabled() const;
virtual bool companionPreventsActions() const;
bool operatesByInstruction() const;
virtual void operateByInstructionTriggered(bool on); // FIXME: Remove.
DebuggerState state() const;
bool isDying() const;

View File

@@ -1233,7 +1233,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
m_nextAction.setIcon(Icons::STEP_OVER.icon());
connect(&m_nextAction, &QAction::triggered, this, [] {
if (DebuggerEngine *engine = EngineManager::currentEngine()) {
engine->executeNext();
engine->handleExecNext();
} else {
DebuggerRunTool::setBreakOnMainNextTime();
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
@@ -1248,7 +1248,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
m_stepAction.setIcon(Icons::STEP_OVER.icon());
connect(&m_stepAction, &QAction::triggered, this, [] {
if (DebuggerEngine *engine = EngineManager::currentEngine()) {
engine->executeStep();
engine->handleExecStep();
} else {
DebuggerRunTool::setBreakOnMainNextTime();
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
@@ -1298,10 +1298,10 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
ActionManager::registerAction(&m_frameUpAction,
"Debugger.FrameUp", cppDebuggercontext);
cmd = ActionManager::registerAction(action(OperateByInstruction),
Constants::OPERATE_BY_INSTRUCTION, cppDebuggercontext);
cmd->setAttribute(Command::CA_Hide);
debugMenu->addAction(cmd);
// cmd = ActionManager::registerAction(action(OperateByInstruction),
// Constants::OPERATE_BY_INSTRUCTION, cppDebuggercontext);
// cmd->setAttribute(Command::CA_Hide);
// debugMenu->addAction(cmd);
cmd = ActionManager::registerAction(&m_breakAction, "Debugger.ToggleBreak");
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("F8") : tr("F9")));
@@ -2056,7 +2056,6 @@ void DebuggerPluginPrivate::setInitialState()
m_watchAction.setEnabled(false);
m_breakAction.setEnabled(false);
//m_snapshotAction.setEnabled(false);
action(OperateByInstruction)->setChecked(false);
m_exitAction.setEnabled(false);
m_abortAction.setEnabled(false);

View File

@@ -1233,7 +1233,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
//qDebug() << "BP " << rid << data.toString();
// Quickly set the location marker.
if (lineNumber && !boolSetting(OperateByInstruction)
if (lineNumber && !operatesByInstruction()
&& QFileInfo::exists(fullName)
&& function != "qt_v4TriggeredBreakpointHook"
&& function != "qt_qmlDebugMessageAvailable"

View File

@@ -891,7 +891,7 @@ void LldbEngine::handleLocationNotification(const GdbMi &reportedLocation)
QString function = reportedLocation["function"].data();
int lineNumber = reportedLocation["line"].toInt();
Location loc = Location(fileName, lineNumber);
if (boolSetting(OperateByInstruction) || !QFileInfo::exists(fileName) || lineNumber <= 0) {
if (operatesByInstruction() || !QFileInfo::exists(fileName) || lineNumber <= 0) {
loc = Location(address);
loc.setNeedsMarker(true);
loc.setUseAssembler(true);

View File

@@ -69,8 +69,6 @@ StackHandler::StackHandler(DebuggerEngine *engine)
{
setObjectName("StackModel");
connect(action(OperateByInstruction), &QAction::triggered,
this, &StackHandler::resetModel);
connect(action(ExpandStack), &QAction::triggered,
this, &StackHandler::reloadFullStack);
connect(action(MaximalStackDepth), &QAction::triggered,
@@ -159,7 +157,7 @@ Qt::ItemFlags StackHandler::flags(const QModelIndex &index) const
if (index.row() == m_stackFrames.size())
return QAbstractTableModel::flags(index);
const StackFrame &frame = m_stackFrames.at(index.row());
const bool isValid = frame.isUsable() || boolSetting(OperateByInstruction);
const bool isValid = frame.isUsable() || m_engine->operatesByInstruction();
return isValid && m_contentsValid
? QAbstractTableModel::flags(index) : Qt::ItemFlags();
}
@@ -258,7 +256,7 @@ void StackHandler::setFramesAndCurrentIndex(const GdbMi &frames, bool isFull)
// a few exceptions:
// Always jump to frame #0 when stepping by instruction.
if (boolSetting(OperateByInstruction))
if (m_engine->operatesByInstruction())
targetFrame = 0;
// If there is no frame with source, jump to frame #0.
@@ -284,7 +282,7 @@ void StackHandler::prependFrames(const StackFrames &frames)
int StackHandler::firstUsableIndex() const
{
if (!boolSetting(OperateByInstruction)) {
if (!m_engine->operatesByInstruction()) {
for (int i = 0, n = m_stackFrames.size(); i != n; ++i)
if (m_stackFrames.at(i).isUsable())
return i;

View File

@@ -73,6 +73,7 @@ public:
bool isContentsValid() const { return m_contentsValid; }
void scheduleResetLocation();
void resetLocation();
void resetModel() { beginResetModel(); endResetModel(); }
signals:
void stackChanged();
@@ -87,7 +88,6 @@ private:
bool setData(const QModelIndex &idx, const QVariant &data, int role) override;
bool contextMenuEvent(const Utils::ItemViewEvent &event);
void resetModel() { beginResetModel(); endResetModel(); }
void reloadFullStack();
void copyContentsToClipboard();
void saveTaskFile();