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,
|
||||
Module *module)
|
||||
{
|
||||
const QString hexPrefix = QLatin1String("0x");
|
||||
if ((p.Flags & DEBUG_MODULE_USER_MODE) && (p.SymbolType != DEBUG_SYMTYPE_NONE))
|
||||
module->symbolsRead = Module::ReadOk;
|
||||
else
|
||||
module->symbolsRead = Module::ReadFailed;
|
||||
module->startAddress = hexPrefix + QString::number(p.Base, 16);
|
||||
module->endAddress = hexPrefix + QString::number((p.Base + p.Size), 16);
|
||||
module->startAddress = p.Base;
|
||||
module->endAddress = p.Base + p.Size;
|
||||
}
|
||||
|
||||
// Get module name by index
|
||||
|
||||
@@ -1164,8 +1164,8 @@ void CdbEngine::handleModules(const CdbExtensionCommandPtr &reply)
|
||||
Debugger::Internal::Module module;
|
||||
module.moduleName = QString::fromAscii(gdbmiModule.findChild("name").data());
|
||||
module.modulePath = QString::fromAscii(gdbmiModule.findChild("image").data());
|
||||
module.startAddress = QString::fromAscii(gdbmiModule.findChild("start").data());
|
||||
module.endAddress = QString::fromAscii(gdbmiModule.findChild("end").data());
|
||||
module.startAddress = gdbmiModule.findChild("start").data().toULongLong(0, 0);
|
||||
module.endAddress = gdbmiModule.findChild("end").data().toULongLong(0, 0);
|
||||
if (gdbmiModule.findChild("deferred").type() == Debugger::Internal::GdbMi::Invalid)
|
||||
module.symbolsRead = Debugger::Internal::Module::ReadOk;
|
||||
modules.push_back(module);
|
||||
|
||||
@@ -1182,6 +1182,10 @@ void DebuggerEngine::loadAllSymbols()
|
||||
{
|
||||
}
|
||||
|
||||
void DebuggerEngine::loadSymbolsForStack()
|
||||
{
|
||||
}
|
||||
|
||||
void DebuggerEngine::requestModuleSymbols(const QString &)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ public:
|
||||
virtual void reloadModules();
|
||||
virtual void examineModules();
|
||||
virtual void loadSymbols(const QString &moduleName);
|
||||
virtual void loadSymbolsForStack();
|
||||
virtual void loadAllSymbols();
|
||||
virtual void requestModuleSymbols(const QString &moduleName);
|
||||
|
||||
|
||||
@@ -2630,6 +2630,30 @@ void GdbEngine::loadAllSymbols()
|
||||
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)
|
||||
{
|
||||
QTemporaryFile tf(QDir::tempPath() + _("/gdbsymbols"));
|
||||
@@ -2756,12 +2780,13 @@ void GdbEngine::handleModulesList(const GdbResponse &response)
|
||||
// shlib-info={...}...
|
||||
foreach (const GdbMi &item, response.data.children()) {
|
||||
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::ReadOk : Module::ReadFailed;
|
||||
module.startAddress = _(item.findChild("loaded_addr").data());
|
||||
//: End address of loaded module
|
||||
module.endAddress = tr("<unknown>", "address");
|
||||
module.startAddress =
|
||||
item.findChild("loaded_addr").data().toULongLong(0, 0);
|
||||
module.endAddress = 0; // FIXME: End address not easily available.
|
||||
modules.append(module);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,6 +377,7 @@ private: ////////// View & Data Stuff //////////
|
||||
//
|
||||
void loadSymbols(const QString &moduleName);
|
||||
void loadAllSymbols();
|
||||
void loadSymbolsForStack();
|
||||
void requestModuleSymbols(const QString &moduleName);
|
||||
void reloadModules();
|
||||
void examineModules();
|
||||
|
||||
@@ -107,11 +107,17 @@ QVariant ModulesModel::data(const QModelIndex &index, int role) const
|
||||
break;
|
||||
case 4:
|
||||
if (role == Qt::DisplayRole)
|
||||
return module.startAddress;
|
||||
return QString(QLatin1String("0x")
|
||||
+ QString::number(module.startAddress, 16));
|
||||
break;
|
||||
case 5:
|
||||
if (role == Qt::DisplayRole)
|
||||
return module.endAddress;
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (module.endAddress)
|
||||
return QString(QLatin1String("0x")
|
||||
+ QString::number(module.endAddress, 16));
|
||||
//: End address of loaded module
|
||||
return tr("<unknown>", "address");
|
||||
}
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
@@ -90,8 +90,8 @@ public:
|
||||
QString modulePath;
|
||||
SymbolReadState symbolsRead;
|
||||
SymbolType symbolsType;
|
||||
QString startAddress;
|
||||
QString endAddress;
|
||||
quint64 startAddress;
|
||||
quint64 endAddress;
|
||||
};
|
||||
|
||||
typedef QVector<Module> Modules;
|
||||
|
||||
@@ -143,6 +143,10 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
|
||||
actShowDisassembler->setEnabled(engineCapabilities & DisassemblerCapability);
|
||||
}
|
||||
|
||||
QAction *actLoadSymbols = 0;
|
||||
if (engineCapabilities & ShowModuleSymbolsCapability)
|
||||
actLoadSymbols = menu.addAction(tr("Try to Load Unknown Symbols"));
|
||||
|
||||
menu.addSeparator();
|
||||
#if 0 // @TODO: not implemented
|
||||
menu.addAction(debuggerCore()->action(UseToolTipsInStackView));
|
||||
@@ -162,7 +166,9 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
|
||||
|
||||
QAction *act = menu.exec(ev->globalPos());
|
||||
|
||||
if (act == actCopyContents)
|
||||
if (!act)
|
||||
;
|
||||
else if (act == actCopyContents)
|
||||
copyContentsToClipboard();
|
||||
else if (act == actAdjust)
|
||||
resizeColumnsToContents();
|
||||
@@ -172,6 +178,8 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
|
||||
engine->openMemoryView(address);
|
||||
else if (act == actShowDisassembler)
|
||||
engine->openDisassemblerView(frame);
|
||||
else if (act == actLoadSymbols)
|
||||
engine->loadSymbolsForStack();
|
||||
}
|
||||
|
||||
void StackWindow::copyContentsToClipboard()
|
||||
|
||||
Reference in New Issue
Block a user