2009-08-12 10:51:25 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
2010-12-17 17:14:20 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 17:14:20 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 17:14:20 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-12-08 12:43:11 +01:00
|
|
|
#include "disassembleragent.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2011-01-10 10:14:23 +01:00
|
|
|
#include "disassemblerlines.h"
|
2010-11-25 11:51:09 +01:00
|
|
|
#include "breakhandler.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerengine.h"
|
2011-04-21 15:52:51 +02:00
|
|
|
#include "debuggerinternalconstants.h"
|
2010-11-10 11:39:01 +01:00
|
|
|
#include "debuggercore.h"
|
2009-09-25 15:02:16 +02:00
|
|
|
#include "debuggerstringutils.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "stackframe.h"
|
2009-08-12 10:51:25 +02:00
|
|
|
|
2009-08-14 13:04:05 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2010-12-08 12:43:11 +01:00
|
|
|
#include <coreplugin/mimedatabase.h>
|
2009-08-14 13:04:05 +02:00
|
|
|
|
2010-11-24 18:36:17 +01:00
|
|
|
#include <texteditor/basetextdocument.h>
|
2009-08-14 13:04:05 +02:00
|
|
|
#include <texteditor/basetexteditor.h>
|
|
|
|
|
#include <texteditor/basetextmark.h>
|
2010-11-24 18:36:17 +01:00
|
|
|
#include <texteditor/plaintexteditor.h>
|
2009-08-14 13:04:05 +02:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2010-11-24 15:55:09 +01:00
|
|
|
#include <QtGui/QTextBlock>
|
2010-10-29 15:20:10 +02:00
|
|
|
#include <QtGui/QIcon>
|
2011-01-10 10:14:23 +01:00
|
|
|
#include <QtCore/QPointer>
|
2011-07-01 16:57:17 +02:00
|
|
|
#include <QtCore/QPair>
|
|
|
|
|
#include <QtCore/QDir>
|
2009-08-12 15:11:05 +02:00
|
|
|
|
2010-09-09 17:58:26 +02:00
|
|
|
using namespace Core;
|
2011-03-21 17:15:02 +01:00
|
|
|
using namespace TextEditor;
|
2010-09-09 17:58:26 +02:00
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-08-14 13:04:05 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2011-09-02 10:26:06 +02:00
|
|
|
// FrameKey
|
2009-08-14 13:04:05 +02:00
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-07-01 16:57:17 +02:00
|
|
|
class FrameKey
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FrameKey() : startAddress(0), endAddress(0) {}
|
|
|
|
|
inline bool matches(const Location &loc) const;
|
|
|
|
|
|
|
|
|
|
QString functionName;
|
|
|
|
|
QString fileName;
|
|
|
|
|
quint64 startAddress;
|
|
|
|
|
quint64 endAddress;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool FrameKey::matches(const Location &loc) const
|
|
|
|
|
{
|
|
|
|
|
return loc.address() >= startAddress
|
2011-09-02 10:26:06 +02:00
|
|
|
&& loc.address() <= endAddress
|
|
|
|
|
&& loc.fileName() == fileName
|
|
|
|
|
&& loc.functionName() == functionName;
|
2011-07-01 16:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef QPair<FrameKey, DisassemblerLines> CacheEntry;
|
|
|
|
|
|
2011-09-02 10:26:06 +02:00
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DisassemblerAgentPrivate
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
class DisassemblerAgentPrivate
|
2009-08-14 13:04:05 +02:00
|
|
|
{
|
2010-11-24 15:55:09 +01:00
|
|
|
public:
|
2010-12-14 12:29:32 +01:00
|
|
|
DisassemblerAgentPrivate();
|
|
|
|
|
~DisassemblerAgentPrivate();
|
2010-06-22 14:06:42 +02:00
|
|
|
void configureMimeType();
|
2011-09-02 10:26:06 +02:00
|
|
|
DisassemblerLines contentsAtCurrentLocation() const;
|
2010-02-01 16:14:57 +01:00
|
|
|
|
2010-11-24 15:55:09 +01:00
|
|
|
public:
|
2009-08-14 13:04:05 +02:00
|
|
|
QPointer<TextEditor::ITextEditor> editor;
|
2010-12-16 19:06:33 +01:00
|
|
|
Location location;
|
2010-06-16 11:08:54 +02:00
|
|
|
QPointer<DebuggerEngine> engine;
|
2011-03-21 17:15:02 +01:00
|
|
|
ITextMark *locationMark;
|
|
|
|
|
QList<ITextMark *> breakpointMarks;
|
2011-07-01 16:57:17 +02:00
|
|
|
QList<CacheEntry> cache;
|
2010-06-22 14:06:42 +02:00
|
|
|
QString mimeType;
|
2011-09-02 10:26:06 +02:00
|
|
|
bool tryMixed;
|
|
|
|
|
bool resetLocationScheduled;
|
2009-08-14 13:04:05 +02:00
|
|
|
};
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
DisassemblerAgentPrivate::DisassemblerAgentPrivate()
|
2010-11-24 15:55:09 +01:00
|
|
|
: editor(0),
|
2011-03-18 18:33:20 +01:00
|
|
|
mimeType(_("text/x-qtcreator-generic-asm")),
|
2011-09-02 10:26:06 +02:00
|
|
|
tryMixed(true),
|
|
|
|
|
resetLocationScheduled(false)
|
2009-08-18 11:23:01 +02:00
|
|
|
{
|
2011-03-21 17:15:02 +01:00
|
|
|
locationMark = new ITextMark;
|
|
|
|
|
locationMark->setIcon(debuggerCore()->locationMarkIcon());
|
|
|
|
|
locationMark->setPriority(TextEditor::ITextMark::HighPriority);
|
2010-06-22 14:06:42 +02:00
|
|
|
}
|
2009-08-18 11:23:01 +02:00
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
DisassemblerAgentPrivate::~DisassemblerAgentPrivate()
|
2010-11-25 11:51:09 +01:00
|
|
|
{
|
|
|
|
|
if (editor) {
|
|
|
|
|
EditorManager *editorManager = EditorManager::instance();
|
|
|
|
|
editorManager->closeEditors(QList<IEditor *>() << editor);
|
|
|
|
|
}
|
|
|
|
|
editor = 0;
|
|
|
|
|
delete locationMark;
|
|
|
|
|
}
|
2010-11-24 15:55:09 +01:00
|
|
|
|
2011-09-02 10:26:06 +02:00
|
|
|
DisassemblerLines DisassemblerAgentPrivate::contentsAtCurrentLocation() const
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0, n = cache.size(); i != n; ++i) {
|
|
|
|
|
const CacheEntry &entry = cache.at(i);
|
|
|
|
|
if (entry.first.matches(location))
|
|
|
|
|
return entry.second;
|
|
|
|
|
}
|
|
|
|
|
return DisassemblerLines();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DisassemblerAgent
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-08-14 13:04:05 +02:00
|
|
|
/*!
|
2011-01-26 17:22:25 +01:00
|
|
|
\class Debugger::Internal::DisassemblerAgent
|
2009-08-14 13:04:05 +02:00
|
|
|
|
|
|
|
|
Objects from this class are created in response to user actions in
|
|
|
|
|
the Gui for showing disassembled memory from the inferior. After creation
|
|
|
|
|
it handles communication between the engine and the editor.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
DisassemblerAgent::DisassemblerAgent(DebuggerEngine *engine)
|
|
|
|
|
: QObject(0), d(new DisassemblerAgentPrivate)
|
2009-08-14 13:04:05 +02:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
d->engine = engine;
|
2009-08-14 13:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
DisassemblerAgent::~DisassemblerAgent()
|
2009-08-14 13:04:05 +02:00
|
|
|
{
|
|
|
|
|
delete d;
|
2009-09-28 09:41:07 +02:00
|
|
|
d = 0;
|
2009-08-14 13:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-01 16:57:17 +02:00
|
|
|
int DisassemblerAgent::indexOf(const Location &loc) const
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < d->cache.size(); i++)
|
|
|
|
|
if (d->cache.at(i).first.matches(loc))
|
|
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void DisassemblerAgent::cleanup()
|
2009-09-29 16:17:01 +02:00
|
|
|
{
|
|
|
|
|
d->cache.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-18 18:33:20 +01:00
|
|
|
void DisassemblerAgent::scheduleResetLocation()
|
|
|
|
|
{
|
2011-09-02 10:26:06 +02:00
|
|
|
d->resetLocationScheduled = true;
|
2011-03-18 18:33:20 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void DisassemblerAgent::resetLocation()
|
2009-10-01 16:23:26 +02:00
|
|
|
{
|
2010-11-25 11:51:09 +01:00
|
|
|
if (!d->editor)
|
|
|
|
|
return;
|
2011-09-02 10:26:06 +02:00
|
|
|
if (d->resetLocationScheduled) {
|
|
|
|
|
d->resetLocationScheduled = false;
|
2011-03-18 18:33:20 +01:00
|
|
|
d->editor->markableInterface()->removeMark(d->locationMark);
|
|
|
|
|
}
|
2009-10-01 16:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-16 19:06:33 +01:00
|
|
|
const Location &DisassemblerAgent::location() const
|
2010-02-01 16:14:57 +01:00
|
|
|
{
|
2010-12-16 19:06:33 +01:00
|
|
|
return d->location;
|
2010-02-01 16:14:57 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
bool DisassemblerAgent::isMixed() const
|
2010-02-01 16:14:57 +01:00
|
|
|
{
|
|
|
|
|
return d->tryMixed
|
2010-12-16 19:06:33 +01:00
|
|
|
&& d->location.lineNumber() > 0
|
|
|
|
|
&& !d->location.functionName().isEmpty()
|
|
|
|
|
&& d->location.functionName() != _("??");
|
2010-02-01 16:14:57 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-16 19:06:33 +01:00
|
|
|
void DisassemblerAgent::setLocation(const Location &loc)
|
2009-08-14 13:04:05 +02:00
|
|
|
{
|
2010-12-16 19:06:33 +01:00
|
|
|
d->location = loc;
|
2011-07-01 16:57:17 +02:00
|
|
|
int index = indexOf(loc);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
// Refresh when not displaying a function and there is not sufficient
|
|
|
|
|
// context left past the address.
|
|
|
|
|
if (!isMixed() && d->cache.at(index).first.endAddress - loc.address() < 24) {
|
|
|
|
|
index = -1;
|
|
|
|
|
d->cache.removeAt(index);
|
2009-09-29 16:17:01 +02:00
|
|
|
}
|
2010-01-29 21:33:57 +01:00
|
|
|
}
|
2011-07-01 16:57:17 +02:00
|
|
|
if (index != -1) {
|
|
|
|
|
const FrameKey &key = d->cache.at(index).first;
|
|
|
|
|
const QString msg =
|
|
|
|
|
_("Using cached disassembly for 0x%1 (0x%2-0x%3) in '%4'/ '%5'")
|
|
|
|
|
.arg(loc.address(), 0, 16)
|
|
|
|
|
.arg(key.startAddress, 0, 16).arg(key.endAddress, 0, 16)
|
|
|
|
|
.arg(loc.functionName(), QDir::toNativeSeparators(loc.fileName()));
|
|
|
|
|
d->engine->showMessage(msg);
|
|
|
|
|
setContentsToEditor(d->cache.at(index).second);
|
2011-09-02 10:26:06 +02:00
|
|
|
d->resetLocationScheduled = false; // In case reset from previous run still pending.
|
2011-07-01 16:57:17 +02:00
|
|
|
} else {
|
|
|
|
|
d->engine->fetchDisassembler(this);
|
|
|
|
|
}
|
2009-08-14 13:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void DisassemblerAgentPrivate::configureMimeType()
|
2010-06-22 14:06:42 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(editor, return);
|
|
|
|
|
|
2010-11-19 09:14:08 +01:00
|
|
|
TextEditor::BaseTextDocument *doc =
|
|
|
|
|
qobject_cast<TextEditor::BaseTextDocument *>(editor->file());
|
2010-06-22 14:06:42 +02:00
|
|
|
QTC_ASSERT(doc, return);
|
|
|
|
|
doc->setMimeType(mimeType);
|
|
|
|
|
|
2011-02-21 16:02:26 +01:00
|
|
|
TextEditor::PlainTextEditorWidget *pe =
|
|
|
|
|
qobject_cast<TextEditor::PlainTextEditorWidget *>(editor->widget());
|
2010-06-22 14:06:42 +02:00
|
|
|
QTC_ASSERT(pe, return);
|
|
|
|
|
|
2010-11-19 09:14:08 +01:00
|
|
|
MimeType mtype = ICore::instance()->mimeDatabase()->findByType(mimeType);
|
|
|
|
|
if (mtype)
|
2010-06-22 14:06:42 +02:00
|
|
|
pe->configure(mtype);
|
2010-11-19 09:14:08 +01:00
|
|
|
else
|
2010-06-22 14:06:42 +02:00
|
|
|
qWarning("Assembler mimetype '%s' not found.", qPrintable(mimeType));
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
QString DisassemblerAgent::mimeType() const
|
2010-06-22 14:06:42 +02:00
|
|
|
{
|
|
|
|
|
return d->mimeType;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void DisassemblerAgent::setMimeType(const QString &mt)
|
2010-06-22 14:06:42 +02:00
|
|
|
{
|
|
|
|
|
if (mt == d->mimeType)
|
|
|
|
|
return;
|
|
|
|
|
d->mimeType = mt;
|
|
|
|
|
if (d->editor)
|
|
|
|
|
d->configureMimeType();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void DisassemblerAgent::setContents(const DisassemblerLines &contents)
|
2011-07-01 16:57:17 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(d, return);
|
|
|
|
|
if (contents.size()) {
|
|
|
|
|
const quint64 startAddress = contents.startAddress();
|
|
|
|
|
const quint64 endAddress = contents.endAddress();
|
|
|
|
|
if (startAddress) {
|
|
|
|
|
FrameKey key;
|
|
|
|
|
key.fileName = d->location.fileName();
|
|
|
|
|
key.functionName = d->location.functionName();
|
|
|
|
|
key.startAddress = startAddress;
|
|
|
|
|
key.endAddress = endAddress;
|
|
|
|
|
d->cache.append(CacheEntry(key, contents));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setContentsToEditor(contents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisassemblerAgent::setContentsToEditor(const DisassemblerLines &contents)
|
2009-08-14 13:04:05 +02:00
|
|
|
{
|
2009-09-28 09:41:07 +02:00
|
|
|
QTC_ASSERT(d, return);
|
2009-08-14 13:04:05 +02:00
|
|
|
using namespace Core;
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
|
|
|
|
EditorManager *editorManager = EditorManager::instance();
|
|
|
|
|
if (!d->editor) {
|
|
|
|
|
QString titlePattern = "Disassembler";
|
|
|
|
|
d->editor = qobject_cast<ITextEditor *>(
|
|
|
|
|
editorManager->openEditorWithContents(
|
2010-01-07 18:17:24 +01:00
|
|
|
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
|
2009-08-18 17:27:30 +02:00
|
|
|
&titlePattern));
|
2010-06-22 14:06:42 +02:00
|
|
|
QTC_ASSERT(d->editor, return);
|
2010-10-25 13:37:46 +02:00
|
|
|
d->editor->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
|
|
|
|
d->editor->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
2010-06-22 14:06:42 +02:00
|
|
|
d->configureMimeType();
|
2010-11-24 18:36:17 +01:00
|
|
|
|
2011-02-21 16:02:26 +01:00
|
|
|
BaseTextEditorWidget *baseTextEdit =
|
|
|
|
|
qobject_cast<BaseTextEditorWidget *>(d->editor->widget());
|
2010-11-24 18:36:17 +01:00
|
|
|
if (baseTextEdit)
|
|
|
|
|
baseTextEdit->setRequestMarkEnabled(true);
|
2009-08-14 13:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-14 15:15:57 +02:00
|
|
|
editorManager->activateEditor(d->editor);
|
2009-08-14 13:04:05 +02:00
|
|
|
|
2010-11-24 15:55:09 +01:00
|
|
|
QPlainTextEdit *plainTextEdit =
|
|
|
|
|
qobject_cast<QPlainTextEdit *>(d->editor->widget());
|
|
|
|
|
QTC_ASSERT(plainTextEdit, return);
|
|
|
|
|
|
|
|
|
|
QString str;
|
|
|
|
|
for (int i = 0, n = contents.size(); i != n; ++i) {
|
2011-04-12 17:32:41 +02:00
|
|
|
str += contents.at(i).toString();
|
2011-02-25 15:27:13 +01:00
|
|
|
str += QLatin1Char('\n');
|
2010-06-22 14:06:42 +02:00
|
|
|
}
|
2010-11-24 15:55:09 +01:00
|
|
|
plainTextEdit->setPlainText(str);
|
|
|
|
|
plainTextEdit->setReadOnly(true);
|
2009-08-14 13:04:05 +02:00
|
|
|
|
2010-12-16 19:06:33 +01:00
|
|
|
d->editor->setDisplayName(_("Disassembler (%1)")
|
|
|
|
|
.arg(d->location.functionName()));
|
2010-11-25 11:51:09 +01:00
|
|
|
|
|
|
|
|
updateBreakpointMarkers();
|
|
|
|
|
updateLocationMarker();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void DisassemblerAgent::updateLocationMarker()
|
2010-11-25 11:51:09 +01:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(d->editor, return);
|
2011-09-02 10:26:06 +02:00
|
|
|
const DisassemblerLines contents = d->contentsAtCurrentLocation();
|
2010-12-16 19:06:33 +01:00
|
|
|
int lineNumber = contents.lineForAddress(d->location.address());
|
|
|
|
|
if (d->location.needsMarker()) {
|
2010-11-25 11:51:09 +01:00
|
|
|
d->editor->markableInterface()->removeMark(d->locationMark);
|
|
|
|
|
if (lineNumber)
|
|
|
|
|
d->editor->markableInterface()->addMark(d->locationMark, lineNumber);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPlainTextEdit *plainTextEdit =
|
|
|
|
|
qobject_cast<QPlainTextEdit *>(d->editor->widget());
|
|
|
|
|
QTC_ASSERT(plainTextEdit, return);
|
2010-11-24 15:55:09 +01:00
|
|
|
QTextCursor tc = plainTextEdit->textCursor();
|
|
|
|
|
QTextBlock block = tc.document()->findBlockByNumber(lineNumber - 1);
|
|
|
|
|
tc.setPosition(block.position());
|
|
|
|
|
plainTextEdit->setTextCursor(tc);
|
2011-07-12 16:46:01 +02:00
|
|
|
plainTextEdit->centerCursor();
|
2009-10-02 11:45:19 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void DisassemblerAgent::updateBreakpointMarkers()
|
2010-11-25 11:51:09 +01:00
|
|
|
{
|
|
|
|
|
if (!d->editor)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
BreakHandler *handler = breakHandler();
|
2011-06-24 16:25:30 +02:00
|
|
|
BreakpointModelIds ids = handler->engineBreakpointIds(d->engine);
|
2010-11-25 11:51:09 +01:00
|
|
|
if (ids.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2011-09-02 10:26:06 +02:00
|
|
|
const DisassemblerLines contents = d->contentsAtCurrentLocation();
|
2010-11-25 11:51:09 +01:00
|
|
|
foreach (TextEditor::ITextMark *marker, d->breakpointMarks)
|
|
|
|
|
d->editor->markableInterface()->removeMark(marker);
|
|
|
|
|
d->breakpointMarks.clear();
|
2011-06-24 16:25:30 +02:00
|
|
|
foreach (BreakpointModelId id, ids) {
|
2011-02-02 17:28:24 +01:00
|
|
|
const quint64 address = handler->response(id).address;
|
2010-11-25 11:51:09 +01:00
|
|
|
if (!address)
|
|
|
|
|
continue;
|
|
|
|
|
const int lineNumber = contents.lineForAddress(address);
|
2010-11-25 14:33:13 +01:00
|
|
|
if (!lineNumber)
|
|
|
|
|
continue;
|
2011-03-21 17:15:02 +01:00
|
|
|
ITextMark *marker = new ITextMark;
|
|
|
|
|
marker->setIcon(handler->icon(id));
|
|
|
|
|
marker->setPriority(ITextMark::NormalPriority);
|
2010-11-25 11:51:09 +01:00
|
|
|
d->breakpointMarks.append(marker);
|
|
|
|
|
d->editor->markableInterface()->addMark(marker, lineNumber);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
quint64 DisassemblerAgent::address() const
|
2009-08-14 13:04:05 +02:00
|
|
|
{
|
2010-12-16 19:06:33 +01:00
|
|
|
return d->location.address();
|
2009-08-14 13:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-16 19:06:33 +01:00
|
|
|
void DisassemblerAgent::setTryMixed(bool on)
|
|
|
|
|
{
|
|
|
|
|
d->tryMixed = on;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|