debugger: fix display/use of module name in ModulesView

Change-Id: I335ce9427f4c7abea84e109323869226c07e7f7c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
hjk
2012-03-16 13:34:00 +01:00
committed by hjk
parent 8e8168fc5c
commit 7c0a7a50dc
2 changed files with 28 additions and 19 deletions

View File

@@ -3140,10 +3140,10 @@ void GdbEngine::removeBreakpoint(BreakpointModelId id)
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
void GdbEngine::loadSymbols(const QString &moduleName) void GdbEngine::loadSymbols(const QString &modulePath)
{ {
// FIXME: gdb does not understand quoted names here (tested with 6.8) // FIXME: gdb does not understand quoted names here (tested with 6.8)
postCommand("sharedlibrary " + dotEscape(moduleName.toLocal8Bit())); postCommand("sharedlibrary " + dotEscape(modulePath.toLocal8Bit()));
reloadModulesInternal(); reloadModulesInternal();
reloadBreakListInternal(); reloadBreakListInternal();
reloadStack(true); reloadStack(true);
@@ -3170,7 +3170,7 @@ void GdbEngine::loadSymbolsForStack()
if (module.startAddress <= frame.address if (module.startAddress <= frame.address
&& frame.address < module.endAddress) { && frame.address < module.endAddress) {
postCommand("sharedlibrary " postCommand("sharedlibrary "
+ dotEscape(module.moduleName.toLocal8Bit())); + dotEscape(module.modulePath.toLocal8Bit()));
needUpdate = true; needUpdate = true;
} }
} }
@@ -3184,7 +3184,7 @@ void GdbEngine::loadSymbolsForStack()
} }
} }
void GdbEngine::requestModuleSymbols(const QString &moduleName) void GdbEngine::requestModuleSymbols(const QString &modulePath)
{ {
QTemporaryFile tf(QDir::tempPath() + _("/gdbsymbols")); QTemporaryFile tf(QDir::tempPath() + _("/gdbsymbols"));
if (!tf.open()) if (!tf.open())
@@ -3192,15 +3192,15 @@ void GdbEngine::requestModuleSymbols(const QString &moduleName)
QString fileName = tf.fileName(); QString fileName = tf.fileName();
tf.close(); tf.close();
postCommand("maint print msymbols " + fileName.toLocal8Bit() postCommand("maint print msymbols " + fileName.toLocal8Bit()
+ ' ' + moduleName.toLocal8Bit(), + ' ' + modulePath.toLocal8Bit(),
NeedsStop, CB(handleShowModuleSymbols), NeedsStop, CB(handleShowModuleSymbols),
QVariant(moduleName + QLatin1Char('@') + fileName)); QVariant(modulePath + QLatin1Char('@') + fileName));
} }
void GdbEngine::handleShowModuleSymbols(const GdbResponse &response) void GdbEngine::handleShowModuleSymbols(const GdbResponse &response)
{ {
const QString cookie = response.cookie.toString(); const QString cookie = response.cookie.toString();
const QString moduleName = cookie.section(QLatin1Char('@'), 0, 0); const QString modulePath = cookie.section(QLatin1Char('@'), 0, 0);
const QString fileName = cookie.section(QLatin1Char('@'), 1, 1); const QString fileName = cookie.section(QLatin1Char('@'), 1, 1);
if (response.resultClass == GdbResultDone) { if (response.resultClass == GdbResultDone) {
Symbols rc; Symbols rc;
@@ -3251,7 +3251,7 @@ void GdbEngine::handleShowModuleSymbols(const GdbResponse &response)
} }
file.close(); file.close();
file.remove(); file.remove();
debuggerCore()->showModuleSymbols(moduleName, rc); debuggerCore()->showModuleSymbols(modulePath, rc);
} else { } else {
showMessageBox(QMessageBox::Critical, tr("Cannot Read Symbols"), showMessageBox(QMessageBox::Critical, tr("Cannot Read Symbols"),
tr("Cannot read symbols for module \"%1\".").arg(fileName)); tr("Cannot read symbols for module \"%1\".").arg(fileName));
@@ -3270,6 +3270,11 @@ void GdbEngine::reloadModulesInternal()
postCommand("info shared", NeedsStop, CB(handleModulesList)); postCommand("info shared", NeedsStop, CB(handleModulesList));
} }
static QString nameFromPath(const QString &path)
{
return QFileInfo(path).baseName();
}
void GdbEngine::handleModulesList(const GdbResponse &response) void GdbEngine::handleModulesList(const GdbResponse &response)
{ {
Modules modules; Modules modules;
@@ -3285,7 +3290,8 @@ void GdbEngine::handleModulesList(const GdbResponse &response)
QTextStream ts(&line, QIODevice::ReadOnly); QTextStream ts(&line, QIODevice::ReadOnly);
if (line.startsWith(QLatin1String("0x"))) { if (line.startsWith(QLatin1String("0x"))) {
ts >> module.startAddress >> module.endAddress >> symbolsRead; ts >> module.startAddress >> module.endAddress >> symbolsRead;
module.moduleName = ts.readLine().trimmed(); module.modulePath = ts.readLine().trimmed();
module.moduleName = nameFromPath(module.modulePath);
module.symbolsRead = module.symbolsRead =
(symbolsRead == QLatin1String("Yes") ? Module::ReadOk : Module::ReadFailed); (symbolsRead == QLatin1String("Yes") ? Module::ReadOk : Module::ReadFailed);
modules.append(module); modules.append(module);
@@ -3295,7 +3301,8 @@ void GdbEngine::handleModulesList(const GdbResponse &response)
QTC_ASSERT(symbolsRead == QLatin1String("No"), continue); QTC_ASSERT(symbolsRead == QLatin1String("No"), continue);
module.startAddress = 0; module.startAddress = 0;
module.endAddress = 0; module.endAddress = 0;
module.moduleName = ts.readLine().trimmed(); module.modulePath = ts.readLine().trimmed();
module.moduleName = nameFromPath(module.modulePath);
modules.append(module); modules.append(module);
} }
} }
@@ -3307,8 +3314,9 @@ 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 = module.modulePath =
QString::fromLocal8Bit(item.findChild("path").data()); QString::fromLocal8Bit(item.findChild("path").data());
module.moduleName = nameFromPath(module.modulePath);
module.symbolsRead = (item.findChild("state").data() == "Y") module.symbolsRead = (item.findChild("state").data() == "Y")
? Module::ReadOk : Module::ReadFailed; ? Module::ReadOk : Module::ReadFailed;
module.startAddress = module.startAddress =
@@ -3327,8 +3335,8 @@ void GdbEngine::examineModules()
foreach (Module module, modulesHandler()->modules()) { foreach (Module module, modulesHandler()->modules()) {
if (module.symbolsType == Module::UnknownType) { if (module.symbolsType == Module::UnknownType) {
QProcess proc; QProcess proc;
qDebug() << _("objdump -h \"%1\"").arg(module.moduleName); qDebug() << _("objdump -h \"%1\"").arg(module.modulePath);
proc.start(_("objdump -h \"%1\"").arg(module.moduleName)); proc.start(_("objdump -h \"%1\"").arg(module.modulePath));
if (!proc.waitForStarted()) if (!proc.waitForStarted())
continue; continue;
if (!proc.waitForFinished()) if (!proc.waitForFinished())
@@ -3338,7 +3346,7 @@ void GdbEngine::examineModules()
module.symbolsType = Module::FastSymbols; module.symbolsType = Module::FastSymbols;
else else
module.symbolsType = Module::PlainSymbols; module.symbolsType = Module::PlainSymbols;
modulesHandler()->updateModule(module.moduleName, module); modulesHandler()->updateModule(module.modulePath, module);
} }
} }
} }

View File

@@ -72,7 +72,8 @@ void ModulesWindow::moduleActivated(const QModelIndex &index)
{ {
DebuggerEngine *engine = debuggerCore()->currentEngine(); DebuggerEngine *engine = debuggerCore()->currentEngine();
QTC_ASSERT(engine, return); QTC_ASSERT(engine, return);
engine->gotoLocation(index.data().toString()); if (index.isValid())
engine->gotoLocation(index.sibling(index.row(), 1).data().toString());
} }
void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev) void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
@@ -156,17 +157,17 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
if (act == actUpdateModuleList) if (act == actUpdateModuleList)
engine->reloadModules(); engine->reloadModules();
else if (act == actShowModuleSources) else if (act == actShowModuleSources)
engine->loadSymbols(name); engine->loadSymbols(fileName);
else if (act == actLoadSymbolsForAllModules) else if (act == actLoadSymbolsForAllModules)
engine->loadAllSymbols(); engine->loadAllSymbols();
else if (act == actExamineAllModules) else if (act == actExamineAllModules)
engine->examineModules(); engine->examineModules();
else if (act == actLoadSymbolsForModule) else if (act == actLoadSymbolsForModule)
engine->loadSymbols(name); engine->loadSymbols(fileName);
else if (act == actEditFile) else if (act == actEditFile)
engine->gotoLocation(name); engine->gotoLocation(fileName);
else if (act == actShowModuleSymbols) else if (act == actShowModuleSymbols)
engine->requestModuleSymbols(name); engine->requestModuleSymbols(fileName);
else if (actShowDependencies && act == actShowDependencies) else if (actShowDependencies && act == actShowDependencies)
QProcess::startDetached(QLatin1String("depends"), QStringList(fileName)); QProcess::startDetached(QLatin1String("depends"), QStringList(fileName));
else else