forked from qt-creator/qt-creator
debugger: add an option to load "missing" symbols for current stack
This commit is contained in:
@@ -74,13 +74,12 @@ bool getModuleNameList(CIDebugSymbols *syms, QStringList *modules, QString *erro
|
|||||||
static inline void getBasicModuleParameters(const DEBUG_MODULE_PARAMETERS &p,
|
static inline void getBasicModuleParameters(const DEBUG_MODULE_PARAMETERS &p,
|
||||||
Module *module)
|
Module *module)
|
||||||
{
|
{
|
||||||
const QString hexPrefix = QLatin1String("0x");
|
|
||||||
if ((p.Flags & DEBUG_MODULE_USER_MODE) && (p.SymbolType != DEBUG_SYMTYPE_NONE))
|
if ((p.Flags & DEBUG_MODULE_USER_MODE) && (p.SymbolType != DEBUG_SYMTYPE_NONE))
|
||||||
module->symbolsRead = Module::ReadOk;
|
module->symbolsRead = Module::ReadOk;
|
||||||
else
|
else
|
||||||
module->symbolsRead = Module::ReadFailed;
|
module->symbolsRead = Module::ReadFailed;
|
||||||
module->startAddress = hexPrefix + QString::number(p.Base, 16);
|
module->startAddress = p.Base;
|
||||||
module->endAddress = hexPrefix + QString::number((p.Base + p.Size), 16);
|
module->endAddress = p.Base + p.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get module name by index
|
// Get module name by index
|
||||||
|
|||||||
@@ -1164,8 +1164,8 @@ void CdbEngine::handleModules(const CdbExtensionCommandPtr &reply)
|
|||||||
Debugger::Internal::Module module;
|
Debugger::Internal::Module module;
|
||||||
module.moduleName = QString::fromAscii(gdbmiModule.findChild("name").data());
|
module.moduleName = QString::fromAscii(gdbmiModule.findChild("name").data());
|
||||||
module.modulePath = QString::fromAscii(gdbmiModule.findChild("image").data());
|
module.modulePath = QString::fromAscii(gdbmiModule.findChild("image").data());
|
||||||
module.startAddress = QString::fromAscii(gdbmiModule.findChild("start").data());
|
module.startAddress = gdbmiModule.findChild("start").data().toULongLong(0, 0);
|
||||||
module.endAddress = QString::fromAscii(gdbmiModule.findChild("end").data());
|
module.endAddress = gdbmiModule.findChild("end").data().toULongLong(0, 0);
|
||||||
if (gdbmiModule.findChild("deferred").type() == Debugger::Internal::GdbMi::Invalid)
|
if (gdbmiModule.findChild("deferred").type() == Debugger::Internal::GdbMi::Invalid)
|
||||||
module.symbolsRead = Debugger::Internal::Module::ReadOk;
|
module.symbolsRead = Debugger::Internal::Module::ReadOk;
|
||||||
modules.push_back(module);
|
modules.push_back(module);
|
||||||
|
|||||||
@@ -1182,6 +1182,10 @@ void DebuggerEngine::loadAllSymbols()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebuggerEngine::loadSymbolsForStack()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void DebuggerEngine::requestModuleSymbols(const QString &)
|
void DebuggerEngine::requestModuleSymbols(const QString &)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ public:
|
|||||||
virtual void reloadModules();
|
virtual void reloadModules();
|
||||||
virtual void examineModules();
|
virtual void examineModules();
|
||||||
virtual void loadSymbols(const QString &moduleName);
|
virtual void loadSymbols(const QString &moduleName);
|
||||||
|
virtual void loadSymbolsForStack();
|
||||||
virtual void loadAllSymbols();
|
virtual void loadAllSymbols();
|
||||||
virtual void requestModuleSymbols(const QString &moduleName);
|
virtual void requestModuleSymbols(const QString &moduleName);
|
||||||
|
|
||||||
|
|||||||
@@ -2630,6 +2630,30 @@ void GdbEngine::loadAllSymbols()
|
|||||||
updateLocals();
|
updateLocals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GdbEngine::loadSymbolsForStack()
|
||||||
|
{
|
||||||
|
bool needUpdate = false;
|
||||||
|
const Modules &modules = modulesHandler()->modules();
|
||||||
|
foreach (const StackFrame &frame, stackHandler()->frames()) {
|
||||||
|
if (frame.function == _("??")) {
|
||||||
|
qDebug() << "LOAD FOR " << frame.address;
|
||||||
|
foreach (const Module &module, modules) {
|
||||||
|
if (module.startAddress <= frame.address
|
||||||
|
&& frame.address < module.endAddress) {
|
||||||
|
postCommand("sharedlibrary "
|
||||||
|
+ dotEscape(module.moduleName.toLocal8Bit()));
|
||||||
|
needUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needUpdate) {
|
||||||
|
reloadModulesInternal();
|
||||||
|
reloadStack(true);
|
||||||
|
updateLocals();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GdbEngine::requestModuleSymbols(const QString &moduleName)
|
void GdbEngine::requestModuleSymbols(const QString &moduleName)
|
||||||
{
|
{
|
||||||
QTemporaryFile tf(QDir::tempPath() + _("/gdbsymbols"));
|
QTemporaryFile tf(QDir::tempPath() + _("/gdbsymbols"));
|
||||||
@@ -2756,12 +2780,13 @@ void GdbEngine::handleModulesList(const GdbResponse &response)
|
|||||||
// shlib-info={...}...
|
// shlib-info={...}...
|
||||||
foreach (const GdbMi &item, response.data.children()) {
|
foreach (const GdbMi &item, response.data.children()) {
|
||||||
Module module;
|
Module module;
|
||||||
module.moduleName = QString::fromLocal8Bit(item.findChild("path").data());
|
module.moduleName =
|
||||||
|
QString::fromLocal8Bit(item.findChild("path").data());
|
||||||
module.symbolsRead = (item.findChild("state").data() == "Y")
|
module.symbolsRead = (item.findChild("state").data() == "Y")
|
||||||
? Module::ReadOk : Module::ReadFailed;
|
? Module::ReadOk : Module::ReadFailed;
|
||||||
module.startAddress = _(item.findChild("loaded_addr").data());
|
module.startAddress =
|
||||||
//: End address of loaded module
|
item.findChild("loaded_addr").data().toULongLong(0, 0);
|
||||||
module.endAddress = tr("<unknown>", "address");
|
module.endAddress = 0; // FIXME: End address not easily available.
|
||||||
modules.append(module);
|
modules.append(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -377,6 +377,7 @@ private: ////////// View & Data Stuff //////////
|
|||||||
//
|
//
|
||||||
void loadSymbols(const QString &moduleName);
|
void loadSymbols(const QString &moduleName);
|
||||||
void loadAllSymbols();
|
void loadAllSymbols();
|
||||||
|
void loadSymbolsForStack();
|
||||||
void requestModuleSymbols(const QString &moduleName);
|
void requestModuleSymbols(const QString &moduleName);
|
||||||
void reloadModules();
|
void reloadModules();
|
||||||
void examineModules();
|
void examineModules();
|
||||||
|
|||||||
@@ -107,11 +107,17 @@ QVariant ModulesModel::data(const QModelIndex &index, int role) const
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
return module.startAddress;
|
return QString(QLatin1String("0x")
|
||||||
|
+ QString::number(module.startAddress, 16));
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole) {
|
||||||
return module.endAddress;
|
if (module.endAddress)
|
||||||
|
return QString(QLatin1String("0x")
|
||||||
|
+ QString::number(module.endAddress, 16));
|
||||||
|
//: End address of loaded module
|
||||||
|
return tr("<unknown>", "address");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ public:
|
|||||||
QString modulePath;
|
QString modulePath;
|
||||||
SymbolReadState symbolsRead;
|
SymbolReadState symbolsRead;
|
||||||
SymbolType symbolsType;
|
SymbolType symbolsType;
|
||||||
QString startAddress;
|
quint64 startAddress;
|
||||||
QString endAddress;
|
quint64 endAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QVector<Module> Modules;
|
typedef QVector<Module> Modules;
|
||||||
|
|||||||
@@ -143,6 +143,10 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
actShowDisassembler->setEnabled(engineCapabilities & DisassemblerCapability);
|
actShowDisassembler->setEnabled(engineCapabilities & DisassemblerCapability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAction *actLoadSymbols = 0;
|
||||||
|
if (engineCapabilities & ShowModuleSymbolsCapability)
|
||||||
|
actLoadSymbols = menu.addAction(tr("Try to Load Unknown Symbols"));
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
#if 0 // @TODO: not implemented
|
#if 0 // @TODO: not implemented
|
||||||
menu.addAction(debuggerCore()->action(UseToolTipsInStackView));
|
menu.addAction(debuggerCore()->action(UseToolTipsInStackView));
|
||||||
@@ -162,7 +166,9 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
|
|
||||||
QAction *act = menu.exec(ev->globalPos());
|
QAction *act = menu.exec(ev->globalPos());
|
||||||
|
|
||||||
if (act == actCopyContents)
|
if (!act)
|
||||||
|
;
|
||||||
|
else if (act == actCopyContents)
|
||||||
copyContentsToClipboard();
|
copyContentsToClipboard();
|
||||||
else if (act == actAdjust)
|
else if (act == actAdjust)
|
||||||
resizeColumnsToContents();
|
resizeColumnsToContents();
|
||||||
@@ -172,6 +178,8 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
engine->openMemoryView(address);
|
engine->openMemoryView(address);
|
||||||
else if (act == actShowDisassembler)
|
else if (act == actShowDisassembler)
|
||||||
engine->openDisassemblerView(frame);
|
engine->openDisassemblerView(frame);
|
||||||
|
else if (act == actLoadSymbols)
|
||||||
|
engine->loadSymbolsForStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackWindow::copyContentsToClipboard()
|
void StackWindow::copyContentsToClipboard()
|
||||||
|
|||||||
Reference in New Issue
Block a user