diff --git a/NEWS.md b/NEWS.md index 7b961cb3..8872df5a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ Red Panda C++ Version 1.1.1 - fix: project don't have compiler set bin folder setting - fix: when run/debug the executable, add current compiler set's bin folders to path - fix: when open in shell, add current compiler set's bin folders to path + - fix: when debug the executable using gdb server, add current compiler set's bin folders to path Red Panda C++ Version 1.1.0 - enhancement: when ctrl+mouse cursor hovered an identifier or header name, use underline to highlight it diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 7c6bfad7..be41eab0 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -122,6 +122,8 @@ bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStrin mTarget->deleteLater(); mTarget = nullptr; }); + mTarget->addBinDirs(binDirs); + mTarget->addBinDir(pSettings->dirs().appDir()); mTarget->start(); mTarget->waitStart(); } @@ -2390,6 +2392,21 @@ void DebugTarget::waitStart() mStartSemaphore.acquire(1); } +const QStringList &DebugTarget::binDirs() const +{ + return mBinDirs; +} + +void DebugTarget::addBinDirs(const QStringList &binDirs) +{ + mBinDirs.append(binDirs); +} + +void DebugTarget::addBinDir(const QString &binDir) +{ + mBinDirs.append(binDir); +} + void DebugTarget::run() { mStop = false; @@ -2414,19 +2431,20 @@ void DebugTarget::run() mProcess->setProgram(cmd); mProcess->setArguments(splitProcessCommand(arguments)); mProcess->setProcessChannelMode(QProcess::MergedChannels); + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + QString path = env.value("PATH"); + QStringList pathAdded = mBinDirs; + if (!path.isEmpty()) { + path = pathAdded.join(PATH_SEPARATOR) + PATH_SEPARATOR + path; + } else { + path = pathAdded.join(PATH_SEPARATOR); + } QString cmdDir = extractFileDir(cmd); if (!cmdDir.isEmpty()) { - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - QString path = env.value("PATH"); - cmdDir.replace("/",QDir::separator()); - if (path.isEmpty()) { - path = cmdDir; - } else { - path = cmdDir + PATH_SEPARATOR + path; - } - env.insert("PATH",path); - mProcess->setProcessEnvironment(env); + path = cmdDir + PATH_SEPARATOR + path; } + env.insert("PATH",path); + mProcess->setProcessEnvironment(env); mProcess->setWorkingDirectory(workingDir); #ifdef Q_OS_WIN diff --git a/RedPandaIDE/debugger.h b/RedPandaIDE/debugger.h index c55c3453..86a5212c 100644 --- a/RedPandaIDE/debugger.h +++ b/RedPandaIDE/debugger.h @@ -359,6 +359,9 @@ public: void setInputFile(const QString& inputFile); void stopDebug(); void waitStart(); + const QStringList &binDirs() const; + void addBinDirs(const QStringList &binDirs); + void addBinDir(const QString &binDir); signals: void processError(QProcess::ProcessError error); private: @@ -370,6 +373,7 @@ private: QSemaphore mStartSemaphore; bool mErrorOccured; QString mInputFile; + QStringList mBinDirs; // QThread interface protected: