diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 015480eacd1fa997d5d0b32981f7a179196cdceb..e39691323e0c58d105be1281245a9143a2071fc5 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -35,6 +35,7 @@ HEADERS += breakhandler.h \ debuggerstringutils.h \ debuggertooltip.h \ debuggeruiswitcher.h \ + disassemblerlines.h \ logwindow.h \ moduleshandler.h \ moduleswindow.h \ @@ -73,6 +74,7 @@ SOURCES += breakhandler.cpp \ debuggerstreamops.cpp \ debuggertooltip.cpp \ debuggeruiswitcher.cpp \ + disassemblerlines.cpp \ logwindow.cpp \ moduleshandler.cpp \ moduleswindow.cpp \ diff --git a/src/plugins/debugger/debuggeragents.cpp b/src/plugins/debugger/debuggeragents.cpp index bff396217dfba5dc1950af517183b5153a33d564..3d28e5bd44f48197902fd8da1c13988faa0bf01a 100644 --- a/src/plugins/debugger/debuggeragents.cpp +++ b/src/plugins/debugger/debuggeragents.cpp @@ -405,55 +405,5 @@ quint64 DisassemblerViewAgent::addressFromDisassemblyLine(const QString &line) 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 Debugger diff --git a/src/plugins/debugger/debuggeragents.h b/src/plugins/debugger/debuggeragents.h index 57d3c02c4b549f8298f3330484fd53912bf787a9..968e4ca148b0f558182afa25c849e704d0df203b 100644 --- a/src/plugins/debugger/debuggeragents.h +++ b/src/plugins/debugger/debuggeragents.h @@ -35,6 +35,8 @@ #include <QtCore/QPointer> #include <QtCore/QVector> +#include "disassemblerlines.h" + namespace Core { class IEditor; } @@ -76,34 +78,6 @@ private: 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 { Q_OBJECT diff --git a/src/plugins/debugger/debuggerstreamops.cpp b/src/plugins/debugger/debuggerstreamops.cpp index 9312bb9172c6d0ca3eaaf0132e584a858a250133..85c0438c705cc6bea6ec2a9794776eb5697be4eb 100644 --- a/src/plugins/debugger/debuggerstreamops.cpp +++ b/src/plugins/debugger/debuggerstreamops.cpp @@ -242,6 +242,47 @@ QDataStream &operator>>(QDataStream &stream, WatchData &wd) 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 Debugger diff --git a/src/plugins/debugger/debuggerstreamops.h b/src/plugins/debugger/debuggerstreamops.h index 067332fba8c4fb3e0387cd5d7b2db0f832d755e4..b7bc2a7d0d2bdda5db114254457abb42ed181f04 100644 --- a/src/plugins/debugger/debuggerstreamops.h +++ b/src/plugins/debugger/debuggerstreamops.h @@ -34,6 +34,7 @@ #include "stackframe.h" #include "threaddata.h" #include "watchdata.h" +#include "disassemblerlines.h" #include <QtCore/QDataStream> #include <QtCore/QVector> @@ -55,6 +56,10 @@ QDataStream &operator<<(QDataStream& stream, const BreakpointResponse &data); QDataStream &operator>>(QDataStream& stream, BreakpointResponse &data); QDataStream &operator<<(QDataStream& stream, const 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 Debugger diff --git a/src/plugins/debugger/disassemblerlines.cpp b/src/plugins/debugger/disassemblerlines.cpp new file mode 100644 index 0000000000000000000000000000000000000000..75f315a9ac8d51279a88df55baed84e256ebd713 --- /dev/null +++ b/src/plugins/debugger/disassemblerlines.cpp @@ -0,0 +1,86 @@ +/************************************************************************** +** +** 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 diff --git a/src/plugins/debugger/disassemblerlines.h b/src/plugins/debugger/disassemblerlines.h new file mode 100644 index 0000000000000000000000000000000000000000..33612ab0346d180a648b4dd42c00ac417c1da058 --- /dev/null +++ b/src/plugins/debugger/disassemblerlines.h @@ -0,0 +1,71 @@ +/************************************************************************** +** +** 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 diff --git a/src/plugins/debugger/lldb/guest/lldb b/src/plugins/debugger/lldb/guest/lldb new file mode 160000 index 0000000000000000000000000000000000000000..d75343c3ae88438ae4dd7d8a7ad87108e9f28f30 --- /dev/null +++ b/src/plugins/debugger/lldb/guest/lldb @@ -0,0 +1 @@ +Subproject commit d75343c3ae88438ae4dd7d8a7ad87108e9f28f30 diff --git a/src/plugins/debugger/lldb/guest/lldbengineguest.cpp b/src/plugins/debugger/lldb/guest/lldbengineguest.cpp index dd92f29a596d93fb8148cffde154f92ae4acfa96..4adeb22371eef7d1daa03c1b890295caa4e52a89 100644 --- a/src/plugins/debugger/lldb/guest/lldbengineguest.cpp +++ b/src/plugins/debugger/lldb/guest/lldbengineguest.cpp @@ -376,8 +376,12 @@ void LLDBEngineGuest::disassemble(quint64 pc) for (uint j = 0; j < m_currentThread.GetNumFrames(); j++) { lldb::SBFrame fr = m_currentThread.GetFrameAtIndex(j); if (pc == fr.GetPCAddress().GetLoadAddress(*m_target)) { - disassembled(pc, QString::fromLocal8Bit(fr.Disassemble())); - return; + QString linesStr = QString::fromLocal8Bit(fr.Disassemble()); + DisassemblerLines lines; + foreach (const QString &lineStr, linesStr.split(QLatin1Char('\n'))) { + lines.appendLine(DisassemblerLine(lineStr)); + } + disassembled(pc, lines); } } } diff --git a/src/plugins/debugger/lldb/guest/qtcreator-lldb.pro b/src/plugins/debugger/lldb/guest/qtcreator-lldb.pro index f9d58469608f87657162339a68dc28951a97ef08..c885675ebc355685d304a2eae2add2e622404138 100644 --- a/src/plugins/debugger/lldb/guest/qtcreator-lldb.pro +++ b/src/plugins/debugger/lldb/guest/qtcreator-lldb.pro @@ -21,6 +21,7 @@ HEADERS += ../ipcengineguest.h \ ../breakpoint.h \ ../watchdata.h \ ../stackframe.h \ + ../disassemblerlines.h \ lldbengineguest.h SOURCES += ../ipcengineguest.cpp \ @@ -28,6 +29,7 @@ SOURCES += ../ipcengineguest.cpp \ ../breakpoint.cpp \ ../watchdata.cpp \ ../stackframe.cpp \ + ../disassemblerlines.cpp \ lldbengineguest.cpp \ main.cpp diff --git a/src/plugins/debugger/lldb/ipcengineguest.cpp b/src/plugins/debugger/lldb/ipcengineguest.cpp index 3ce8b80d1db00445189b26581f250bdf32897852..deede1da34a4f58442c618bb67b1c39ef2a688f1 100644 --- a/src/plugins/debugger/lldb/ipcengineguest.cpp +++ b/src/plugins/debugger/lldb/ipcengineguest.cpp @@ -503,7 +503,7 @@ void IPCEngineGuest::listThreads(const Threads &threads) rpcCall(ListThreads, p); } -void IPCEngineGuest::disassembled(quint64 pc, const QString &da) +void IPCEngineGuest::disassembled(quint64 pc, const DisassemblerLines &da) { QByteArray p; { diff --git a/src/plugins/debugger/lldb/ipcengineguest.h b/src/plugins/debugger/lldb/ipcengineguest.h index 5d849691f7b4e35c6b21f95932842dc02c7f91e5..126ecc1881043ece18686dbe03a759ee05fc5e79 100644 --- a/src/plugins/debugger/lldb/ipcengineguest.h +++ b/src/plugins/debugger/lldb/ipcengineguest.h @@ -32,6 +32,7 @@ #include "breakhandler.h" #include "debuggerengine.h" +#include "disassemblerlines.h" #include "stackhandler.h" #include "threadshandler.h" @@ -152,7 +153,7 @@ public: void currentThreadChanged(qint64 token); void listFrames(const StackFrames &); void listThreads(const Threads &); - void disassembled(quint64 pc, const QString &da); + void disassembled(quint64 pc, const DisassemblerLines &da); void notifyAddBreakpointOk(BreakpointId id); void notifyAddBreakpointFailed(BreakpointId id); diff --git a/src/plugins/debugger/lldb/ipcenginehost.cpp b/src/plugins/debugger/lldb/ipcenginehost.cpp index 2c0ee3d1994f1d736243590249cbfc8b0cc64131..997be0d80f67ea5bda9b8489231a975723500936 100644 --- a/src/plugins/debugger/lldb/ipcenginehost.cpp +++ b/src/plugins/debugger/lldb/ipcenginehost.cpp @@ -31,6 +31,7 @@ #include "ipcengineguest.h" #include "breakhandler.h" #include "breakpoint.h" +#include "disassemblerlines.h" #include "moduleshandler.h" #include "registerhandler.h" #include "stackhandler.h" @@ -443,12 +444,12 @@ void IPCEngineHost::rpcCallback(quint64 f, QByteArray payload) QDataStream s(payload); SET_NATIVE_BYTE_ORDER(s); quint64 pc; - QString da; + DisassemblerLines lines; s >> pc; - s >> da; - //DisassemblerViewAgent *view = m_frameToDisassemblerAgent.take(pc); - //if (view) - // view->setContents(da); + s >> lines; + DisassemblerViewAgent *view = m_frameToDisassemblerAgent.take(pc); + if (view) + view->setContents(lines); } break; case IPCEngineGuest::UpdateWatchData: