Debugger: Use more FilePaths in module handling interface

Change-Id: Ie058b928900015d0f71776151547bf7ba32a62bf
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2023-03-14 08:27:50 +01:00
parent 8778eaaaa0
commit c08322900f
12 changed files with 49 additions and 48 deletions

View File

@@ -1441,15 +1441,16 @@ void CdbEngine::reloadModules()
runCommand({"modules", ExtensionCommand, CB(handleModules)}); runCommand({"modules", ExtensionCommand, CB(handleModules)});
} }
void CdbEngine::loadSymbols(const QString & /* moduleName */) void CdbEngine::loadSymbols(const FilePath &moduleName)
{ {
Q_UNUSED(moduleName)
} }
void CdbEngine::loadAllSymbols() void CdbEngine::loadAllSymbols()
{ {
} }
void CdbEngine::requestModuleSymbols(const QString &moduleName) void CdbEngine::requestModuleSymbols(const FilePath &moduleName)
{ {
Q_UNUSED(moduleName) Q_UNUSED(moduleName)
} }

View File

@@ -65,9 +65,9 @@ public:
void changeMemory(MemoryAgent *, quint64 addr, const QByteArray &data) override; void changeMemory(MemoryAgent *, quint64 addr, const QByteArray &data) override;
void reloadModules() override; void reloadModules() override;
void loadSymbols(const QString &moduleName) override; void loadSymbols(const Utils::FilePath &moduleName) override;
void loadAllSymbols() override; void loadAllSymbols() override;
void requestModuleSymbols(const QString &moduleName) override; void requestModuleSymbols(const Utils::FilePath &moduleName) override;
void reloadRegisters() override; void reloadRegisters() override;
void reloadSourceFiles() override; void reloadSourceFiles() override;

View File

@@ -2083,7 +2083,7 @@ void DebuggerEngine::examineModules()
{ {
} }
void DebuggerEngine::loadSymbols(const QString &) void DebuggerEngine::loadSymbols(const FilePath &)
{ {
} }
@@ -2095,11 +2095,11 @@ void DebuggerEngine::loadSymbolsForStack()
{ {
} }
void DebuggerEngine::requestModuleSymbols(const QString &) void DebuggerEngine::requestModuleSymbols(const FilePath &)
{ {
} }
void DebuggerEngine::requestModuleSections(const QString &) void DebuggerEngine::requestModuleSections(const FilePath &)
{ {
} }
@@ -2652,7 +2652,7 @@ static void createNewDock(QWidget *widget)
dockWidget->show(); dockWidget->show();
} }
void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols &symbols) void DebuggerEngine::showModuleSymbols(const FilePath &moduleName, const Symbols &symbols)
{ {
auto w = new QTreeWidget; auto w = new QTreeWidget;
w->setUniformRowHeights(true); w->setUniformRowHeights(true);
@@ -2660,7 +2660,7 @@ void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols
w->setRootIsDecorated(false); w->setRootIsDecorated(false);
w->setAlternatingRowColors(true); w->setAlternatingRowColors(true);
w->setSortingEnabled(true); w->setSortingEnabled(true);
w->setObjectName("Symbols." + moduleName); w->setObjectName("Symbols." + moduleName.toFSPathString());
QStringList header; QStringList header;
header.append(Tr::tr("Symbol")); header.append(Tr::tr("Symbol"));
header.append(Tr::tr("Address")); header.append(Tr::tr("Address"));
@@ -2668,7 +2668,7 @@ void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols
header.append(Tr::tr("Section")); header.append(Tr::tr("Section"));
header.append(Tr::tr("Name")); header.append(Tr::tr("Name"));
w->setHeaderLabels(header); w->setHeaderLabels(header);
w->setWindowTitle(Tr::tr("Symbols in \"%1\"").arg(moduleName)); w->setWindowTitle(Tr::tr("Symbols in \"%1\"").arg(moduleName.toUserOutput()));
for (const Symbol &s : symbols) { for (const Symbol &s : symbols) {
auto it = new QTreeWidgetItem; auto it = new QTreeWidgetItem;
it->setData(0, Qt::DisplayRole, s.name); it->setData(0, Qt::DisplayRole, s.name);
@@ -2681,7 +2681,7 @@ void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols
createNewDock(w); createNewDock(w);
} }
void DebuggerEngine::showModuleSections(const QString &moduleName, const Sections &sections) void DebuggerEngine::showModuleSections(const FilePath &moduleName, const Sections &sections)
{ {
auto w = new QTreeWidget; auto w = new QTreeWidget;
w->setUniformRowHeights(true); w->setUniformRowHeights(true);
@@ -2689,7 +2689,7 @@ void DebuggerEngine::showModuleSections(const QString &moduleName, const Section
w->setRootIsDecorated(false); w->setRootIsDecorated(false);
w->setAlternatingRowColors(true); w->setAlternatingRowColors(true);
w->setSortingEnabled(true); w->setSortingEnabled(true);
w->setObjectName("Sections." + moduleName); w->setObjectName("Sections." + moduleName.toFSPathString());
QStringList header; QStringList header;
header.append(Tr::tr("Name")); header.append(Tr::tr("Name"));
header.append(Tr::tr("From")); header.append(Tr::tr("From"));
@@ -2697,7 +2697,7 @@ void DebuggerEngine::showModuleSections(const QString &moduleName, const Section
header.append(Tr::tr("Address")); header.append(Tr::tr("Address"));
header.append(Tr::tr("Flags")); header.append(Tr::tr("Flags"));
w->setHeaderLabels(header); w->setHeaderLabels(header);
w->setWindowTitle(Tr::tr("Sections in \"%1\"").arg(moduleName)); w->setWindowTitle(Tr::tr("Sections in \"%1\"").arg(moduleName.toUserOutput()));
for (const Section &s : sections) { for (const Section &s : sections) {
auto it = new QTreeWidgetItem; auto it = new QTreeWidgetItem;
it->setData(0, Qt::DisplayRole, s.name); it->setData(0, Qt::DisplayRole, s.name);

View File

@@ -303,11 +303,11 @@ public:
virtual void reloadModules(); virtual void reloadModules();
virtual void examineModules(); virtual void examineModules();
virtual void loadSymbols(const QString &moduleName); virtual void loadSymbols(const Utils::FilePath &moduleName);
virtual void loadSymbolsForStack(); virtual void loadSymbolsForStack();
virtual void loadAllSymbols(); virtual void loadAllSymbols();
virtual void requestModuleSymbols(const QString &moduleName); virtual void requestModuleSymbols(const Utils::FilePath &moduleName);
virtual void requestModuleSections(const QString &moduleName); virtual void requestModuleSections(const Utils::FilePath &moduleName);
virtual void reloadRegisters(); virtual void reloadRegisters();
virtual void reloadPeripheralRegisters(); virtual void reloadPeripheralRegisters();
@@ -452,8 +452,8 @@ public:
void openMemoryEditor(); void openMemoryEditor();
static void showModuleSymbols(const QString &moduleName, const QVector<Symbol> &symbols); static void showModuleSymbols(const Utils::FilePath &moduleName, const QVector<Symbol> &symbols);
static void showModuleSections(const QString &moduleName, const QVector<Section> &sections); static void showModuleSections(const Utils::FilePath &moduleName, const QVector<Section> &sections);
void handleExecDetach(); void handleExecDetach();
void handleExecContinue(); void handleExecContinue();

View File

@@ -2783,10 +2783,10 @@ static QString dotEscape(QString str)
return str; return str;
} }
void GdbEngine::loadSymbols(const QString &modulePath) void GdbEngine::loadSymbols(const FilePath &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)
runCommand({"sharedlibrary " + dotEscape(modulePath)}); runCommand({"sharedlibrary " + dotEscape(modulePath.path())});
reloadModulesInternal(); reloadModulesInternal();
reloadStack(); reloadStack();
updateLocals(); updateLocals();
@@ -2824,7 +2824,7 @@ void GdbEngine::loadSymbolsForStack()
} }
static void handleShowModuleSymbols(const DebuggerResponse &response, static void handleShowModuleSymbols(const DebuggerResponse &response,
const QString &modulePath, const QString &fileName) const FilePath &modulePath, const QString &fileName)
{ {
if (response.resultClass == ResultDone) { if (response.resultClass == ResultDone) {
Symbols symbols; Symbols symbols;
@@ -2883,21 +2883,21 @@ static void handleShowModuleSymbols(const DebuggerResponse &response,
} }
} }
void GdbEngine::requestModuleSymbols(const QString &modulePath) void GdbEngine::requestModuleSymbols(const FilePath &modulePath)
{ {
Utils::TemporaryFile tf("gdbsymbols"); TemporaryFile tf("gdbsymbols");
if (!tf.open()) if (!tf.open())
return; return;
QString fileName = tf.fileName(); QString fileName = tf.fileName();
tf.close(); tf.close();
DebuggerCommand cmd("maint print msymbols \"" + fileName + "\" " + modulePath, NeedsTemporaryStop); DebuggerCommand cmd("maint print msymbols \"" + fileName + "\" " + modulePath.path(), NeedsTemporaryStop);
cmd.callback = [modulePath, fileName](const DebuggerResponse &r) { cmd.callback = [modulePath, fileName](const DebuggerResponse &r) {
handleShowModuleSymbols(r, modulePath, fileName); handleShowModuleSymbols(r, modulePath, fileName);
}; };
runCommand(cmd); runCommand(cmd);
} }
void GdbEngine::requestModuleSections(const QString &moduleName) void GdbEngine::requestModuleSections(const FilePath &moduleName)
{ {
// There seems to be no way to get the symbols from a single .so. // There seems to be no way to get the symbols from a single .so.
DebuggerCommand cmd("maint info section ALLOBJ", NeedsTemporaryStop); DebuggerCommand cmd("maint info section ALLOBJ", NeedsTemporaryStop);
@@ -2908,14 +2908,14 @@ void GdbEngine::requestModuleSections(const QString &moduleName)
} }
void GdbEngine::handleShowModuleSections(const DebuggerResponse &response, void GdbEngine::handleShowModuleSections(const DebuggerResponse &response,
const QString &moduleName) const FilePath &moduleName)
{ {
// ~" Object file: /usr/lib/i386-linux-gnu/libffi.so.6\n" // ~" Object file: /usr/lib/i386-linux-gnu/libffi.so.6\n"
// ~" 0xb44a6114->0xb44a6138 at 0x00000114: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS\n" // ~" 0xb44a6114->0xb44a6138 at 0x00000114: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS\n"
if (response.resultClass == ResultDone) { if (response.resultClass == ResultDone) {
const QStringList lines = response.consoleStreamOutput.split('\n'); const QStringList lines = response.consoleStreamOutput.split('\n');
const QString prefix = " Object file: "; const QString prefix = " Object file: ";
const QString needle = prefix + moduleName; const QString needle = prefix + moduleName.path();
Sections sections; Sections sections;
bool active = false; bool active = false;
for (const QString &line : std::as_const(lines)) { for (const QString &line : std::as_const(lines)) {

View File

@@ -216,17 +216,17 @@ private: ////////// General Interface //////////
// //
// Modules specific stuff // Modules specific stuff
// //
void loadSymbols(const QString &moduleName) final; void loadSymbols(const Utils::FilePath &moduleName) final;
void loadAllSymbols() final; void loadAllSymbols() final;
void loadSymbolsForStack() final; void loadSymbolsForStack() final;
void requestModuleSymbols(const QString &moduleName) final; void requestModuleSymbols(const Utils::FilePath &moduleName) final;
void requestModuleSections(const QString &moduleName) final; void requestModuleSections(const Utils::FilePath &moduleName) final;
void reloadModules() final; void reloadModules() final;
void examineModules() final; void examineModules() final;
void reloadModulesInternal(); void reloadModulesInternal();
void handleModulesList(const DebuggerResponse &response); void handleModulesList(const DebuggerResponse &response);
void handleShowModuleSections(const DebuggerResponse &response, const QString &moduleName); void handleShowModuleSections(const DebuggerResponse &response, const Utils::FilePath &moduleName);
// //
// Snapshot specific stuff // Snapshot specific stuff

View File

@@ -630,7 +630,7 @@ void LldbEngine::handleInterpreterBreakpointModified(const GdbMi &bpItem)
updateBreakpointData(bp, bpItem, false); updateBreakpointData(bp, bpItem, false);
} }
void LldbEngine::loadSymbols(const QString &moduleName) void LldbEngine::loadSymbols(const FilePath &moduleName)
{ {
Q_UNUSED(moduleName) Q_UNUSED(moduleName)
} }
@@ -660,13 +660,13 @@ void LldbEngine::reloadModules()
runCommand(cmd); runCommand(cmd);
} }
void LldbEngine::requestModuleSymbols(const QString &moduleName) void LldbEngine::requestModuleSymbols(const FilePath &moduleName)
{ {
DebuggerCommand cmd("fetchSymbols"); DebuggerCommand cmd("fetchSymbols");
cmd.arg("module", moduleName); cmd.arg("module", moduleName.path());
cmd.callback = [moduleName](const DebuggerResponse &response) { cmd.callback = [moduleName](const DebuggerResponse &response) {
const GdbMi &symbols = response.data["symbols"]; const GdbMi &symbols = response.data["symbols"];
QString moduleName = response.data["module"].data(); const QString module = response.data["module"].data();
Symbols syms; Symbols syms;
for (const GdbMi &item : symbols) { for (const GdbMi &item : symbols) {
Symbol symbol; Symbol symbol;
@@ -677,7 +677,7 @@ void LldbEngine::requestModuleSymbols(const QString &moduleName)
symbol.demangled = item["demangled"].data(); symbol.demangled = item["demangled"].data();
syms.append(symbol); syms.append(symbol);
} }
showModuleSymbols(moduleName, syms); showModuleSymbols(moduleName.withNewPath(module), syms);
}; };
runCommand(cmd); runCommand(cmd);
} }

View File

@@ -68,9 +68,9 @@ private:
void assignValueInDebugger(WatchItem *item, const QString &expr, const QVariant &value) override; void assignValueInDebugger(WatchItem *item, const QString &expr, const QVariant &value) override;
void executeDebuggerCommand(const QString &command) override; void executeDebuggerCommand(const QString &command) override;
void loadSymbols(const QString &moduleName) override; void loadSymbols(const Utils::FilePath &moduleName) override;
void loadAllSymbols() override; void loadAllSymbols() override;
void requestModuleSymbols(const QString &moduleName) override; void requestModuleSymbols(const Utils::FilePath &moduleName) override;
void reloadModules() override; void reloadModules() override;
void reloadRegisters() override; void reloadRegisters() override;
void reloadSourceFiles() override {} void reloadSourceFiles() override {}

View File

@@ -263,7 +263,7 @@ void PdbEngine::removeBreakpoint(const Breakpoint &bp)
notifyBreakpointRemoveOk(bp); notifyBreakpointRemoveOk(bp);
} }
void PdbEngine::loadSymbols(const QString &moduleName) void PdbEngine::loadSymbols(const FilePath &moduleName)
{ {
Q_UNUSED(moduleName) Q_UNUSED(moduleName)
} }
@@ -300,10 +300,10 @@ void PdbEngine::refreshModules(const GdbMi &modules)
handler->endUpdateAll(); handler->endUpdateAll();
} }
void PdbEngine::requestModuleSymbols(const QString &moduleName) void PdbEngine::requestModuleSymbols(const FilePath &moduleName)
{ {
DebuggerCommand cmd("listSymbols"); DebuggerCommand cmd("listSymbols");
cmd.arg("module", moduleName); cmd.arg("module", moduleName.path());
runCommand(cmd); runCommand(cmd);
} }
@@ -341,7 +341,7 @@ void PdbEngine::refreshSymbols(const GdbMi &symbols)
symbol.name = item["name"].data(); symbol.name = item["name"].data();
syms.append(symbol); syms.append(symbol);
} }
showModuleSymbols(moduleName, syms); showModuleSymbols(runParameters().inferior.command.executable().withNewPath(moduleName), syms);
} }
bool PdbEngine::canHandleToolTip(const DebuggerToolTipContext &) const bool PdbEngine::canHandleToolTip(const DebuggerToolTipContext &) const

View File

@@ -52,9 +52,9 @@ private:
const QString &expr, const QVariant &value) override; const QString &expr, const QVariant &value) override;
void executeDebuggerCommand(const QString &command) override; void executeDebuggerCommand(const QString &command) override;
void loadSymbols(const QString &moduleName) override; void loadSymbols(const Utils::FilePath &moduleName) override;
void loadAllSymbols() override; void loadAllSymbols() override;
void requestModuleSymbols(const QString &moduleName) override; void requestModuleSymbols(const Utils::FilePath &moduleName) override;
void reloadModules() override; void reloadModules() override;
void reloadRegisters() override {} void reloadRegisters() override {}
void reloadSourceFiles() override {} void reloadSourceFiles() override {}

View File

@@ -736,7 +736,7 @@ bool QmlEngine::acceptsBreakpoint(const BreakpointParameters &bp) const
return bp.isQmlFileAndLineBreakpoint(); return bp.isQmlFileAndLineBreakpoint();
} }
void QmlEngine::loadSymbols(const QString &moduleName) void QmlEngine::loadSymbols(const FilePath &moduleName)
{ {
Q_UNUSED(moduleName) Q_UNUSED(moduleName)
} }
@@ -759,7 +759,7 @@ void QmlEngine::updateAll()
d->updateLocals(); d->updateLocals();
} }
void QmlEngine::requestModuleSymbols(const QString &moduleName) void QmlEngine::requestModuleSymbols(const FilePath &moduleName)
{ {
Q_UNUSED(moduleName) Q_UNUSED(moduleName)
} }

View File

@@ -75,9 +75,9 @@ private:
void assignValueInDebugger(WatchItem *item, void assignValueInDebugger(WatchItem *item,
const QString &expr, const QVariant &value) override; const QString &expr, const QVariant &value) override;
void loadSymbols(const QString &moduleName) override; void loadSymbols(const Utils::FilePath &moduleName) override;
void loadAllSymbols() override; void loadAllSymbols() override;
void requestModuleSymbols(const QString &moduleName) override; void requestModuleSymbols(const Utils::FilePath &moduleName) override;
void reloadModules() override; void reloadModules() override;
void reloadRegisters() override {} void reloadRegisters() override {}
void reloadSourceFiles() override; void reloadSourceFiles() override;