- fix: when debug the executable using gdb server, add current compiler set's bin folders to path

This commit is contained in:
Roy Qu 2022-06-16 21:56:07 +08:00
parent 3d6d3c5210
commit 9dacc9bbb9
3 changed files with 33 additions and 10 deletions

View File

@ -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

View File

@ -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);
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;
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()) {
path = cmdDir + PATH_SEPARATOR + path;
}
env.insert("PATH",path);
mProcess->setProcessEnvironment(env);
}
mProcess->setWorkingDirectory(workingDir);
#ifdef Q_OS_WIN

View File

@ -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: