Commit 12fd2a60 authored by hjk's avatar hjk

debugger: move showModuleSymbols from DebuggerManager to DebuggerEngine

parent 69a4ed32
......@@ -1236,7 +1236,7 @@ void CdbDebugEngine::requestModuleSymbols(const QString &moduleName)
} while (false);
if (!success)
warning(errorMessage);
manager()->showModuleSymbols(moduleName, rc);
m_engine->showModuleSymbols(moduleName, rc);
}
void CdbDebugEngine::reloadRegisters()
......
......@@ -1171,33 +1171,6 @@ void DebuggerManager::loadSymbols(const QString &module)
d->m_engine->loadSymbols(module);
}
void DebuggerManager::requestModuleSymbols(const QString &moduleName)
{
QTC_ASSERT(d->m_engine, return);
d->m_engine->requestModuleSymbols(moduleName);
}
void DebuggerManager::showModuleSymbols(const QString &moduleName,
const QList<Symbol> &symbols)
{
QTC_ASSERT(d->m_engine, return);
QTreeWidget *w = new QTreeWidget;
w->setColumnCount(3);
w->setRootIsDecorated(false);
w->setAlternatingRowColors(true);
w->setSortingEnabled(true);
w->setHeaderLabels(QStringList() << tr("Symbol") << tr("Address") << tr("Code"));
w->setWindowTitle(tr("Symbols in \"%1\"").arg(moduleName));
foreach (const Symbol &s, symbols) {
QTreeWidgetItem *it = new QTreeWidgetItem;
it->setData(0, Qt::DisplayRole, s.name);
it->setData(1, Qt::DisplayRole, s.address);
it->setData(2, Qt::DisplayRole, s.state);
w->addTopLevelItem(it);
}
createNewDock(w);
}
void DebuggerManager::executeStep()
{
QTC_ASSERT(d->m_engine, return);
......@@ -1538,7 +1511,7 @@ void DebuggerManager::showMessage(const QString &msg, int channel)
{
if (runControl())
runControl()->showMessage(msg, channel);
//else
//else
// qDebug() << "OUTPUT: " << channel << msg;
}
......@@ -2029,6 +2002,25 @@ bool IDebuggerEngine::debuggerActionsEnabled() const
return m_manager->debuggerActionsEnabled();
}
void IDebuggerEngine::showModuleSymbols
(const QString &moduleName, const Symbols &symbols)
{
QTreeWidget *w = new QTreeWidget;
w->setColumnCount(3);
w->setRootIsDecorated(false);
w->setAlternatingRowColors(true);
w->setSortingEnabled(true);
w->setHeaderLabels(QStringList() << tr("Symbol") << tr("Address") << tr("Code"));
w->setWindowTitle(tr("Symbols in \"%1\"").arg(moduleName));
foreach (const Symbol &s, symbols) {
QTreeWidgetItem *it = new QTreeWidgetItem;
it->setData(0, Qt::DisplayRole, s.name);
it->setData(1, Qt::DisplayRole, s.address);
it->setData(2, Qt::DisplayRole, s.state);
w->addTopLevelItem(it);
}
manager()->createNewDock(w);
}
//////////////////////////////////////////////////////////////////////
//
// Testing
......
......@@ -293,13 +293,6 @@ private:
Q_SLOT void dumpLog();
Q_SLOT void fontSettingsChanged(const TextEditor::FontSettings &settings);
public:
// stuff in this block should be made private by moving it to
// one of the interfaces
void requestModuleSymbols(const QString &moduleName);
void showModuleSymbols(const QString &moduleName,
const QList<Internal::Symbol> &symbols);
signals:
void debuggingFinished();
void inferiorPidChanged(qint64 pid);
......
......@@ -485,7 +485,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
// new_bp="1",pended_bp="1",new_expr="\"gdbengine.cpp\":1584",
// bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
// addr="0x0000000115cc3ddf",func="foo()",file="../foo.cpp",
// line="1584",shlib="/../libFoo_debug.dylib",times="0"}
// line="1584",shlib="/../libFoo_debug.dylib",times="0"}
const GdbMi bkpt = result.findChild("bkpt");
const int number = bkpt.findChild("number").data().toInt();
BreakHandler *handler = manager()->breakHandler();
......@@ -1409,7 +1409,7 @@ void GdbEngine::handleStop1(const GdbMi &data)
// value={old="1",new="0"},frame={addr="0x00451e1b",
// func="QScopedPointer",args=[{name="this",value="0xbfffed40"},
// {name="p",value="0x0"}],file="x.h",fullname="/home/.../x.h",line="95"},
// thread-id="1",stopped-threads="all",core="2"
// thread-id="1",stopped-threads="all",core="2"
GdbMi wpt = data.findChild("wpt");
QByteArray bpNumber = wpt.findChild("number").data();
QByteArray bpAddress = wpt.findChild("exp").data();
......@@ -1783,7 +1783,7 @@ void GdbEngine::startDebugger()
m_progress->setProgressRange(0, 100);
Core::FutureProgress *fp = Core::ICore::instance()->progressManager()
->addTask(m_progress->future(), tr("Launching"), _("Debugger.Launcher"));
fp->setKeepOnFinish(false);
fp->setKeepOnFinish(false);
m_progress->reportStarted();
delete m_gdbAdapter;
......@@ -1804,7 +1804,7 @@ unsigned GdbEngine::debuggerCapabilities() const
| RegisterCapability | ShowMemoryCapability
| JumpToLineCapability | ReloadModuleCapability
| ReloadModuleSymbolsCapability | BreakOnThrowAndCatchCapability
| ReturnFromFunctionCapability
| ReturnFromFunctionCapability
| CreateFullBacktraceCapability
| WatchpointCapability
| AddWatcherCapability;
......@@ -2219,7 +2219,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response)
setBreakpointDataFromOutput(data, bkpt);
} else {
// Some versions of gdb like "GNU gdb (GDB) SUSE (6.8.91.20090930-2.4)"
// know how to do pending breakpoints using CLI but not MI. So try
// know how to do pending breakpoints using CLI but not MI. So try
// again with MI.
QByteArray cmd = "break " + breakpointLocation(data);
postCommand(cmd, NeedsStop | RebuildBreakpointModel,
......@@ -2647,7 +2647,7 @@ void GdbEngine::requestModuleSymbols(const QString &moduleName)
} while (false);
if (!success)
qWarning("moduleSymbols: %s\n", qPrintable(errorMessage));
manager()->showModuleSymbols(moduleName, rc);
showModuleSymbols(moduleName, rc);
}
void GdbEngine::reloadModules()
......
......@@ -31,6 +31,7 @@
#define DEBUGGER_IDEBUGGERENGINE_H
#include "debuggerconstants.h"
#include "moduleshandler.h" // For 'Symbols'.
#include <QtCore/QObject>
#include <QtCore/QList>
......@@ -139,6 +140,7 @@ public slots:
{ showMessage(msg, StatusBar, timeout); }
DebuggerManager *manager() const { return m_manager; }
bool debuggerActionsEnabled() const;
void showModuleSymbols(const QString &moduleName, const Symbols &symbols);
protected:
DebuggerState state() const;
......
......@@ -35,7 +35,6 @@
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QList>
#include <QtCore/QTextStream>
#include <QtGui/QAction>
......@@ -73,9 +72,9 @@ public:
void clearModel();
void addModule(const Module &m);
void removeModule(const QString &moduleName);
void setModules(const QList<Module> &m);
void setModules(const Modules &m);
const QList<Module> &modules() const { return m_modules; }
const Modules &modules() const { return m_modules; }
IDebuggerEngine *engine() { return m_runControl->engine(); }
const IDebuggerEngine *engine() const { return m_runControl->engine(); }
......@@ -85,7 +84,7 @@ private:
DebuggerRunControl *m_runControl;
const QVariant m_yes;
const QVariant m_no;
QList<Module> m_modules;
Modules m_modules;
};
ModulesModel::ModulesModel(ModulesHandler *parent, DebuggerRunControl *runControl)
......@@ -175,7 +174,7 @@ void ModulesModel::addModule(const Module &m)
endInsertRows();
}
void ModulesModel::setModules(const QList<Module> &m)
void ModulesModel::setModules(const Modules &m)
{
m_modules = m;
reset();
......@@ -241,12 +240,12 @@ void ModulesHandler::removeModule(const QString &moduleName)
m_model->removeModule(moduleName);
}
void ModulesHandler::setModules(const QList<Module> &modules)
void ModulesHandler::setModules(const Modules &modules)
{
m_model->setModules(modules);
}
QList<Module> ModulesHandler::modules() const
Modules ModulesHandler::modules() const
{
return m_model->modules();
}
......
......@@ -61,6 +61,8 @@ public:
QString name;
};
typedef QList<Symbol> Symbols;
//////////////////////////////////////////////////////////////////
//
// Module
......@@ -80,6 +82,8 @@ public:
QString endAddress;
};
typedef QList<Module> Modules;
//////////////////////////////////////////////////////////////////
//
......@@ -94,11 +98,11 @@ public:
QAbstractItemModel *model() const;
void setModules(const QList<Module> &modules);
void setModules(const Modules &modules);
void addModule(const Module &module);
void removeModule(const QString &moduleName);
QList<Module> modules() const;
Modules modules() const;
void removeAll();
private:
......
......@@ -402,7 +402,7 @@ void PdbEngine::handleListModules(const PdbResponse &response)
{
GdbMi out;
out.fromString(response.data.trimmed());
QList<Module> modules;
Modules modules;
foreach (const GdbMi &item, out.children()) {
Module module;
module.moduleName = _(item.findChild("name").data());
......@@ -432,14 +432,14 @@ void PdbEngine::handleListSymbols(const PdbResponse &response)
{
GdbMi out;
out.fromString(response.data.trimmed());
QList<Symbol> symbols;
Symbols symbols;
QString moduleName = response.cookie.toString();
foreach (const GdbMi &item, out.children()) {
Symbol symbol;
symbol.name = _(item.findChild("name").data());
symbols.append(symbol);
}
manager()->showModuleSymbols(moduleName, symbols);
showModuleSymbols(moduleName, symbols);
}
//////////////////////////////////////////////////////////////////////
......@@ -737,7 +737,7 @@ void PdbEngine::handleBacktrace(const PdbResponse &response)
// "-> def square(a):"
// Populate stack view.
QList<StackFrame> stackFrames;
StackFrames stackFrames;
int level = 0;
int currentIndex = -1;
foreach (const QByteArray &line, response.data.split('\n')) {
......
......@@ -31,6 +31,7 @@
#define DEBUGGER_STACKFRAME_H
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtCore/QMetaType>
QT_BEGIN_NAMESPACE
......@@ -57,7 +58,9 @@ struct StackFrame
QString address;
};
QDebug operator<<(QDebug d, const StackFrame &);
QDebug operator<<(QDebug d, const StackFrame &frame);
typedef QList<StackFrame> StackFrames;
} // namespace Internal
} // namespace Debugger
......
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