Update terminal arguments pattern (#168)

* fix terminal arguments in debugger

* fix gnome-terminal args in debugger

* add args pattern for ConEmu
This commit is contained in:
Cyano Hao 2023-12-22 18:07:26 +08:00 committed by GitHub
parent 2e96a21f6f
commit 6a168cfd16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 14 deletions

View File

@ -136,9 +136,9 @@ bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStrin
mWatchModel->resetAllVarInfos(); mWatchModel->resetAllVarInfos();
if (pSettings->debugger().useGDBServer()) { if (pSettings->debugger().useGDBServer()) {
//deleted when thread finished //deleted when thread finished
QString params; QStringList params;
if (pSettings->executor().useParams()) if (pSettings->executor().useParams())
params = pSettings->executor().params(); params = splitProcessCommand(pSettings->executor().params());
mTarget = new DebugTarget(inferior,compilerSet->debugServer(),pSettings->debugger().GDBServerPort(),params); mTarget = new DebugTarget(inferior,compilerSet->debugServer(),pSettings->debugger().GDBServerPort(),params);
if (pSettings->executor().redirectInput()) if (pSettings->executor().redirectInput())
mTarget->setInputFile(pSettings->executor().inputFilename()); mTarget->setInputFile(pSettings->executor().inputFilename());
@ -1850,7 +1850,7 @@ void DebugReader::run()
mErrorOccured = false; mErrorOccured = false;
QString cmd = mDebuggerPath; QString cmd = mDebuggerPath;
// QString arguments = "--annotate=2"; // QString arguments = "--annotate=2";
QString arguments = "--interpret=mi --silent"; QStringList arguments{"--interpret=mi", "--silent"};
QString workingDir = QFileInfo(mDebuggerPath).path(); QString workingDir = QFileInfo(mDebuggerPath).path();
mProcess = std::make_shared<QProcess>(); mProcess = std::make_shared<QProcess>();
@ -1858,7 +1858,7 @@ void DebugReader::run()
mProcess.reset(); mProcess.reset();
}); });
mProcess->setProgram(cmd); mProcess->setProgram(cmd);
mProcess->setArguments(splitProcessCommand(arguments)); mProcess->setArguments(arguments);
mProcess->setProcessChannelMode(QProcess::MergedChannels); mProcess->setProcessChannelMode(QProcess::MergedChannels);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
@ -3012,7 +3012,7 @@ DebugTarget::DebugTarget(
const QString &inferior, const QString &inferior,
const QString &GDBServer, const QString &GDBServer,
int port, int port,
const QString& arguments, const QStringList& arguments,
QObject *parent): QObject *parent):
QThread(parent), QThread(parent),
mInferior(inferior), mInferior(inferior),
@ -3062,14 +3062,31 @@ void DebugTarget::run()
mErrorOccured = false; mErrorOccured = false;
//find first available port //find first available port
QStringList execArgs = QStringList{
mGDBServer,
QString("localhost:%1").arg(mPort),
mInferior,
} + mArguments;
QString cmd; QString cmd;
QString arguments; QStringList arguments;
std::unique_ptr<QTemporaryFile> fileOwner;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
cmd= mGDBServer; if (pSettings->environment().useCustomTerminal()) {
arguments = QString(" localhost:%1 \"%2\" %3").arg(mPort).arg(mInferior,mArguments); std::tie(cmd, arguments, fileOwner) = wrapCommandForTerminalEmulator(
pSettings->environment().terminalPath(),
pSettings->environment().terminalArgumentsPattern(),
execArgs
);
} else {
cmd = execArgs[0];
arguments = execArgs.mid(1);
}
#else #else
cmd= pSettings->environment().terminalPath(); std::tie(cmd, arguments, fileOwner) = wrapCommandForTerminalEmulator(
arguments = QString(" -e \"%1\" localhost:%2 \"%3\"").arg(mGDBServer).arg(mPort).arg(mInferior); pSettings->environment().terminalPath(),
pSettings->environment().terminalArgumentsPattern(),
execArgs
);
#endif #endif
QString workingDir = QFileInfo(mInferior).path(); QString workingDir = QFileInfo(mInferior).path();
@ -3078,7 +3095,7 @@ void DebugTarget::run()
mProcess.reset(); mProcess.reset();
}); });
mProcess->setProgram(cmd); mProcess->setProgram(cmd);
mProcess->setArguments(splitProcessCommand(arguments)); mProcess->setArguments(arguments);
mProcess->setProcessChannelMode(QProcess::MergedChannels); mProcess->setProcessChannelMode(QProcess::MergedChannels);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString path = env.value("PATH"); QString path = env.value("PATH");

View File

@ -431,7 +431,7 @@ public:
explicit DebugTarget(const QString& inferior, explicit DebugTarget(const QString& inferior,
const QString& GDBServer, const QString& GDBServer,
int port, int port,
const QString& arguments, const QStringList& arguments,
QObject *parent = nullptr); QObject *parent = nullptr);
void setInputFile(const QString& inputFile); void setInputFile(const QString& inputFile);
void stopDebug(); void stopDebug();
@ -443,7 +443,7 @@ signals:
void processError(QProcess::ProcessError error); void processError(QProcess::ProcessError error);
private: private:
QString mInferior; QString mInferior;
QString mArguments; QStringList mArguments;
QString mGDBServer; QString mGDBServer;
int mPort; int mPort;
bool mStop; bool mStop;

View File

@ -81,7 +81,7 @@
{ {
"name": "GNOME Terminal", "name": "GNOME Terminal",
"path": "gnome-terminal", "path": "gnome-terminal",
"argsPattern": "$term -- $argv" "argsPattern": "$term --wait -- $argv"
}, },
{ {
"name": "GNOME Terminator", "name": "GNOME Terminator",

View File

@ -38,6 +38,16 @@
"path": "alacritty.exe", "path": "alacritty.exe",
"argsPattern": "$term -e $argv" "argsPattern": "$term -e $argv"
}, },
{
"name": "ConEmu",
"path": "ConEmu.exe",
"argsPattern": "$term -run $argv"
},
{
"name": "ConEmu",
"path": "ConEmu64.exe",
"argsPattern": "$term -run $argv"
},
{ {
"name": "Konsole", "name": "Konsole",
"path": "konsole.exe", "path": "konsole.exe",