}
}
}
+void LldbEngineGuest::fetchFrameSource(qint64 frame)
+{
+ QFile f(m_frame_to_file.value(frame));
+ f.open(QFile::ReadOnly);
+ frameSourceFetched(frame, QFileInfo(m_frame_to_file.value(frame)).fileName()
+ , QString::fromLocal8Bit(f.readAll()));
+}
void LldbEngineGuest::addBreakpoint(BreakpointId id,
const Internal::BreakpointParameters &bp_)
DEBUG_FUNC_ENTER;
SYNC_INFERIOR_OR(return);
+ m_frame_to_file.clear();
for (uint i = 0; i < m_process->GetNumThreads(); i++) {
lldb::SBThread t = m_process->GetThreadAtIndex(i);
if (t.GetThreadID() == token) {
frame.address = fr.GetPCAddress().GetLoadAddress(*m_target);
frame.line = lineNumber;
frame.file = sourceFilePath;
+ frame.usable = QFileInfo(frame.file).isReadable();
frames.append(frame);
+ m_frame_to_file.insert(j, frame.file);
}
currentThreadChanged(token);
listFrames(frames);
void addBreakpoint(BreakpointId id, const BreakpointParameters &bp);
void removeBreakpoint(BreakpointId id);
void changeBreakpoint(BreakpointId id, const BreakpointParameters &bp);
-
void requestUpdateWatchData(const WatchData &data,
const WatchUpdateFlags &flags);
+ void fetchFrameSource(qint64 frame);
private:
bool m_running;
bool m_relistFrames;
QHash<QString, lldb::SBValue> m_localesCache;
QHash<BreakpointId, lldb::SBBreakpoint> m_breakpoints;
+ QHash<qint64, QString> m_frame_to_file;
void updateThreads();
void getWatchDataR(lldb::SBValue v, int level,
requestUpdateWatchData(data);
}
break;
+ case IPCEngineHost::FetchFrameSource:
+ {
+ QDataStream s(payload);
+ SET_NATIVE_BYTE_ORDER(s);
+ qint64 id;
+ s >> id;
+ fetchFrameSource(id);
+ }
+ break;
};
}
rpcCall(UpdateWatchData, p);
}
+void IPCEngineGuest::frameSourceFetched(qint64 id, const QString &name, const QString &source)
+{
+ QByteArray p;
+ {
+ QDataStream s(&p, QIODevice::WriteOnly);
+ SET_NATIVE_BYTE_ORDER(s);
+ s << id;
+ s << name;
+ s << source;
+ }
+ rpcCall(FrameSourceFetched, p);
+}
+
} // namespace Internal
} // namespace Debugger
virtual void changeBreakpoint(BreakpointId id, const BreakpointParameters &bp) = 0;
virtual void requestUpdateWatchData(const WatchData &data,
const WatchUpdateFlags & flags = WatchUpdateFlags()) = 0;
+ virtual void fetchFrameSource(qint64 frame) = 0;
enum Function
{
NotifyChangeBreakpointOk = 34,
NotifyChangeBreakpointFailed = 35,
NotifyBreakpointAdjusted = 36,
- UpdateWatchData = 47
+ UpdateWatchData = 47,
+ FrameSourceFetched = 48
};
Q_ENUMS(Function);
void updateWatchData(bool fullCycle, const QList<WatchData> &);
+ void frameSourceFetched(qint64 frame, const QString &name, const QString &sourceCode);
+
void rpcCall(Function f, QByteArray payload = QByteArray());
public slots:
void rpcCallback(quint64 f, QByteArray payload = QByteArray());
#include "threadshandler.h"
#include "debuggeragents.h"
#include "debuggerstreamops.h"
+#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/editormanager/ieditor.h>
+#include <cppeditor/cppeditorconstants.h>
#include <QSysInfo>
#include <QDebug>
rpcCall(RequestUpdateWatchData, p);
}
+void IPCEngineHost::fetchFrameSource(qint64 id)
+{
+ QByteArray p;
+ {
+ QDataStream s(&p, QIODevice::WriteOnly);
+ SET_NATIVE_BYTE_ORDER(s);
+ s << id;
+ }
+ rpcCall(FetchFrameSource, p);
+}
+
void IPCEngineHost::rpcCallback(quint64 f, QByteArray payload)
{
switch (f) {
resetLocation();
StackHandler *sh = stackHandler();
sh->setCurrentIndex(token);
- gotoLocation(sh->currentFrame(), true);
+ if (QFileInfo(sh->currentFrame().file).exists())
+ gotoLocation(sh->currentFrame(), true);
+ else
+ fetchFrameSource(token);
}
break;
case IPCEngineGuest::CurrentThreadChanged:
breakHandler()->notifyBreakpointAdjusted(id, d);
}
break;
+ case IPCEngineGuest::FrameSourceFetched:
+ {
+ QDataStream s(payload);
+ SET_NATIVE_BYTE_ORDER(s);
+ qint64 token;
+ QString name;
+ QString source;
+ s >> token >> name >> source;
+ Core::EditorManager *editorManager = Core::EditorManager::instance();
+ Core::IEditor *editor = editorManager->openEditorWithContents(CppEditor::Constants::CPPEDITOR_ID, &name, source);
+ editorManager->activateEditor(editor);
+ editor->gotoLine(stackHandler()->currentFrame().line, 0);
+ editor->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
+ }
+ break;
}
}
AddBreakpoint = 22,
RemoveBreakpoint = 23,
ChangeBreakpoint = 24,
- RequestUpdateWatchData = 25
+ RequestUpdateWatchData = 25,
+ FetchFrameSource = 26
};
Q_ENUMS(Function);
void changeBreakpoint(BreakpointId id);
void updateWatchData(const WatchData &data,
const WatchUpdateFlags &flags = WatchUpdateFlags());
+ void fetchFrameSource(qint64 id);
void rpcCall(Function f, QByteArray payload = QByteArray());
protected: