2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-08-12 10:51:25 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 17:14:20 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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
|
|
|
|
2010-11-25 11:51:09 +01:00
|
|
|
#include "breakhandler.h"
|
2014-05-26 15:24:27 +02:00
|
|
|
#include "debuggeractions.h"
|
2012-06-28 10:00:04 +02:00
|
|
|
#include "debuggercore.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerengine.h"
|
2011-04-21 15:52:51 +02:00
|
|
|
#include "debuggerinternalconstants.h"
|
2012-06-28 10:00:04 +02:00
|
|
|
#include "debuggerstartparameters.h"
|
2009-09-25 15:02:16 +02:00
|
|
|
#include "debuggerstringutils.h"
|
2012-06-28 10:00:04 +02:00
|
|
|
#include "disassemblerlines.h"
|
2015-07-20 09:37:54 +02:00
|
|
|
#include "sourceutils.h"
|
2009-08-12 10:51:25 +02:00
|
|
|
|
2009-08-14 13:04:05 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <coreplugin/editormanager/documentmodel.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2009-08-14 13:04:05 +02:00
|
|
|
|
2015-02-26 15:29:28 +01:00
|
|
|
#include <texteditor/textmark.h>
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/textdocument.h>
|
|
|
|
|
#include <texteditor/texteditor.h>
|
2009-08-14 13:04:05 +02:00
|
|
|
|
2015-02-04 09:32:46 +01:00
|
|
|
#include <utils/mimetypes/mimedatabase.h>
|
2009-08-14 13:04:05 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTextBlock>
|
|
|
|
|
#include <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 {
|
|
|
|
|
|
2015-08-31 16:35:24 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DisassemblerBreakpointMarker
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// The red blob on the left side in the cpp editor.
|
|
|
|
|
class DisassemblerBreakpointMarker : public TextMark
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DisassemblerBreakpointMarker(const Breakpoint &bp, int lineNumber)
|
|
|
|
|
: TextMark(QString(), lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(bp)
|
|
|
|
|
{
|
|
|
|
|
setIcon(bp.icon());
|
|
|
|
|
setPriority(TextMark::NormalPriority);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isClickable() const { return true; }
|
|
|
|
|
void clicked() { m_bp.removeBreakpoint(); }
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Breakpoint m_bp;
|
|
|
|
|
};
|
|
|
|
|
|
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:
|
2015-07-17 16:33:25 +02:00
|
|
|
DisassemblerAgentPrivate(DebuggerEngine *engine);
|
2010-12-14 12:29:32 +01:00
|
|
|
~DisassemblerAgentPrivate();
|
2010-06-22 14:06:42 +02:00
|
|
|
void configureMimeType();
|
2015-08-31 16:35:24 +02:00
|
|
|
int lineForAddress(quint64 address) const;
|
2010-02-01 16:14:57 +01:00
|
|
|
|
2010-11-24 15:55:09 +01:00
|
|
|
public:
|
2014-09-22 18:43:31 +02:00
|
|
|
QPointer<TextDocument> document;
|
2010-12-16 19:06:33 +01:00
|
|
|
Location location;
|
2010-06-16 11:08:54 +02:00
|
|
|
QPointer<DebuggerEngine> engine;
|
2015-07-17 16:33:25 +02:00
|
|
|
LocationMark locationMark;
|
2015-08-31 16:35:24 +02:00
|
|
|
QList<DisassemblerBreakpointMarker *> 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 resetLocationScheduled;
|
2009-08-14 13:04:05 +02:00
|
|
|
};
|
|
|
|
|
|
2015-07-17 16:33:25 +02:00
|
|
|
DisassemblerAgentPrivate::DisassemblerAgentPrivate(DebuggerEngine *engine)
|
2014-05-07 11:51:40 +02:00
|
|
|
: document(0),
|
2015-07-17 16:33:25 +02:00
|
|
|
engine(engine),
|
|
|
|
|
locationMark(engine, QString(), 0),
|
2011-03-18 18:33:20 +01:00
|
|
|
mimeType(_("text/x-qtcreator-generic-asm")),
|
2011-09-02 10:26:06 +02:00
|
|
|
resetLocationScheduled(false)
|
2015-07-17 16:33:25 +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
|
|
|
{
|
2014-05-07 11:51:40 +02:00
|
|
|
EditorManager::closeDocuments(QList<IDocument *>() << document);
|
|
|
|
|
document = 0;
|
2012-02-21 16:24:12 +01:00
|
|
|
qDeleteAll(breakpointMarks);
|
2010-11-25 11:51:09 +01:00
|
|
|
}
|
2010-11-24 15:55:09 +01:00
|
|
|
|
2015-08-31 16:35:24 +02:00
|
|
|
int DisassemblerAgentPrivate::lineForAddress(quint64 address) const
|
2011-09-02 10:26:06 +02:00
|
|
|
{
|
|
|
|
|
for (int i = 0, n = cache.size(); i != n; ++i) {
|
|
|
|
|
const CacheEntry &entry = cache.at(i);
|
|
|
|
|
if (entry.first.matches(location))
|
2015-08-31 16:35:24 +02:00
|
|
|
return entry.second.lineForAddress(address);
|
2011-09-02 10:26:06 +02:00
|
|
|
}
|
2015-08-31 16:35:24 +02:00
|
|
|
return 0;
|
2011-09-02 10:26:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// 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)
|
2015-07-17 16:33:25 +02:00
|
|
|
: d(new DisassemblerAgentPrivate(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
|
|
|
{
|
2014-05-07 11:51:40 +02:00
|
|
|
if (!d->document)
|
2010-11-25 11:51:09 +01:00
|
|
|
return;
|
2011-09-02 10:26:06 +02:00
|
|
|
if (d->resetLocationScheduled) {
|
|
|
|
|
d->resetLocationScheduled = false;
|
2014-07-18 15:29:04 +02:00
|
|
|
d->document->removeMark(&d->locationMark);
|
2011-03-18 18:33:20 +01:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2014-05-26 15:24:27 +02:00
|
|
|
void DisassemblerAgent::reload()
|
|
|
|
|
{
|
|
|
|
|
d->cache.clear();
|
|
|
|
|
d->engine->fetchDisassembler(this);
|
|
|
|
|
}
|
|
|
|
|
|
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.
|
2014-07-22 16:29:15 +02:00
|
|
|
if (d->cache.at(index).first.endAddress - loc.address() < 24) {
|
2011-07-01 16:57:17 +02:00
|
|
|
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 =
|
2014-04-17 14:09:47 +02:00
|
|
|
_("Using cached disassembly for 0x%1 (0x%2-0x%3) in \"%4\"/ \"%5\"")
|
2011-07-01 16:57:17 +02:00
|
|
|
.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);
|
2014-05-07 11:51:40 +02:00
|
|
|
setContentsToDocument(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
|
|
|
{
|
2014-05-07 11:51:40 +02:00
|
|
|
QTC_ASSERT(document, return);
|
2010-06-22 14:06:42 +02:00
|
|
|
|
2014-05-07 11:51:40 +02:00
|
|
|
document->setMimeType(mimeType);
|
2010-06-22 14:06:42 +02:00
|
|
|
|
2015-02-04 09:32:46 +01:00
|
|
|
Utils::MimeDatabase mdb;
|
|
|
|
|
Utils::MimeType mtype = mdb.mimeTypeForName(mimeType);
|
|
|
|
|
if (mtype.isValid()) {
|
2014-05-07 16:25:04 +02:00
|
|
|
foreach (IEditor *editor, DocumentModel::editorsForDocument(document))
|
2014-09-26 11:37:54 +02:00
|
|
|
if (TextEditorWidget *widget = qobject_cast<TextEditorWidget *>(editor->widget()))
|
2015-02-03 09:18:57 +01:00
|
|
|
widget->configureGenericHighlighter();
|
2014-05-07 11:51:40 +02:00
|
|
|
} else {
|
2010-06-22 14:06:42 +02:00
|
|
|
qWarning("Assembler mimetype '%s' not found.", qPrintable(mimeType));
|
2014-05-07 11:51:40 +02:00
|
|
|
}
|
2010-06-22 14:06:42 +02:00
|
|
|
}
|
|
|
|
|
|
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;
|
2014-05-07 11:51:40 +02:00
|
|
|
if (d->document)
|
2010-06-22 14:06:42 +02:00
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-07 11:51:40 +02:00
|
|
|
setContentsToDocument(contents);
|
2011-07-01 16:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-07 11:51:40 +02:00
|
|
|
void DisassemblerAgent::setContentsToDocument(const DisassemblerLines &contents)
|
2009-08-14 13:04:05 +02:00
|
|
|
{
|
2009-09-28 09:41:07 +02:00
|
|
|
QTC_ASSERT(d, return);
|
2014-05-07 11:51:40 +02:00
|
|
|
if (!d->document) {
|
2011-12-21 14:02:52 +01:00
|
|
|
QString titlePattern = QLatin1String("Disassembler");
|
2014-05-07 11:51:40 +02:00
|
|
|
IEditor *editor = EditorManager::openEditorWithContents(
|
2010-01-07 18:17:24 +01:00
|
|
|
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
|
2014-05-07 11:51:40 +02:00
|
|
|
&titlePattern);
|
|
|
|
|
QTC_ASSERT(editor, return);
|
2014-09-26 11:37:54 +02:00
|
|
|
if (TextEditorWidget *widget = qobject_cast<TextEditorWidget *>(editor->widget())) {
|
2014-05-07 11:51:40 +02:00
|
|
|
widget->setReadOnly(true);
|
|
|
|
|
widget->setRequestMarkEnabled(true);
|
|
|
|
|
}
|
2015-07-20 09:37:54 +02:00
|
|
|
// FIXME: This is accumulating quite a bit out-of-band data.
|
|
|
|
|
// Make that a proper TextDocument reimplementation.
|
2014-09-22 18:43:31 +02:00
|
|
|
d->document = qobject_cast<TextDocument *>(editor->document());
|
2014-05-07 11:51:40 +02:00
|
|
|
QTC_ASSERT(d->document, return);
|
|
|
|
|
d->document->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
|
|
|
|
d->document->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
2015-07-20 09:37:54 +02:00
|
|
|
d->document->setProperty(Debugger::Constants::DISASSEMBLER_SOURCE_FILE, d->location.fileName());
|
2010-06-22 14:06:42 +02:00
|
|
|
d->configureMimeType();
|
2014-07-23 10:41:34 +02:00
|
|
|
} else {
|
|
|
|
|
EditorManager::activateEditorForDocument(d->document);
|
2009-08-14 13:04:05 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-07 11:51:40 +02:00
|
|
|
d->document->setPlainText(contents.toString());
|
2010-11-24 15:55:09 +01:00
|
|
|
|
2015-02-25 14:36:03 +02:00
|
|
|
d->document->setPreferredDisplayName(_("Disassembler (%1)")
|
2010-12-16 19:06:33 +01:00
|
|
|
.arg(d->location.functionName()));
|
2010-11-25 11:51:09 +01:00
|
|
|
|
2015-08-31 16:35:24 +02:00
|
|
|
Breakpoints bps = breakHandler()->engineBreakpoints(d->engine);
|
|
|
|
|
foreach (Breakpoint bp, bps)
|
|
|
|
|
updateBreakpointMarker(bp);
|
|
|
|
|
|
2010-11-25 11:51:09 +01:00
|
|
|
updateLocationMarker();
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void DisassemblerAgent::updateLocationMarker()
|
2010-11-25 11:51:09 +01:00
|
|
|
{
|
2014-05-07 11:51:40 +02:00
|
|
|
QTC_ASSERT(d->document, return);
|
2015-08-31 16:35:24 +02:00
|
|
|
int lineNumber = d->lineForAddress(d->location.address());
|
2010-12-16 19:06:33 +01:00
|
|
|
if (d->location.needsMarker()) {
|
2014-07-18 15:29:04 +02:00
|
|
|
d->document->removeMark(&d->locationMark);
|
2014-05-07 11:51:40 +02:00
|
|
|
d->locationMark.updateLineNumber(lineNumber);
|
2014-07-18 15:29:04 +02:00
|
|
|
d->document->addMark(&d->locationMark);
|
2010-11-25 11:51:09 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-07 11:51:40 +02:00
|
|
|
// Center cursor.
|
|
|
|
|
if (EditorManager::currentDocument() == d->document)
|
|
|
|
|
if (BaseTextEditor *textEditor = qobject_cast<BaseTextEditor *>(EditorManager::currentEditor()))
|
|
|
|
|
textEditor->gotoLine(lineNumber);
|
2009-10-02 11:45:19 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:35:24 +02:00
|
|
|
void DisassemblerAgent::removeBreakpointMarker(const Breakpoint &bp)
|
2010-11-25 11:51:09 +01:00
|
|
|
{
|
2014-05-07 11:51:40 +02:00
|
|
|
if (!d->document)
|
2010-11-25 11:51:09 +01:00
|
|
|
return;
|
|
|
|
|
|
2015-08-31 16:35:24 +02:00
|
|
|
BreakpointModelId id = bp.id();
|
|
|
|
|
foreach (DisassemblerBreakpointMarker *marker, d->breakpointMarks) {
|
|
|
|
|
if (marker->m_bp.id() == id) {
|
|
|
|
|
d->breakpointMarks.removeOne(marker);
|
|
|
|
|
d->document->removeMark(marker);
|
|
|
|
|
delete marker;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisassemblerAgent::updateBreakpointMarker(const Breakpoint &bp)
|
|
|
|
|
{
|
|
|
|
|
removeBreakpointMarker(bp);
|
|
|
|
|
const quint64 address = bp.response().address;
|
|
|
|
|
if (!address)
|
2010-11-25 11:51:09 +01:00
|
|
|
return;
|
|
|
|
|
|
2015-08-31 16:35:24 +02:00
|
|
|
int lineNumber = d->lineForAddress(address);
|
|
|
|
|
if (!lineNumber)
|
|
|
|
|
return;
|
2015-07-20 09:37:54 +02:00
|
|
|
|
2015-08-31 16:35:24 +02:00
|
|
|
// HACK: If it's a FileAndLine breakpoint, and there's a source line
|
|
|
|
|
// above, move the marker up there. That allows setting and removing
|
|
|
|
|
// normal breakpoints from within the disassembler view.
|
|
|
|
|
if (bp.type() == BreakpointByFileAndLine) {
|
|
|
|
|
ContextData context = getLocationContext(d->document, lineNumber - 1);
|
|
|
|
|
if (context.type == LocationByFile)
|
|
|
|
|
--lineNumber;
|
2010-11-25 11:51:09 +01:00
|
|
|
}
|
2015-08-31 16:35:24 +02:00
|
|
|
|
|
|
|
|
auto marker = new DisassemblerBreakpointMarker(bp, lineNumber);
|
|
|
|
|
d->breakpointMarks.append(marker);
|
|
|
|
|
d->document->addMark(marker);
|
2010-11-25 11:51:09 +01:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2009-08-12 10:51:25 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|