2010-12-08 12:43:11 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-12-08 12:43:11 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-12-08 12:43:11 +01: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.
|
2010-12-08 12:43:11 +01: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.
|
2010-12-08 12:43:11 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "memoryagent.h"
|
2011-04-19 12:17:48 +02:00
|
|
|
#include "memoryview.h"
|
2010-12-08 12:43:11 +01:00
|
|
|
|
2012-06-03 23:05:58 +02:00
|
|
|
#include "breakhandler.h"
|
2010-12-08 12:43:11 +01:00
|
|
|
#include "debuggerengine.h"
|
2011-04-08 16:18:47 +02:00
|
|
|
#include "debuggerstartparameters.h"
|
2010-12-08 12:43:11 +01:00
|
|
|
#include "debuggercore.h"
|
2011-04-21 15:52:51 +02:00
|
|
|
#include "debuggerinternalconstants.h"
|
2010-12-08 12:43:11 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2011-04-19 12:17:48 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <extensionsystem/invoker.h>
|
2010-12-08 12:43:11 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
#include <QVBoxLayout>
|
2011-04-08 16:18:47 +02:00
|
|
|
|
|
|
|
|
#include <cstring>
|
2010-12-08 12:43:11 +01:00
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2010-12-14 12:29:32 +01:00
|
|
|
// MemoryAgent
|
2010-12-08 12:43:11 +01:00
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/*!
|
2011-01-26 17:22:25 +01:00
|
|
|
\class Debugger::Internal::MemoryAgent
|
2010-12-08 12:43:11 +01:00
|
|
|
|
|
|
|
|
Objects form this class are created in response to user actions in
|
|
|
|
|
the Gui for showing raw memory from the inferior. After creation
|
|
|
|
|
it handles communication between the engine and the bineditor.
|
2011-04-19 12:17:48 +02:00
|
|
|
|
|
|
|
|
Memory can be shown as
|
|
|
|
|
\list
|
|
|
|
|
\o Editor: Create an IEditor using the normal editor factory
|
|
|
|
|
interface (m_editors)
|
|
|
|
|
\o View: Separate top-level view consisting of a Bin Editor widget
|
|
|
|
|
(m_view).
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
Views are updated on the DebuggerEngine::stackFrameCompleted signal.
|
|
|
|
|
An exception are views of class Debugger::RegisterMemoryView tracking the
|
|
|
|
|
content pointed to by a register (eg stack pointer, instruction pointer).
|
|
|
|
|
They are connected to the set/changed signals of
|
|
|
|
|
the engine's register handler.
|
|
|
|
|
|
|
|
|
|
\sa Debugger::MemoryView, Debugger::RegisterMemoryView
|
2010-12-08 12:43:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace { const int DataRange = 1024 * 1024; }
|
|
|
|
|
|
2011-02-25 14:57:21 +01:00
|
|
|
MemoryAgent::MemoryAgent(DebuggerEngine *engine)
|
2010-12-08 12:43:11 +01:00
|
|
|
: QObject(engine), m_engine(engine)
|
|
|
|
|
{
|
2011-07-29 12:00:11 +02:00
|
|
|
QTC_CHECK(engine);
|
2011-04-19 12:17:48 +02:00
|
|
|
connect(engine, SIGNAL(stateChanged(Debugger::DebuggerState)),
|
|
|
|
|
this, SLOT(engineStateChanged(Debugger::DebuggerState)));
|
|
|
|
|
connect(engine, SIGNAL(stackFrameCompleted()), this,
|
|
|
|
|
SLOT(updateContents()));
|
2010-12-08 12:43:11 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
MemoryAgent::~MemoryAgent()
|
2010-12-08 12:43:11 +01:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
closeEditors();
|
|
|
|
|
closeViews();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryAgent::closeEditors()
|
|
|
|
|
{
|
|
|
|
|
if (m_editors.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2010-12-08 12:43:11 +01:00
|
|
|
QList<IEditor *> editors;
|
|
|
|
|
foreach (QPointer<IEditor> editor, m_editors)
|
|
|
|
|
if (editor)
|
|
|
|
|
editors.append(editor.data());
|
2010-12-13 18:17:31 +01:00
|
|
|
EditorManager::instance()->closeEditors(editors);
|
2011-04-19 12:17:48 +02:00
|
|
|
m_editors.clear();
|
2010-12-08 12:43:11 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::closeViews()
|
2011-04-08 16:18:47 +02:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
foreach (const QPointer<MemoryView> &w, m_views)
|
|
|
|
|
if (w)
|
|
|
|
|
w->close();
|
|
|
|
|
m_views.clear();
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::updateMemoryView(quint64 address, quint64 length)
|
2011-04-08 16:18:47 +02:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
m_engine->fetchMemory(this, sender(), address, length);
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::connectBinEditorWidget(QWidget *w)
|
2011-04-08 16:18:47 +02:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
connect(w,
|
|
|
|
|
SIGNAL(dataRequested(Core::IEditor*,quint64)),
|
|
|
|
|
SLOT(fetchLazyData(Core::IEditor*,quint64)));
|
|
|
|
|
connect(w,
|
|
|
|
|
SIGNAL(newWindowRequested(quint64)),
|
|
|
|
|
SLOT(createBinEditor(quint64)));
|
|
|
|
|
connect(w,
|
|
|
|
|
SIGNAL(newRangeRequested(Core::IEditor*,quint64)),
|
|
|
|
|
SLOT(provideNewRange(Core::IEditor*,quint64)));
|
|
|
|
|
connect(w,
|
|
|
|
|
SIGNAL(startOfFileRequested(Core::IEditor*)),
|
|
|
|
|
SLOT(handleStartOfFileRequested(Core::IEditor*)));
|
|
|
|
|
connect(w,
|
2012-03-05 22:30:59 +01:00
|
|
|
SIGNAL(endOfFileRequested(Core::IEditor*)),
|
2011-04-19 12:17:48 +02:00
|
|
|
SLOT(handleEndOfFileRequested(Core::IEditor*)));
|
|
|
|
|
connect(w,
|
|
|
|
|
SIGNAL(dataChanged(Core::IEditor*,quint64,QByteArray)),
|
|
|
|
|
SLOT(handleDataChanged(Core::IEditor*,quint64,QByteArray)));
|
2012-06-03 23:05:58 +02:00
|
|
|
connect(w,
|
|
|
|
|
SIGNAL(dataChanged(Core::IEditor*,quint64,QByteArray)),
|
|
|
|
|
SLOT(handleDataChanged(Core::IEditor*,quint64,QByteArray)));
|
|
|
|
|
connect(w,
|
|
|
|
|
SIGNAL(addWatchpointRequested(quint64, uint)),
|
|
|
|
|
SLOT(handleWatchpointRequest(quint64, uint)));
|
2011-04-08 16:18:47 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags,
|
|
|
|
|
const QList<MemoryMarkup> &ml, const QPoint &pos,
|
|
|
|
|
QString title, QWidget *parent)
|
2010-12-08 12:43:11 +01:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
const bool readOnly = (flags & DebuggerEngine::MemoryReadOnly) != 0;
|
|
|
|
|
if (title.isEmpty())
|
|
|
|
|
title = tr("Memory at 0x%1").arg(addr, 0, 16);
|
|
|
|
|
// Separate view?
|
|
|
|
|
if (flags & DebuggerEngine::MemoryView) {
|
|
|
|
|
// Ask BIN editor plugin for factory service and have it create a bin editor widget.
|
|
|
|
|
QWidget *binEditor = 0;
|
2011-12-21 14:02:52 +01:00
|
|
|
if (QObject *factory = ExtensionSystem::PluginManager::instance()->getObjectByClassName(QLatin1String("BINEditor::BinEditorWidgetFactory")))
|
2011-04-19 12:17:48 +02:00
|
|
|
binEditor = ExtensionSystem::invoke<QWidget *>(factory, "createWidget", (QWidget *)0);
|
|
|
|
|
if (!binEditor)
|
|
|
|
|
return false;
|
|
|
|
|
connectBinEditorWidget(binEditor);
|
|
|
|
|
MemoryView::setBinEditorReadOnly(binEditor, readOnly);
|
|
|
|
|
MemoryView::setBinEditorNewWindowRequestAllowed(binEditor, true);
|
|
|
|
|
MemoryView *topLevel = 0;
|
|
|
|
|
// Memory view tracking register value, providing its own updating mechanism.
|
|
|
|
|
if (flags & DebuggerEngine::MemoryTrackRegister) {
|
|
|
|
|
RegisterMemoryView *rmv = new RegisterMemoryView(binEditor, parent);
|
|
|
|
|
rmv->init(m_engine->registerHandler(), int(addr));
|
|
|
|
|
topLevel = rmv;
|
|
|
|
|
} else {
|
|
|
|
|
// Ordinary memory view
|
|
|
|
|
MemoryView::setBinEditorMarkup(binEditor, ml);
|
|
|
|
|
MemoryView::setBinEditorRange(binEditor, addr, MemoryAgent::DataRange, MemoryAgent::BinBlockSize);
|
|
|
|
|
topLevel = new MemoryView(binEditor, parent);
|
|
|
|
|
topLevel->setWindowTitle(title);
|
|
|
|
|
}
|
|
|
|
|
m_views << topLevel;
|
|
|
|
|
topLevel->move(pos);
|
|
|
|
|
topLevel->show();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// Editor: Register tracking not supported.
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(!(flags & DebuggerEngine::MemoryTrackRegister), return false);
|
2011-04-19 12:17:48 +02:00
|
|
|
if (!title.endsWith(QLatin1Char('$')))
|
|
|
|
|
title.append(QLatin1String(" $"));
|
2012-05-08 09:43:14 +02:00
|
|
|
IEditor *editor = EditorManager::openEditorWithContents(
|
2011-04-19 12:17:48 +02:00
|
|
|
Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title);
|
|
|
|
|
if (!editor)
|
|
|
|
|
return false;
|
|
|
|
|
editor->setProperty(Constants::OPENED_BY_DEBUGGER, QVariant(true));
|
|
|
|
|
editor->setProperty(Constants::OPENED_WITH_MEMORY, QVariant(true));
|
|
|
|
|
QWidget *editorBinEditor = editor->widget();
|
|
|
|
|
connectBinEditorWidget(editorBinEditor);
|
|
|
|
|
MemoryView::setBinEditorReadOnly(editorBinEditor, readOnly);
|
|
|
|
|
MemoryView::setBinEditorNewWindowRequestAllowed(editorBinEditor, true);
|
|
|
|
|
MemoryView::setBinEditorRange(editorBinEditor, addr, MemoryAgent::DataRange, MemoryAgent::BinBlockSize);
|
|
|
|
|
MemoryView::setBinEditorMarkup(editorBinEditor, ml);
|
|
|
|
|
m_editors << editor;
|
2012-05-08 09:43:14 +02:00
|
|
|
EditorManager::activateEditor(editor);
|
2011-04-19 12:17:48 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryAgent::createBinEditor(quint64 addr, unsigned flags,
|
|
|
|
|
const QList<MemoryMarkup> &ml, const QPoint &pos,
|
|
|
|
|
const QString &title, QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
if (!doCreateBinEditor(addr, flags, ml, pos, title, parent))
|
2010-12-08 12:43:11 +01:00
|
|
|
showMessageBox(QMessageBox::Warning,
|
2011-04-19 12:17:48 +02:00
|
|
|
tr("No Memory Viewer Available"),
|
2010-12-08 12:43:11 +01:00
|
|
|
tr("The memory contents cannot be shown as no viewer plugin "
|
|
|
|
|
"for binary data has been loaded."));
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::createBinEditor(quint64 addr)
|
2010-12-08 12:43:11 +01:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
createBinEditor(addr, 0, QList<MemoryMarkup>(), QPoint(), QString(), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MemoryAgent::fetchLazyData(IEditor *, quint64 block)
|
|
|
|
|
{
|
|
|
|
|
m_engine->fetchMemory(this, sender(), BinBlockSize * block, BinBlockSize);
|
2010-12-08 12:43:11 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void MemoryAgent::addLazyData(QObject *editorToken, quint64 addr,
|
2010-12-08 12:43:11 +01:00
|
|
|
const QByteArray &ba)
|
|
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
QWidget *w = qobject_cast<QWidget *>(editorToken);
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(w, return);
|
2011-04-19 12:17:48 +02:00
|
|
|
MemoryView::binEditorAddData(w, addr, ba);
|
2010-12-08 12:43:11 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::provideNewRange(IEditor *, quint64 address)
|
2010-12-08 12:43:11 +01:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
QWidget *w = qobject_cast<QWidget *>(sender());
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(w, return);
|
2011-04-19 12:17:48 +02:00
|
|
|
MemoryView::setBinEditorRange(w, address, DataRange, BinBlockSize);
|
2010-12-08 12:43:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Since we are not dealing with files, we take these signals to mean
|
|
|
|
|
// "move to start/end of range". This seems to make more sense than
|
|
|
|
|
// jumping to the start or end of the address space, respectively.
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::handleStartOfFileRequested(IEditor *)
|
2010-12-08 12:43:11 +01:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
QWidget *w = qobject_cast<QWidget *>(sender());
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(w, return);
|
2011-04-19 12:17:48 +02:00
|
|
|
MemoryView::binEditorSetCursorPosition(w, 0);
|
2010-12-08 12:43:11 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::handleEndOfFileRequested(IEditor *)
|
2010-12-08 12:43:11 +01:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
QWidget *w = qobject_cast<QWidget *>(sender());
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(w, return);
|
2011-04-19 12:17:48 +02:00
|
|
|
MemoryView::binEditorSetCursorPosition(w, DataRange - 1);
|
2010-12-08 12:43:11 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::handleDataChanged(IEditor *,
|
2011-02-25 13:21:54 +01:00
|
|
|
quint64 addr, const QByteArray &data)
|
|
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
m_engine->changeMemory(this, sender(), addr, data);
|
2011-02-25 13:21:54 +01:00
|
|
|
}
|
|
|
|
|
|
2012-06-03 23:05:58 +02:00
|
|
|
void MemoryAgent::handleWatchpointRequest(quint64 address, uint size)
|
|
|
|
|
{
|
|
|
|
|
m_engine->breakHandler()->setWatchpointAtAddress(address, size);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-14 12:29:32 +01:00
|
|
|
void MemoryAgent::updateContents()
|
2010-12-13 18:17:31 +01:00
|
|
|
{
|
2011-04-19 12:17:48 +02:00
|
|
|
foreach (const QPointer<Core::IEditor> &e, m_editors)
|
|
|
|
|
if (e)
|
|
|
|
|
MemoryView::binEditorUpdateContents(e->widget());
|
|
|
|
|
// Update all views except register views, which trigger on
|
|
|
|
|
// register value set/changed.
|
|
|
|
|
foreach (const QPointer<MemoryView> &w, m_views)
|
|
|
|
|
if (w && !qobject_cast<RegisterMemoryView *>(w.data()))
|
|
|
|
|
w->updateContents();
|
2010-12-13 18:17:31 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-16 10:44:21 +01:00
|
|
|
bool MemoryAgent::hasVisibleEditor() const
|
|
|
|
|
{
|
|
|
|
|
QList<IEditor *> visible = EditorManager::instance()->visibleEditors();
|
|
|
|
|
foreach (QPointer<IEditor> editor, m_editors)
|
|
|
|
|
if (visible.contains(editor.data()))
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-19 12:17:48 +02:00
|
|
|
void MemoryAgent::engineStateChanged(Debugger::DebuggerState s)
|
|
|
|
|
{
|
|
|
|
|
switch (s) {
|
|
|
|
|
case DebuggerFinished:
|
|
|
|
|
closeViews();
|
|
|
|
|
foreach (const QPointer<IEditor> &editor, m_editors)
|
|
|
|
|
if (editor) { // Prevent triggering updates, etc.
|
|
|
|
|
MemoryView::setBinEditorReadOnly(editor->widget(), true);
|
|
|
|
|
editor->widget()->disconnect(this);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 16:18:47 +02:00
|
|
|
bool MemoryAgent::isBigEndian(const ProjectExplorer::Abi &a)
|
|
|
|
|
{
|
|
|
|
|
switch (a.architecture()) {
|
|
|
|
|
case ProjectExplorer::Abi::UnknownArchitecture:
|
|
|
|
|
case ProjectExplorer::Abi::X86Architecture:
|
|
|
|
|
case ProjectExplorer::Abi::ItaniumArchitecture: // Configureable
|
|
|
|
|
case ProjectExplorer::Abi::ArmArchitecture: // Configureable
|
2011-09-22 14:26:10 +00:00
|
|
|
case ProjectExplorer::Abi::ShArchitecture: // Configureable
|
2011-04-08 16:18:47 +02:00
|
|
|
break;
|
2011-08-31 09:55:34 +00:00
|
|
|
case ProjectExplorer::Abi::MipsArchitecture: // Configureable
|
2011-04-08 16:18:47 +02:00
|
|
|
case ProjectExplorer::Abi::PowerPCArchitecture: // Configureable
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read a POD variable from a memory location. Swap bytes if endianness differs
|
|
|
|
|
template <class POD> POD readPod(const unsigned char *data, bool swapByteOrder)
|
|
|
|
|
{
|
|
|
|
|
POD pod = 0;
|
|
|
|
|
if (swapByteOrder) {
|
|
|
|
|
unsigned char *target = reinterpret_cast<unsigned char *>(&pod) + sizeof(POD) - 1;
|
|
|
|
|
for (size_t i = 0; i < sizeof(POD); i++)
|
|
|
|
|
*target-- = data[i];
|
|
|
|
|
} else {
|
|
|
|
|
std::memcpy(&pod, data, sizeof(POD));
|
|
|
|
|
}
|
|
|
|
|
return pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read memory from debuggee
|
|
|
|
|
quint64 MemoryAgent::readInferiorPointerValue(const unsigned char *data, const ProjectExplorer::Abi &a)
|
|
|
|
|
{
|
|
|
|
|
const bool swapByteOrder = isBigEndian(a) != isBigEndian(ProjectExplorer::Abi::hostAbi());
|
|
|
|
|
return a.wordWidth() == 32 ? readPod<quint32>(data, swapByteOrder) :
|
|
|
|
|
readPod<quint64>(data, swapByteOrder);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-08 12:43:11 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
2011-04-19 12:17:48 +02:00
|
|
|
;
|