2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
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"
|
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 "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
|
|
|
|
2021-03-01 08:59:44 +01:00
|
|
|
#include <utils/aspects.h>
|
2022-02-23 17:11:20 +01:00
|
|
|
#include <utils/mimeutils.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
|
|
|
|
2022-07-05 15:37:08 +02:00
|
|
|
namespace Debugger::Internal {
|
2009-08-12 10:51:25 +02:00
|
|
|
|
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)
|
2019-05-28 13:49:26 +02:00
|
|
|
: TextMark(Utils::FilePath(), lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(bp)
|
2015-08-31 16:35:24 +02:00
|
|
|
{
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
setIcon(bp->icon());
|
2015-08-31 16:35:24 +02:00
|
|
|
setPriority(TextMark::NormalPriority);
|
|
|
|
|
}
|
|
|
|
|
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
bool isClickable() const final { return true; }
|
|
|
|
|
|
|
|
|
|
void clicked() final
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_bp, return);
|
|
|
|
|
m_bp->deleteGlobalOrThisBreakpoint();
|
|
|
|
|
}
|
2015-08-31 16:35:24 +02:00
|
|
|
|
|
|
|
|
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:
|
2018-07-23 22:28:49 +02:00
|
|
|
FrameKey() = default;
|
2011-07-01 16:57:17 +02:00
|
|
|
inline bool matches(const Location &loc) const;
|
|
|
|
|
|
|
|
|
|
QString functionName;
|
|
|
|
|
QString fileName;
|
2018-07-23 22:28:49 +02:00
|
|
|
quint64 startAddress = 0;
|
|
|
|
|
quint64 endAddress = 0;
|
2011-07-01 16:57:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool FrameKey::matches(const Location &loc) const
|
|
|
|
|
{
|
|
|
|
|
return loc.address() >= startAddress
|
2011-09-02 10:26:06 +02:00
|
|
|
&& loc.address() <= endAddress
|
2020-01-02 12:37:57 +01:00
|
|
|
&& loc.fileName().toString() == fileName
|
2011-09-02 10:26:06 +02:00
|
|
|
&& loc.functionName() == functionName;
|
2011-07-01 16:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
2018-07-23 22:28:49 +02:00
|
|
|
using CacheEntry = QPair<FrameKey, DisassemblerLines>;
|
2011-07-01 16:57:17 +02:00
|
|
|
|
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)
|
2018-07-23 22:28:49 +02:00
|
|
|
: document(nullptr),
|
2015-07-17 16:33:25 +02:00
|
|
|
engine(engine),
|
2019-05-28 13:49:26 +02:00
|
|
|
locationMark(engine, Utils::FilePath(), 0),
|
2016-06-07 17:04:53 +02: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
|
|
|
{
|
2019-01-18 20:25:30 +01:00
|
|
|
EditorManager::closeDocuments({document});
|
2018-07-23 22:28:49 +02:00
|
|
|
document = nullptr;
|
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))
|
2017-10-19 17:30:30 +02:00
|
|
|
{
|
2021-03-01 08:59:44 +01:00
|
|
|
connect(&debuggerSettings()->intelFlavor, &Utils::BaseAspect::changed,
|
2017-10-19 17:30:30 +02:00
|
|
|
this, &DisassemblerAgent::reload);
|
|
|
|
|
}
|
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;
|
2018-07-23 22:28:49 +02:00
|
|
|
d = nullptr;
|
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
|
|
|
d->cache.removeAt(index);
|
2020-03-06 10:15:26 +01:00
|
|
|
index = -1;
|
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 =
|
2016-06-07 17:04:53 +02:00
|
|
|
QString("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)
|
2020-01-02 12:37:57 +01:00
|
|
|
.arg(loc.functionName(), loc.fileName().toUserOutput());
|
2011-07-01 16:57:17 +02:00
|
|
|
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
|
|
|
|
2017-03-02 12:07:11 +01:00
|
|
|
Utils::MimeType mtype = Utils::mimeTypeForName(mimeType);
|
2015-02-04 09:32:46 +01:00
|
|
|
if (mtype.isValid()) {
|
2022-04-29 12:43:37 +02:00
|
|
|
const QList<IEditor *> editors = DocumentModel::editorsForDocument(document);
|
|
|
|
|
for (IEditor *editor : editors)
|
2020-02-11 14:00:09 +01:00
|
|
|
if (auto widget = TextEditorWidget::fromEditor(editor))
|
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;
|
2020-01-02 12:37:57 +01:00
|
|
|
key.fileName = d->location.fileName().toString();
|
2011-07-01 16:57:17 +02:00
|
|
|
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) {
|
2018-10-07 22:38:47 +03:00
|
|
|
QString titlePattern = "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);
|
2020-02-11 14:00:09 +01:00
|
|
|
if (auto widget = TextEditorWidget::fromEditor(editor)) {
|
2014-05-07 11:51:40 +02:00
|
|
|
widget->setReadOnly(true);
|
|
|
|
|
widget->setRequestMarkEnabled(true);
|
|
|
|
|
}
|
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);
|
2015-09-16 16:19:15 +02:00
|
|
|
d->document->setTemporary(true);
|
|
|
|
|
// FIXME: This is accumulating quite a bit out-of-band data.
|
|
|
|
|
// Make that a proper TextDocument reimplementation.
|
2014-05-07 11:51:40 +02:00
|
|
|
d->document->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
|
|
|
|
d->document->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
2020-01-02 12:37:57 +01:00
|
|
|
d->document->setProperty(Debugger::Constants::DISASSEMBLER_SOURCE_FILE, d->location.fileName().toString());
|
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
|
|
|
|
2016-06-07 17:04:53 +02:00
|
|
|
d->document->setPreferredDisplayName(QString("Disassembler (%1)")
|
2010-12-16 19:06:33 +01:00
|
|
|
.arg(d->location.functionName()));
|
2010-11-25 11:51:09 +01:00
|
|
|
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
const Breakpoints bps = d->engine->breakHandler()->breakpoints();
|
2020-05-12 13:01:44 +02:00
|
|
|
for (const Breakpoint &bp : bps)
|
2015-08-31 16:35:24 +02:00
|
|
|
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
|
|
|
{
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
if (!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
|
|
|
}
|
|
|
|
|
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
d->locationMark.updateIcon();
|
|
|
|
|
|
2014-05-07 11:51:40 +02:00
|
|
|
// Center cursor.
|
|
|
|
|
if (EditorManager::currentDocument() == d->document)
|
2018-07-23 22:28:49 +02:00
|
|
|
if (auto textEditor = qobject_cast<BaseTextEditor *>(EditorManager::currentEditor()))
|
2014-05-07 11:51:40 +02:00
|
|
|
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;
|
|
|
|
|
|
2021-02-16 23:09:02 +01:00
|
|
|
for (DisassemblerBreakpointMarker *marker : qAsConst(d->breakpointMarks)) {
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
if (marker->m_bp == bp) {
|
2015-08-31 16:35:24 +02:00
|
|
|
d->breakpointMarks.removeOne(marker);
|
|
|
|
|
d->document->removeMark(marker);
|
|
|
|
|
delete marker;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DisassemblerAgent::updateBreakpointMarker(const Breakpoint &bp)
|
|
|
|
|
{
|
|
|
|
|
removeBreakpointMarker(bp);
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
const quint64 address = bp->address();
|
2015-08-31 16:35:24 +02:00
|
|
|
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.
|
Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-07-31 12:30:48 +02:00
|
|
|
if (bp->type() == BreakpointByFileAndLine) {
|
2015-08-31 16:35:24 +02:00
|
|
|
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);
|
2018-10-02 12:53:07 +02:00
|
|
|
QTC_ASSERT(d->document, return);
|
2015-08-31 16:35:24 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2022-07-05 15:37:08 +02:00
|
|
|
} // Debugger::Internal
|