Commit 3ce54345 authored by hjk's avatar hjk

debugger: start attempt to handle dwarf index data

parent 45f15f0e
......@@ -237,6 +237,7 @@ enum ModelRoles
// Modules
RequestReloadModulesRole,
RequestExamineModulesRole,
RequestModuleSymbolsRole,
RequestAllSymbolsRole,
RequestOpenFileRole,
......
......@@ -136,6 +136,7 @@ public:
virtual void activateFrame(int index) { Q_UNUSED(index); }
virtual void reloadModules() {}
virtual void examineModules() {}
virtual void loadSymbols(const QString &moduleName)
{ Q_UNUSED(moduleName); }
virtual void loadAllSymbols() {}
......
......@@ -2672,6 +2672,27 @@ void GdbEngine::handleModulesList(const GdbResponse &response)
}
void GdbEngine::examineModules()
{
foreach (Module module, modulesHandler()->modules()) {
if (module.symbolsType == Module::UnknownType) {
QProcess proc;
qDebug() << _("objdump -h \"%1\"").arg(module.moduleName);
proc.start(_("objdump -h \"%1\"").arg(module.moduleName));
if (!proc.waitForStarted())
continue;
if (!proc.waitForFinished())
continue;
QByteArray ba = proc.readAllStandardOutput();
if (ba.contains(".gdb_index"))
module.symbolsType = Module::FastSymbols;
else
module.symbolsType = Module::PlainSymbols;
modulesHandler()->updateModule(module.moduleName, module);
}
}
}
//////////////////////////////////////////////////////////////////////
//
// Source files specific stuff
......
......@@ -368,6 +368,7 @@ private: ////////// View & Data Stuff //////////
virtual void loadAllSymbols();
virtual void requestModuleSymbols(const QString &moduleName);
virtual void reloadModules();
virtual void examineModules();
void reloadModulesInternal();
void handleModulesList(const GdbResponse &response);
......
......@@ -70,9 +70,10 @@ public:
bool setData(const QModelIndex &index, const QVariant &value, int role);
void clearModel();
void addModule(const Module &m);
void addModule(const Module &module);
void removeModule(const QString &moduleName);
void setModules(const Modules &m);
void setModules(const Modules &modules);
void updateModule(const QString &moduleName, const Module &module);
const Modules &modules() const { return m_modules; }
......@@ -167,6 +168,10 @@ bool ModulesModel::setData(const QModelIndex &index, const QVariant &value, int
m_engine->reloadModules();
return true;
case RequestExamineModulesRole:
m_engine->examineModules();
return true;
case RequestModuleSymbolsRole:
m_engine->loadSymbols(value.toString());
return true;
......@@ -216,12 +221,19 @@ void ModulesModel::removeModule(const QString &moduleName)
{
const int index = indexOfModule(moduleName);
QTC_ASSERT(index != -1, return);
beginRemoveRows(QModelIndex(), index, index);
m_modules.removeAt(index);
endRemoveRows();
}
void ModulesModel::updateModule(const QString &moduleName, const Module &module)
{
const int index = indexOfModule(moduleName);
QTC_ASSERT(index != -1, return);
m_modules[index] = module;
reset();
}
//////////////////////////////////////////////////////////////////
//
// ModulesHandler
......@@ -255,6 +267,11 @@ void ModulesHandler::removeModule(const QString &moduleName)
m_model->removeModule(moduleName);
}
void ModulesHandler::updateModule(const QString &moduleName, const Module &module)
{
m_model->updateModule(moduleName, module);
}
void ModulesHandler::setModules(const Modules &modules)
{
m_model->setModules(modules);
......
......@@ -110,6 +110,7 @@ public:
void setModules(const Modules &modules);
void addModule(const Module &module);
void removeModule(const QString &moduleName);
void updateModule(const QString &moduleName, const Module &module);
Modules modules() const;
void removeAll();
......
......@@ -107,35 +107,55 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
model()->data(index, EngineCapabilitiesRole).toInt();
QMenu menu;
QAction *act0 = new QAction(tr("Update Module List"), &menu);
act0->setEnabled(enabled && (capabilities & ReloadModuleCapability));
QAction *act3 = new QAction(tr("Show Source Files for Module \"%1\"").arg(name), &menu);
act3->setEnabled(enabled && (capabilities & ReloadModuleCapability));
QAction *act4 = new QAction(tr("Load Symbols for All Modules"), &menu);
act4->setEnabled(enabled && (capabilities & ReloadModuleSymbolsCapability));
QAction *act5 = 0;
QAction *act6 = 0;
QAction *act7 = 0;
QAction *actUpdateModuleList
= new QAction(tr("Update Module List"), &menu);
actUpdateModuleList
->setEnabled(enabled && (capabilities & ReloadModuleCapability));
QAction *actShowSourceFiles
= new QAction(tr("Show Source Files for Module \"%1\"").arg(name), &menu);
actShowSourceFiles
->setEnabled(enabled && (capabilities & ReloadModuleCapability));
QAction *actLoadSymbolsForAllModules
= new QAction(tr("Load Symbols for All Modules"), &menu);
actLoadSymbolsForAllModules
-> setEnabled(enabled && (capabilities & ReloadModuleSymbolsCapability));
QAction *actExamineAllModules
= new QAction(tr("Examine All Modules"), &menu);
actExamineAllModules
-> setEnabled(enabled && (capabilities & ReloadModuleSymbolsCapability));
QAction *actLoadSymbolsForModule = 0;
QAction *actEditFile = 0;
QAction *actShowSymbols = 0;
if (name.isEmpty()) {
act5 = new QAction(tr("Load Symbols for Module"), &menu);
act5->setEnabled(false);
act6 = new QAction(tr("Edit File"), &menu);
act6->setEnabled(false);
act7 = new QAction(tr("Show Symbols"), &menu);
act7->setEnabled(false);
actLoadSymbolsForModule = new QAction(tr("Load Symbols for Module"), &menu);
actLoadSymbolsForModule->setEnabled(false);
actEditFile = new QAction(tr("Edit File"), &menu);
actEditFile->setEnabled(false);
actShowSymbols = new QAction(tr("Show Symbols"), &menu);
actShowSymbols->setEnabled(false);
} else {
act5 = new QAction(tr("Load Symbols for Module \"%1\"").arg(name), &menu);
act5->setEnabled(capabilities & ReloadModuleSymbolsCapability);
act6 = new QAction(tr("Edit File \"%1\"").arg(name), &menu);
act7 = new QAction(tr("Show Symbols in File \"%1\"").arg(name), &menu);
actLoadSymbolsForModule
= new QAction(tr("Load Symbols for Module \"%1\"").arg(name), &menu);
actLoadSymbolsForModule
->setEnabled(capabilities & ReloadModuleSymbolsCapability);
actEditFile
= new QAction(tr("Edit File \"%1\"").arg(name), &menu);
actShowSymbols
= new QAction(tr("Show Symbols in File \"%1\"").arg(name), &menu);
}
menu.addAction(act0);
//menu.addAction(act3); // FIXME
menu.addAction(act4);
menu.addAction(act5);
menu.addAction(act6);
//menu.addAction(act7); // FIXME
menu.addAction(actUpdateModuleList);
//menu.addAction(actShowSourceFiles); // FIXME
menu.addAction(actLoadSymbolsForAllModules);
menu.addAction(actExamineAllModules);
menu.addAction(actLoadSymbolsForModule);
menu.addAction(actEditFile);
//menu.addAction(actShowSymbols); // FIXME
menu.addSeparator();
QAction *actAdjustColumnWidths =
menu.addAction(tr("Adjust Column Widths to Contents"));
......@@ -148,21 +168,23 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction *act = menu.exec(ev->globalPos());
if (act == act0) {
if (act == actUpdateModuleList) {
setModelData(RequestReloadModulesRole);
} else if (act == actAdjustColumnWidths) {
resizeColumnsToContents();
} else if (act == actAlwaysAdjustColumnWidth) {
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
//} else if (act == act3) {
//} else if (act == actShowSourceFiles) {
// emit displaySourceRequested(name);
} else if (act == act4) {
} else if (act == actLoadSymbolsForAllModules) {
setModelData(RequestAllSymbolsRole);
} else if (act == act5) {
} else if (act == actExamineAllModules) {
setModelData(RequestExamineModulesRole);
} else if (act == actLoadSymbolsForModule) {
setModelData(RequestModuleSymbolsRole, name);
} else if (act == act6) {
} else if (act == actEditFile) {
setModelData(RequestOpenFileRole, name);
} else if (act == act7) {
} else if (act == actShowSymbols) {
setModelData(RequestModuleSymbolsRole, name);
}
}
......
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