Commit a13aa0f6 authored by Kåre Särs's avatar Kåre Särs

gdb-plugin: Add warning about not-found file and search path info

Make the src-path update active without restarting debugging.
Ensure that the target name is unique.
parent ddf9dea3
......@@ -159,7 +159,11 @@ void AdvancedGDBSettings::setConfigs(const QStringList &cfgs)
return;
start = 16; // "set directories "
tmp = cfgs[SrcPathsIndex].mid(start);
u_srcPaths->addItems(tmp.split(pathSeparator));
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
u_srcPaths->addItems(tmp.split(pathSeparator, QString::SkipEmptyParts));
#else
u_srcPaths->addItems(tmp.split(pathSeparator, Qt::SkipEmptyParts));
#endif
// Custom init
for (int i = CustomStartIndex; i < cfgs.count(); i++) {
......
......@@ -228,6 +228,7 @@ void ConfigView::writeConfig(KConfigGroup &group)
const GDBTargetConf ConfigView::currentTarget() const
{
GDBTargetConf cfg;
cfg.targetName = m_targetCombo->currentText();
cfg.executable = m_executable->text();
cfg.workDir = m_workingDirectory->text();
cfg.arguments = m_arguments->text();
......@@ -270,8 +271,16 @@ bool ConfigView::showIOTab() const
void ConfigView::slotTargetEdited(const QString &newText)
{
QString newComboText(newText);
for (int i=0; i<m_targetCombo->count(); ++i) {
if (i != m_targetCombo->currentIndex() &&
m_targetCombo->itemText(i) == newComboText)
{
newComboText = newComboText + QStringLiteral(" 2");
}
}
int cursorPosition = m_targetCombo->lineEdit()->cursorPosition();
m_targetCombo->setItemText(m_targetCombo->currentIndex(), newText);
m_targetCombo->setItemText(m_targetCombo->currentIndex(), newComboText);
m_targetCombo->lineEdit()->setCursorPosition(cursorPosition);
// rebuild the target menu
......@@ -449,6 +458,7 @@ void ConfigView::slotAdvancedClicked()
// save the new values
newList << m_advanced->configs();
m_targetCombo->setItemData(m_targetCombo->currentIndex(), newList);
emit configChanged();
}
}
......
......@@ -31,6 +31,7 @@
#include <KTextEditor/MainWindow>
struct GDBTargetConf {
QString targetName;
QString executable;
QString workDir;
QString arguments;
......@@ -61,6 +62,8 @@ public:
Q_SIGNALS:
void showIO(bool show);
void configChanged();
private Q_SLOTS:
void slotTargetEdited(const QString &newText);
void slotTargetSelected(int index);
......
......@@ -535,8 +535,6 @@ void DebugView::issueNextCommand()
QUrl DebugView::resolveFileName(const QString &fileName)
{
QUrl url;
QFileInfo fInfo = QFileInfo(fileName);
// did we end up with an absolute path or a relative one?
if (fInfo.exists()) {
......@@ -568,6 +566,7 @@ QUrl DebugView::resolveFileName(const QString &fileName)
}
// we can not do anything just return the fileName
emit sourceFileNotFound(fileName);
return QUrl::fromUserInput(fileName);
}
......@@ -591,3 +590,13 @@ void DebugView::slotQueryLocals(bool query)
issueNextCommand();
}
}
QString DebugView::targetName() const
{
return m_targetConf.targetName;
}
void DebugView::setFileSearchPaths(const QStringList &paths)
{
m_targetConf.srcPaths = paths;
}
......@@ -37,6 +37,9 @@ public:
void issueCommand(QString const &cmd);
QString targetName() const;
void setFileSearchPaths(const QStringList &paths);
public Q_SLOTS:
void slotInterrupt();
void slotStepInto();
......@@ -71,6 +74,7 @@ Q_SIGNALS:
void readyForInput(bool ready);
void programEnded();
void gdbEnded();
void sourceFileNotFound(const QString &fileName);
private:
enum State { none, ready, executingCmd, listingBreakpoints, infoStack, infoArgs, printThis, infoLocals, infoThreads };
......
......@@ -173,8 +173,19 @@ KatePluginGDBView::KatePluginGDBView(KTextEditor::Plugin *plugin, KTextEditor::M
connect(m_debugView, &DebugView::threadInfo, this, &KatePluginGDBView::insertThread);
connect(m_debugView, &DebugView::sourceFileNotFound, this, [this](const QString &fileName) {
displayMessage(xi18nc("@info", "<title>Could not open file:</title><nl/>%1<br/>Try adding a search path to Advanced Settings -> Source file search paths", fileName), KTextEditor::Message::Error);
});
connect(m_localsView, &LocalsView::localsVisible, m_debugView, &DebugView::slotQueryLocals);
connect(m_configView, &ConfigView::configChanged, this, [this]() {
GDBTargetConf config = m_configView->currentTarget();
if (m_debugView->targetName() == config.targetName) {
m_debugView->setFileSearchPaths(config.srcPaths);
}
});
// Actions
m_configView->registerActions(actionCollection());
......@@ -717,4 +728,22 @@ void KatePluginGDBView::handleEsc(QEvent *e)
}
}
void KatePluginGDBView::displayMessage(const QString &msg, KTextEditor::Message::MessageType level)
{
KTextEditor::View *kv = m_mainWin->activeView();
if (!kv)
return;
delete m_infoMessage;
m_infoMessage = new KTextEditor::Message(msg, level);
m_infoMessage->setWordWrap(true);
m_infoMessage->setPosition(KTextEditor::Message::BottomInView);
m_infoMessage->setAutoHide(8000);
m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate);
m_infoMessage->setView(kv);
kv->document()->postMessage(m_infoMessage);
}
#include "plugin_kategdb.moc"
......@@ -15,6 +15,7 @@
#include <KActionMenu>
#include <KTextEditor/Application>
#include <KTextEditor/MainWindow>
#include <KTextEditor/Message>
#include <KTextEditor/Plugin>
#include <KTextEditor/SessionConfigInterface>
#include <KXMLGUIClient>
......@@ -90,6 +91,8 @@ protected:
private:
QString currentWord();
void displayMessage(const QString &message, KTextEditor::Message::MessageType level);
KTextEditor::Application *m_kateApplication;
KTextEditor::MainWindow *m_mainWin;
QWidget *m_toolView;
......@@ -112,6 +115,7 @@ private:
int m_lastExecLine;
int m_lastExecFrame;
bool m_focusOnInput;
QPointer<KTextEditor::Message> m_infoMessage;
};
#endif
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