forked from qt-creator/qt-creator
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:
@@ -201,8 +201,6 @@ CdbEngine::CdbEngine() :
|
|||||||
wh->addTypeFormats("QImage", imageFormats);
|
wh->addTypeFormats("QImage", imageFormats);
|
||||||
wh->addTypeFormats("QImage *", imageFormats);
|
wh->addTypeFormats("QImage *", imageFormats);
|
||||||
|
|
||||||
connect(action(OperateByInstruction), &QAction::triggered,
|
|
||||||
this, &CdbEngine::operateByInstructionTriggered);
|
|
||||||
connect(action(CreateFullBacktrace), &QAction::triggered,
|
connect(action(CreateFullBacktrace), &QAction::triggered,
|
||||||
this, &CdbEngine::createFullBacktrace);
|
this, &CdbEngine::createFullBacktrace);
|
||||||
connect(&m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
|
connect(&m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
|
||||||
@@ -270,6 +268,7 @@ CdbEngine::~CdbEngine() = default;
|
|||||||
|
|
||||||
void CdbEngine::operateByInstructionTriggered(bool operateByInstruction)
|
void CdbEngine::operateByInstructionTriggered(bool operateByInstruction)
|
||||||
{
|
{
|
||||||
|
DebuggerEngine::operateByInstructionTriggered(operateByInstruction);
|
||||||
if (m_operateByInstruction == operateByInstruction)
|
if (m_operateByInstruction == operateByInstruction)
|
||||||
return;
|
return;
|
||||||
m_operateByInstruction = operateByInstruction;
|
m_operateByInstruction = operateByInstruction;
|
||||||
@@ -522,7 +521,7 @@ void CdbEngine::handleInitialSessionIdle()
|
|||||||
const DebuggerRunParameters &rp = runParameters();
|
const DebuggerRunParameters &rp = runParameters();
|
||||||
if (!rp.commandsAfterConnect.isEmpty())
|
if (!rp.commandsAfterConnect.isEmpty())
|
||||||
runCommand({rp.commandsAfterConnect, NoFlags});
|
runCommand({rp.commandsAfterConnect, NoFlags});
|
||||||
operateByInstructionTriggered(action(OperateByInstruction)->isChecked());
|
operateByInstructionTriggered(operatesByInstruction());
|
||||||
// QmlCppEngine expects the QML engine to be connected before any breakpoints are hit
|
// QmlCppEngine expects the QML engine to be connected before any breakpoints are hit
|
||||||
// (attemptBreakpointSynchronization() will be directly called then)
|
// (attemptBreakpointSynchronization() will be directly called then)
|
||||||
if (rp.breakOnMain) {
|
if (rp.breakOnMain) {
|
||||||
|
@@ -113,7 +113,7 @@ private:
|
|||||||
void processError();
|
void processError();
|
||||||
void processFinished();
|
void processFinished();
|
||||||
void runCommand(const DebuggerCommand &cmd) override;
|
void runCommand(const DebuggerCommand &cmd) override;
|
||||||
void operateByInstructionTriggered(bool);
|
void operateByInstructionTriggered(bool) override;
|
||||||
|
|
||||||
void createFullBacktrace();
|
void createFullBacktrace();
|
||||||
|
|
||||||
|
@@ -165,18 +165,6 @@ DebuggerSettings::DebuggerSettings()
|
|||||||
item->setDefaultValue(false);
|
item->setDefaultValue(false);
|
||||||
insertItem(LogTimeStamps, item);
|
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 = new SavedAction(this);
|
||||||
item->setText(tr("Dereference Pointers Automatically"));
|
item->setText(tr("Dereference Pointers Automatically"));
|
||||||
item->setCheckable(true);
|
item->setCheckable(true);
|
||||||
|
@@ -82,7 +82,6 @@ enum DebuggerActionCode
|
|||||||
AutoQuit,
|
AutoQuit,
|
||||||
LockView,
|
LockView,
|
||||||
LogTimeStamps,
|
LogTimeStamps,
|
||||||
OperateByInstruction,
|
|
||||||
CloseSourceBuffersOnExit,
|
CloseSourceBuffersOnExit,
|
||||||
CloseMemoryBuffersOnExit,
|
CloseMemoryBuffersOnExit,
|
||||||
SwitchModeOnExit,
|
SwitchModeOnExit,
|
||||||
|
@@ -393,23 +393,6 @@ public:
|
|||||||
m_toolTipManager.resetLocation();
|
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:
|
public:
|
||||||
void setInitialActionStates();
|
void setInitialActionStates();
|
||||||
void setBusyCursor(bool on);
|
void setBusyCursor(bool on);
|
||||||
@@ -542,9 +525,15 @@ void DebuggerEnginePrivate::setupViews()
|
|||||||
m_operateByInstructionAction.setVisible(m_engine->hasCapability(DisassemblerCapability));
|
m_operateByInstructionAction.setVisible(m_engine->hasCapability(DisassemblerCapability));
|
||||||
m_operateByInstructionAction.setIcon(Debugger::Icons::SINGLE_INSTRUCTION_MODE.icon());
|
m_operateByInstructionAction.setIcon(Debugger::Icons::SINGLE_INSTRUCTION_MODE.icon());
|
||||||
m_operateByInstructionAction.setCheckable(true);
|
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,
|
connect(&m_operateByInstructionAction, &QAction::triggered,
|
||||||
this, &DebuggerEnginePrivate::handleOperateByInstructionTriggered);
|
m_engine, &DebuggerEngine::operateByInstructionTriggered);
|
||||||
|
|
||||||
QTC_ASSERT(m_state == DebuggerNotReady || m_state == DebuggerFinished, qDebug() << m_state);
|
QTC_ASSERT(m_state == DebuggerNotReady || m_state == DebuggerFinished, qDebug() << m_state);
|
||||||
m_progress.setProgressValue(200);
|
m_progress.setProgressValue(200);
|
||||||
@@ -977,7 +966,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
|
|||||||
d->resetLocation();
|
d->resetLocation();
|
||||||
|
|
||||||
if (loc.canBeDisassembled()
|
if (loc.canBeDisassembled()
|
||||||
&& ((hasCapability(OperateByInstructionCapability) && d->operatesByInstruction())
|
&& ((hasCapability(OperateByInstructionCapability) && operatesByInstruction())
|
||||||
|| !loc.hasDebugInfo()) )
|
|| !loc.hasDebugInfo()) )
|
||||||
{
|
{
|
||||||
d->m_disassemblerAgent.setLocation(loc);
|
d->m_disassemblerAgent.setLocation(loc);
|
||||||
@@ -1803,6 +1792,24 @@ bool DebuggerEngine::debuggerActionsEnabled() const
|
|||||||
return debuggerActionsEnabledHelper(d->m_state);
|
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
|
bool DebuggerEngine::companionPreventsActions() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -2291,7 +2298,7 @@ void DebuggerEngine::handleExecStep()
|
|||||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||||
} else {
|
} else {
|
||||||
resetLocation();
|
resetLocation();
|
||||||
if (d->operatesByInstruction())
|
if (operatesByInstruction())
|
||||||
executeStepI();
|
executeStepI();
|
||||||
else
|
else
|
||||||
executeStep();
|
executeStep();
|
||||||
@@ -2305,7 +2312,7 @@ void DebuggerEngine::handleExecNext()
|
|||||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||||
} else {
|
} else {
|
||||||
resetLocation();
|
resetLocation();
|
||||||
if (d->operatesByInstruction())
|
if (operatesByInstruction())
|
||||||
executeNextI();
|
executeNextI();
|
||||||
else
|
else
|
||||||
executeNext();
|
executeNext();
|
||||||
|
@@ -338,6 +338,9 @@ public:
|
|||||||
bool debuggerActionsEnabled() const;
|
bool debuggerActionsEnabled() const;
|
||||||
virtual bool companionPreventsActions() const;
|
virtual bool companionPreventsActions() const;
|
||||||
|
|
||||||
|
bool operatesByInstruction() const;
|
||||||
|
virtual void operateByInstructionTriggered(bool on); // FIXME: Remove.
|
||||||
|
|
||||||
DebuggerState state() const;
|
DebuggerState state() const;
|
||||||
bool isDying() const;
|
bool isDying() const;
|
||||||
|
|
||||||
|
@@ -1233,7 +1233,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
m_nextAction.setIcon(Icons::STEP_OVER.icon());
|
m_nextAction.setIcon(Icons::STEP_OVER.icon());
|
||||||
connect(&m_nextAction, &QAction::triggered, this, [] {
|
connect(&m_nextAction, &QAction::triggered, this, [] {
|
||||||
if (DebuggerEngine *engine = EngineManager::currentEngine()) {
|
if (DebuggerEngine *engine = EngineManager::currentEngine()) {
|
||||||
engine->executeNext();
|
engine->handleExecNext();
|
||||||
} else {
|
} else {
|
||||||
DebuggerRunTool::setBreakOnMainNextTime();
|
DebuggerRunTool::setBreakOnMainNextTime();
|
||||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
|
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());
|
m_stepAction.setIcon(Icons::STEP_OVER.icon());
|
||||||
connect(&m_stepAction, &QAction::triggered, this, [] {
|
connect(&m_stepAction, &QAction::triggered, this, [] {
|
||||||
if (DebuggerEngine *engine = EngineManager::currentEngine()) {
|
if (DebuggerEngine *engine = EngineManager::currentEngine()) {
|
||||||
engine->executeStep();
|
engine->handleExecStep();
|
||||||
} else {
|
} else {
|
||||||
DebuggerRunTool::setBreakOnMainNextTime();
|
DebuggerRunTool::setBreakOnMainNextTime();
|
||||||
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
|
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, false);
|
||||||
@@ -1298,10 +1298,10 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
|||||||
ActionManager::registerAction(&m_frameUpAction,
|
ActionManager::registerAction(&m_frameUpAction,
|
||||||
"Debugger.FrameUp", cppDebuggercontext);
|
"Debugger.FrameUp", cppDebuggercontext);
|
||||||
|
|
||||||
cmd = ActionManager::registerAction(action(OperateByInstruction),
|
// cmd = ActionManager::registerAction(action(OperateByInstruction),
|
||||||
Constants::OPERATE_BY_INSTRUCTION, cppDebuggercontext);
|
// Constants::OPERATE_BY_INSTRUCTION, cppDebuggercontext);
|
||||||
cmd->setAttribute(Command::CA_Hide);
|
// cmd->setAttribute(Command::CA_Hide);
|
||||||
debugMenu->addAction(cmd);
|
// debugMenu->addAction(cmd);
|
||||||
|
|
||||||
cmd = ActionManager::registerAction(&m_breakAction, "Debugger.ToggleBreak");
|
cmd = ActionManager::registerAction(&m_breakAction, "Debugger.ToggleBreak");
|
||||||
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("F8") : tr("F9")));
|
cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("F8") : tr("F9")));
|
||||||
@@ -2056,7 +2056,6 @@ void DebuggerPluginPrivate::setInitialState()
|
|||||||
m_watchAction.setEnabled(false);
|
m_watchAction.setEnabled(false);
|
||||||
m_breakAction.setEnabled(false);
|
m_breakAction.setEnabled(false);
|
||||||
//m_snapshotAction.setEnabled(false);
|
//m_snapshotAction.setEnabled(false);
|
||||||
action(OperateByInstruction)->setChecked(false);
|
|
||||||
|
|
||||||
m_exitAction.setEnabled(false);
|
m_exitAction.setEnabled(false);
|
||||||
m_abortAction.setEnabled(false);
|
m_abortAction.setEnabled(false);
|
||||||
|
@@ -1233,7 +1233,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
|
|||||||
|
|
||||||
//qDebug() << "BP " << rid << data.toString();
|
//qDebug() << "BP " << rid << data.toString();
|
||||||
// Quickly set the location marker.
|
// Quickly set the location marker.
|
||||||
if (lineNumber && !boolSetting(OperateByInstruction)
|
if (lineNumber && !operatesByInstruction()
|
||||||
&& QFileInfo::exists(fullName)
|
&& QFileInfo::exists(fullName)
|
||||||
&& function != "qt_v4TriggeredBreakpointHook"
|
&& function != "qt_v4TriggeredBreakpointHook"
|
||||||
&& function != "qt_qmlDebugMessageAvailable"
|
&& function != "qt_qmlDebugMessageAvailable"
|
||||||
|
@@ -891,7 +891,7 @@ void LldbEngine::handleLocationNotification(const GdbMi &reportedLocation)
|
|||||||
QString function = reportedLocation["function"].data();
|
QString function = reportedLocation["function"].data();
|
||||||
int lineNumber = reportedLocation["line"].toInt();
|
int lineNumber = reportedLocation["line"].toInt();
|
||||||
Location loc = Location(fileName, lineNumber);
|
Location loc = Location(fileName, lineNumber);
|
||||||
if (boolSetting(OperateByInstruction) || !QFileInfo::exists(fileName) || lineNumber <= 0) {
|
if (operatesByInstruction() || !QFileInfo::exists(fileName) || lineNumber <= 0) {
|
||||||
loc = Location(address);
|
loc = Location(address);
|
||||||
loc.setNeedsMarker(true);
|
loc.setNeedsMarker(true);
|
||||||
loc.setUseAssembler(true);
|
loc.setUseAssembler(true);
|
||||||
|
@@ -69,8 +69,6 @@ StackHandler::StackHandler(DebuggerEngine *engine)
|
|||||||
{
|
{
|
||||||
setObjectName("StackModel");
|
setObjectName("StackModel");
|
||||||
|
|
||||||
connect(action(OperateByInstruction), &QAction::triggered,
|
|
||||||
this, &StackHandler::resetModel);
|
|
||||||
connect(action(ExpandStack), &QAction::triggered,
|
connect(action(ExpandStack), &QAction::triggered,
|
||||||
this, &StackHandler::reloadFullStack);
|
this, &StackHandler::reloadFullStack);
|
||||||
connect(action(MaximalStackDepth), &QAction::triggered,
|
connect(action(MaximalStackDepth), &QAction::triggered,
|
||||||
@@ -159,7 +157,7 @@ Qt::ItemFlags StackHandler::flags(const QModelIndex &index) const
|
|||||||
if (index.row() == m_stackFrames.size())
|
if (index.row() == m_stackFrames.size())
|
||||||
return QAbstractTableModel::flags(index);
|
return QAbstractTableModel::flags(index);
|
||||||
const StackFrame &frame = m_stackFrames.at(index.row());
|
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
|
return isValid && m_contentsValid
|
||||||
? QAbstractTableModel::flags(index) : Qt::ItemFlags();
|
? QAbstractTableModel::flags(index) : Qt::ItemFlags();
|
||||||
}
|
}
|
||||||
@@ -258,7 +256,7 @@ void StackHandler::setFramesAndCurrentIndex(const GdbMi &frames, bool isFull)
|
|||||||
// a few exceptions:
|
// a few exceptions:
|
||||||
|
|
||||||
// Always jump to frame #0 when stepping by instruction.
|
// Always jump to frame #0 when stepping by instruction.
|
||||||
if (boolSetting(OperateByInstruction))
|
if (m_engine->operatesByInstruction())
|
||||||
targetFrame = 0;
|
targetFrame = 0;
|
||||||
|
|
||||||
// If there is no frame with source, jump to frame #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
|
int StackHandler::firstUsableIndex() const
|
||||||
{
|
{
|
||||||
if (!boolSetting(OperateByInstruction)) {
|
if (!m_engine->operatesByInstruction()) {
|
||||||
for (int i = 0, n = m_stackFrames.size(); i != n; ++i)
|
for (int i = 0, n = m_stackFrames.size(); i != n; ++i)
|
||||||
if (m_stackFrames.at(i).isUsable())
|
if (m_stackFrames.at(i).isUsable())
|
||||||
return i;
|
return i;
|
||||||
|
@@ -73,6 +73,7 @@ public:
|
|||||||
bool isContentsValid() const { return m_contentsValid; }
|
bool isContentsValid() const { return m_contentsValid; }
|
||||||
void scheduleResetLocation();
|
void scheduleResetLocation();
|
||||||
void resetLocation();
|
void resetLocation();
|
||||||
|
void resetModel() { beginResetModel(); endResetModel(); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stackChanged();
|
void stackChanged();
|
||||||
@@ -87,7 +88,6 @@ private:
|
|||||||
bool setData(const QModelIndex &idx, const QVariant &data, int role) override;
|
bool setData(const QModelIndex &idx, const QVariant &data, int role) override;
|
||||||
|
|
||||||
bool contextMenuEvent(const Utils::ItemViewEvent &event);
|
bool contextMenuEvent(const Utils::ItemViewEvent &event);
|
||||||
void resetModel() { beginResetModel(); endResetModel(); }
|
|
||||||
void reloadFullStack();
|
void reloadFullStack();
|
||||||
void copyContentsToClipboard();
|
void copyContentsToClipboard();
|
||||||
void saveTaskFile();
|
void saveTaskFile();
|
||||||
|
Reference in New Issue
Block a user