- 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: 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 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 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 Red Panda C++ Version 1.1.0
- enhancement: when ctrl+mouse cursor hovered an identifier or header name, use underline to highlight it - 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->deleteLater();
mTarget = nullptr; mTarget = nullptr;
}); });
mTarget->addBinDirs(binDirs);
mTarget->addBinDir(pSettings->dirs().appDir());
mTarget->start(); mTarget->start();
mTarget->waitStart(); mTarget->waitStart();
} }
@ -2390,6 +2392,21 @@ void DebugTarget::waitStart()
mStartSemaphore.acquire(1); 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() void DebugTarget::run()
{ {
mStop = false; mStop = false;
@ -2414,19 +2431,20 @@ void DebugTarget::run()
mProcess->setProgram(cmd); mProcess->setProgram(cmd);
mProcess->setArguments(splitProcessCommand(arguments)); mProcess->setArguments(splitProcessCommand(arguments));
mProcess->setProcessChannelMode(QProcess::MergedChannels); mProcess->setProcessChannelMode(QProcess::MergedChannels);
QString cmdDir = extractFileDir(cmd);
if (!cmdDir.isEmpty()) {
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString path = env.value("PATH"); QString path = env.value("PATH");
cmdDir.replace("/",QDir::separator()); QStringList pathAdded = mBinDirs;
if (path.isEmpty()) { if (!path.isEmpty()) {
path = cmdDir; path = pathAdded.join(PATH_SEPARATOR) + PATH_SEPARATOR + path;
} else { } else {
path = pathAdded.join(PATH_SEPARATOR);
}
QString cmdDir = extractFileDir(cmd);
if (!cmdDir.isEmpty()) {
path = cmdDir + PATH_SEPARATOR + path; path = cmdDir + PATH_SEPARATOR + path;
} }
env.insert("PATH",path); env.insert("PATH",path);
mProcess->setProcessEnvironment(env); mProcess->setProcessEnvironment(env);
}
mProcess->setWorkingDirectory(workingDir); mProcess->setWorkingDirectory(workingDir);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

View File

@ -359,6 +359,9 @@ public:
void setInputFile(const QString& inputFile); void setInputFile(const QString& inputFile);
void stopDebug(); void stopDebug();
void waitStart(); void waitStart();
const QStringList &binDirs() const;
void addBinDirs(const QStringList &binDirs);
void addBinDir(const QString &binDir);
signals: signals:
void processError(QProcess::ProcessError error); void processError(QProcess::ProcessError error);
private: private:
@ -370,6 +373,7 @@ private:
QSemaphore mStartSemaphore; QSemaphore mStartSemaphore;
bool mErrorOccured; bool mErrorOccured;
QString mInputFile; QString mInputFile;
QStringList mBinDirs;
// QThread interface // QThread interface
protected: protected: