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

View File

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

View File

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

View File

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