Commit 29580019 authored by Arvid Ephraim Picciani's avatar Arvid Ephraim Picciani
Browse files

Adapt Lldb to dissasembler changes

parent c6193608
...@@ -35,6 +35,7 @@ HEADERS += breakhandler.h \ ...@@ -35,6 +35,7 @@ HEADERS += breakhandler.h \
debuggerstringutils.h \ debuggerstringutils.h \
debuggertooltip.h \ debuggertooltip.h \
debuggeruiswitcher.h \ debuggeruiswitcher.h \
disassemblerlines.h \
logwindow.h \ logwindow.h \
moduleshandler.h \ moduleshandler.h \
moduleswindow.h \ moduleswindow.h \
...@@ -73,6 +74,7 @@ SOURCES += breakhandler.cpp \ ...@@ -73,6 +74,7 @@ SOURCES += breakhandler.cpp \
debuggerstreamops.cpp \ debuggerstreamops.cpp \
debuggertooltip.cpp \ debuggertooltip.cpp \
debuggeruiswitcher.cpp \ debuggeruiswitcher.cpp \
disassemblerlines.cpp \
logwindow.cpp \ logwindow.cpp \
moduleshandler.cpp \ moduleshandler.cpp \
moduleswindow.cpp \ moduleswindow.cpp \
......
...@@ -405,55 +405,5 @@ quint64 DisassemblerViewAgent::addressFromDisassemblyLine(const QString &line) ...@@ -405,55 +405,5 @@ quint64 DisassemblerViewAgent::addressFromDisassemblyLine(const QString &line)
return DisassemblerLine(line).address; return DisassemblerLine(line).address;
} }
DisassemblerLine::DisassemblerLine(const QString &unparsed)
{
// Mac gdb has an overflow reporting 64bit addresses causing the instruction
// to follow the last digit "0x000000013fff4810mov 1,1". Truncate here.
const int pos = qMin(unparsed.indexOf(QLatin1Char(' ')), 19);
if (pos < 0) {
address = 0;
data = unparsed;
return;
}
QString addr = unparsed.left(pos);
// MSVC 64bit: Remove 64bit separator 00000000`00a45000'.
if (addr.size() >= 9 && addr.at(8) == QLatin1Char('`'))
addr.remove(8, 1);
if (addr.endsWith(':')) // clang
addr.chop(1);
if (addr.startsWith(QLatin1String("0x")))
addr.remove(0, 2);
bool ok;
address = addr.toULongLong(&ok, 16);
if (address)
data = unparsed.mid(pos + 1);
else
data = unparsed;
}
int DisassemblerLines::lineForAddress(quint64 address) const
{
return m_rowCache.value(address);
}
bool DisassemblerLines::coversAddress(quint64 address) const
{
return m_rowCache.value(address) != 0;
}
void DisassemblerLines::appendComment(const QString &comment)
{
DisassemblerLine dl;
dl.data = comment;
m_data.append(dl);
}
void DisassemblerLines::appendLine(const DisassemblerLine &dl)
{
m_data.append(dl);
m_rowCache[dl.address] = m_data.size();
}
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include <QtCore/QPointer> #include <QtCore/QPointer>
#include <QtCore/QVector> #include <QtCore/QVector>
#include "disassemblerlines.h"
namespace Core { namespace Core {
class IEditor; class IEditor;
} }
...@@ -76,34 +78,6 @@ private: ...@@ -76,34 +78,6 @@ private:
QPointer<Debugger::DebuggerEngine> m_engine; QPointer<Debugger::DebuggerEngine> m_engine;
}; };
class DisassemblerLine
{
public:
DisassemblerLine() : address(0) {}
DisassemblerLine(const QString &unparsed);
quint64 address;
QString data;
};
class DisassemblerLines
{
public:
DisassemblerLines() {}
bool coversAddress(quint64 address) const;
void appendLine(const DisassemblerLine &dl);
void appendComment(const QString &comment);
int size() const { return m_data.size(); }
const DisassemblerLine &at(int i) const { return m_data.at(i); }
int lineForAddress(quint64 address) const;
private:
friend class DisassemblerViewAgent;
QVector<DisassemblerLine> m_data;
QHash<quint64, int> m_rowCache;
};
class DisassemblerViewAgent : public QObject class DisassemblerViewAgent : public QObject
{ {
Q_OBJECT Q_OBJECT
......
...@@ -242,6 +242,47 @@ QDataStream &operator>>(QDataStream &stream, WatchData &wd) ...@@ -242,6 +242,47 @@ QDataStream &operator>>(QDataStream &stream, WatchData &wd)
return stream; return stream;
} }
QDataStream &operator<<(QDataStream& stream, const DisassemblerLine &o)
{
stream << o.address;
stream << o.data;
return stream;
}
QDataStream &operator>>(QDataStream& stream, DisassemblerLine &o)
{
stream >> o.address;
stream >> o.data;
return stream;
}
QDataStream &operator<<(QDataStream& stream, const DisassemblerLines &o)
{
stream << quint64(o.size());
for (int i = 0; i < o.size(); i++)
{
stream << o.at(i);
}
return stream;
}
QDataStream &operator>>(QDataStream& stream, DisassemblerLines &o)
{
DisassemblerLines r;
quint64 count;
stream >> count;
for (quint64 i = 0; i < count; i++)
{
DisassemblerLine line;
stream >> line;
r.appendLine(line);
}
o = r;
return stream;
}
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "stackframe.h" #include "stackframe.h"
#include "threaddata.h" #include "threaddata.h"
#include "watchdata.h" #include "watchdata.h"
#include "disassemblerlines.h"
#include <QtCore/QDataStream> #include <QtCore/QDataStream>
#include <QtCore/QVector> #include <QtCore/QVector>
...@@ -55,6 +56,10 @@ QDataStream &operator<<(QDataStream& stream, const BreakpointResponse &data); ...@@ -55,6 +56,10 @@ QDataStream &operator<<(QDataStream& stream, const BreakpointResponse &data);
QDataStream &operator>>(QDataStream& stream, BreakpointResponse &data); QDataStream &operator>>(QDataStream& stream, BreakpointResponse &data);
QDataStream &operator<<(QDataStream& stream, const WatchData &data); QDataStream &operator<<(QDataStream& stream, const WatchData &data);
QDataStream &operator>>(QDataStream& stream, WatchData &data); QDataStream &operator>>(QDataStream& stream, WatchData &data);
QDataStream &operator<<(QDataStream& stream, const DisassemblerLine &o);
QDataStream &operator>>(QDataStream& stream, DisassemblerLine &o);
QDataStream &operator<<(QDataStream& stream, const DisassemblerLines &o);
QDataStream &operator>>(QDataStream& stream, DisassemblerLines &o);
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "disassemblerlines.h"
namespace Debugger {
namespace Internal {
DisassemblerLine::DisassemblerLine(const QString &unparsed)
{
// Mac gdb has an overflow reporting 64bit addresses causing the instruction
// to follow the last digit "0x000000013fff4810mov 1,1". Truncate here.
const int pos = qMin(unparsed.indexOf(QLatin1Char(' ')), 19);
if (pos < 0) {
address = 0;
data = unparsed;
return;
}
QString addr = unparsed.left(pos);
// MSVC 64bit: Remove 64bit separator 00000000`00a45000'.
if (addr.size() >= 9 && addr.at(8) == QLatin1Char('`'))
addr.remove(8, 1);
if (addr.endsWith(':')) // clang
addr.chop(1);
if (addr.startsWith(QLatin1String("0x")))
addr.remove(0, 2);
bool ok;
address = addr.toULongLong(&ok, 16);
if (address)
data = unparsed.mid(pos + 1);
else
data = unparsed;
}
int DisassemblerLines::lineForAddress(quint64 address) const
{
return m_rowCache.value(address);
}
bool DisassemblerLines::coversAddress(quint64 address) const
{
return m_rowCache.value(address) != 0;
}
void DisassemblerLines::appendComment(const QString &comment)
{
DisassemblerLine dl;
dl.data = comment;
m_data.append(dl);
}
void DisassemblerLines::appendLine(const DisassemblerLine &dl)
{
m_data.append(dl);
m_rowCache[dl.address] = m_data.size();
}
} // namespace Internal
} // namespace Debugger
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef DEBUGGER_disassemblerlines_H
#define DEBUGGER_disassemblerlines_H
#include <QtCore/QString>
#include <QtCore/QHash>
#include <QtCore/QVector>
namespace Debugger {
namespace Internal {
class DisassemblerLine
{
public:
DisassemblerLine() : address(0) {}
DisassemblerLine(const QString &unparsed);
quint64 address;
QString data;
};
class DisassemblerLines
{
public:
DisassemblerLines() {}
bool coversAddress(quint64 address) const;
void appendLine(const DisassemblerLine &dl);
void appendComment(const QString &comment);
int size() const { return m_data.size(); }
const DisassemblerLine &at(int i) const { return m_data.at(i); }
int lineForAddress(quint64 address) const;
private:
friend class DisassemblerViewAgent;
QVector<DisassemblerLine> m_data;
QHash<quint64, int> m_rowCache;
};
}
}
#endif
lldb @ d75343c3
Subproject commit d75343c3ae88438ae4dd7d8a7ad87108e9f28f30
...@@ -376,8 +376,12 @@ void LLDBEngineGuest::disassemble(quint64 pc) ...@@ -376,8 +376,12 @@ void LLDBEngineGuest::disassemble(quint64 pc)
for (uint j = 0; j < m_currentThread.GetNumFrames(); j++) { for (uint j = 0; j < m_currentThread.GetNumFrames(); j++) {
lldb::SBFrame fr = m_currentThread.GetFrameAtIndex(j); lldb::SBFrame fr = m_currentThread.GetFrameAtIndex(j);
if (pc == fr.GetPCAddress().GetLoadAddress(*m_target)) { if (pc == fr.GetPCAddress().GetLoadAddress(*m_target)) {
disassembled(pc, QString::fromLocal8Bit(fr.Disassemble())); QString linesStr = QString::fromLocal8Bit(fr.Disassemble());
return; DisassemblerLines lines;
foreach (const QString &lineStr, linesStr.split(QLatin1Char('\n'))) {
lines.appendLine(DisassemblerLine(lineStr));
}
disassembled(pc, lines);
} }
} }
} }
......
...@@ -21,6 +21,7 @@ HEADERS += ../ipcengineguest.h \ ...@@ -21,6 +21,7 @@ HEADERS += ../ipcengineguest.h \
../breakpoint.h \ ../breakpoint.h \
../watchdata.h \ ../watchdata.h \
../stackframe.h \ ../stackframe.h \
../disassemblerlines.h \
lldbengineguest.h lldbengineguest.h
SOURCES += ../ipcengineguest.cpp \ SOURCES += ../ipcengineguest.cpp \
...@@ -28,6 +29,7 @@ SOURCES += ../ipcengineguest.cpp \ ...@@ -28,6 +29,7 @@ SOURCES += ../ipcengineguest.cpp \
../breakpoint.cpp \ ../breakpoint.cpp \
../watchdata.cpp \ ../watchdata.cpp \
../stackframe.cpp \ ../stackframe.cpp \
../disassemblerlines.cpp \
lldbengineguest.cpp \ lldbengineguest.cpp \
main.cpp main.cpp
......
...@@ -503,7 +503,7 @@ void IPCEngineGuest::listThreads(const Threads &threads) ...@@ -503,7 +503,7 @@ void IPCEngineGuest::listThreads(const Threads &threads)
rpcCall(ListThreads, p); rpcCall(ListThreads, p);
} }
void IPCEngineGuest::disassembled(quint64 pc, const QString &da) void IPCEngineGuest::disassembled(quint64 pc, const DisassemblerLines &da)
{ {
QByteArray p; QByteArray p;
{ {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "breakhandler.h" #include "breakhandler.h"
#include "debuggerengine.h" #include "debuggerengine.h"
#include "disassemblerlines.h"
#include "stackhandler.h" #include "stackhandler.h"
#include "threadshandler.h" #include "threadshandler.h"
...@@ -152,7 +153,7 @@ public: ...@@ -152,7 +153,7 @@ public:
void currentThreadChanged(qint64 token); void currentThreadChanged(qint64 token);
void listFrames(const StackFrames &); void listFrames(const StackFrames &);
void listThreads(const Threads &); void listThreads(const Threads &);
void disassembled(quint64 pc, const QString &da); void disassembled(quint64 pc, const DisassemblerLines &da);
void notifyAddBreakpointOk(BreakpointId id); void notifyAddBreakpointOk(BreakpointId id);
void notifyAddBreakpointFailed(BreakpointId id); void notifyAddBreakpointFailed(BreakpointId id);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "ipcengineguest.h" #include "ipcengineguest.h"
#include "breakhandler.h" #include "breakhandler.h"
#include "breakpoint.h" #include "breakpoint.h"
#include "disassemblerlines.h"
#include "moduleshandler.h" #include "moduleshandler.h"
#include "registerhandler.h" #include "registerhandler.h"
#include "stackhandler.h" #include "stackhandler.h"
...@@ -443,12 +444,12 @@ void IPCEngineHost::rpcCallback(quint64 f, QByteArray payload) ...@@ -443,12 +444,12 @@ void IPCEngineHost::rpcCallback(quint64 f, QByteArray payload)
QDataStream s(payload); QDataStream s(payload);
SET_NATIVE_BYTE_ORDER(s); SET_NATIVE_BYTE_ORDER(s);
quint64 pc; quint64 pc;
QString da; DisassemblerLines lines;
s >> pc; s >> pc;
s >> da; s >> lines;
//DisassemblerViewAgent *view = m_frameToDisassemblerAgent.take(pc); DisassemblerViewAgent *view = m_frameToDisassemblerAgent.take(pc);
//if (view) if (view)
// view->setContents(da); view->setContents(lines);
} }
break; break;
case IPCEngineGuest::UpdateWatchData: case IPCEngineGuest::UpdateWatchData:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment