Changeset View
Changeset View
Standalone View
Standalone View
src/backtracegenerator.cpp
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 70 | { | |||
---|---|---|---|---|---|
87 | m_proc->setEnv(QStringLiteral("LC_ALL"), QStringLiteral("C")); // force C locale | 87 | m_proc->setEnv(QStringLiteral("LC_ALL"), QStringLiteral("C")); // force C locale | ||
88 | 88 | | |||
89 | m_temp = new QTemporaryFile; | 89 | m_temp = new QTemporaryFile; | ||
90 | m_temp->open(); | 90 | m_temp->open(); | ||
91 | m_temp->write(m_debugger.backtraceBatchCommands().toLatin1()); | 91 | m_temp->write(m_debugger.backtraceBatchCommands().toLatin1()); | ||
92 | m_temp->write("\n", 1); | 92 | m_temp->write("\n", 1); | ||
93 | m_temp->flush(); | 93 | m_temp->flush(); | ||
94 | 94 | | |||
95 | auto preamble = new QTemporaryFile(m_proc); | ||||
sitter: This is leaking the file, is it not? It never deletes this object. | |||||
96 | preamble->open(); | ||||
97 | preamble->write(m_debugger.preambleCommands().toUtf8()); | ||||
98 | preamble->write("\n", 1); | ||||
99 | preamble->flush(); | ||||
100 | | ||||
95 | // start the debugger | 101 | // start the debugger | ||
96 | QString str = m_debugger.command(); | 102 | QString str = m_debugger.command(); | ||
97 | Debugger::expandString(str, Debugger::ExpansionUsageShell, m_temp->fileName()); | 103 | Debugger::expandString(str, Debugger::ExpansionUsageShell, m_temp->fileName(), preamble->fileName()); | ||
98 | 104 | | |||
99 | *m_proc << KShell::splitArgs(str); | 105 | *m_proc << KShell::splitArgs(str); | ||
100 | m_proc->setOutputChannelMode(KProcess::OnlyStdoutChannel); | 106 | m_proc->setOutputChannelMode(KProcess::OnlyStdoutChannel); | ||
101 | m_proc->setNextOpenMode(QIODevice::ReadWrite | QIODevice::Text); | 107 | m_proc->setNextOpenMode(QIODevice::ReadWrite | QIODevice::Text); | ||
102 | // check if the debugger should take its input from a file we'll generate, | 108 | // check if the debugger should take its input from a file we'll generate, | ||
103 | // and take the appropriate steps if so | 109 | // and take the appropriate steps if so | ||
104 | QString stdinFile = m_debugger.backendValueOfParameter(QStringLiteral("ExecInputFile")); | 110 | QString stdinFile = m_debugger.backendValueOfParameter(QStringLiteral("ExecInputFile")); | ||
105 | Debugger::expandString(stdinFile, Debugger::ExpansionUsageShell, m_temp->fileName()); | 111 | Debugger::expandString(stdinFile, Debugger::ExpansionUsageShell, m_temp->fileName(), preamble->fileName()); | ||
106 | if (!stdinFile.isEmpty() && QFile::exists(stdinFile)) { | 112 | if (!stdinFile.isEmpty() && QFile::exists(stdinFile)) { | ||
107 | m_proc->setStandardInputFile(stdinFile); | 113 | m_proc->setStandardInputFile(stdinFile); | ||
108 | } | 114 | } | ||
109 | connect(m_proc, &KProcess::readyReadStandardOutput, this, &BacktraceGenerator::slotReadInput); | 115 | connect(m_proc, &KProcess::readyReadStandardOutput, this, &BacktraceGenerator::slotReadInput); | ||
110 | connect(m_proc, static_cast<void (KProcess::*)(int, QProcess::ExitStatus)>(&KProcess::finished), this, &BacktraceGenerator::slotProcessExited); | 116 | connect(m_proc, static_cast<void (KProcess::*)(int, QProcess::ExitStatus)>(&KProcess::finished), this, &BacktraceGenerator::slotProcessExited); | ||
111 | 117 | | |||
112 | m_proc->start(); | 118 | m_proc->start(); | ||
113 | if (!m_proc->waitForStarted()) { | 119 | if (!m_proc->waitForStarted()) { | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 181 | if (exitStatus != QProcess::NormalExit || exitCode != 0) { | |||
177 | emit someError(); | 183 | emit someError(); | ||
178 | return; | 184 | return; | ||
179 | } | 185 | } | ||
180 | 186 | | |||
181 | //no translation, string appears in the report | 187 | //no translation, string appears in the report | ||
182 | QString tmp(QStringLiteral("Application: %progname (%execname), signal: %signame\n")); | 188 | QString tmp(QStringLiteral("Application: %progname (%execname), signal: %signame\n")); | ||
183 | Debugger::expandString(tmp); | 189 | Debugger::expandString(tmp); | ||
184 | 190 | | |||
185 | m_parsedBacktrace = tmp + m_parser->parsedBacktrace(); | 191 | m_parsedBacktrace = tmp + m_parser->informationLines() + m_parser->parsedBacktrace(); | ||
186 | m_state = Loaded; | 192 | m_state = Loaded; | ||
187 | 193 | | |||
188 | #ifdef BACKTRACE_PARSER_DEBUG | 194 | #ifdef BACKTRACE_PARSER_DEBUG | ||
189 | //append the raw unparsed backtrace | 195 | //append the raw unparsed backtrace | ||
190 | m_parsedBacktrace += "\n------------ Unparsed Backtrace ------------\n"; | 196 | m_parsedBacktrace += "\n------------ Unparsed Backtrace ------------\n"; | ||
191 | m_parsedBacktrace += m_debugParser->parsedBacktrace(); //it's not really parsed, it's from the null parser. | 197 | m_parsedBacktrace += m_debugParser->parsedBacktrace(); //it's not really parsed, it's from the null parser. | ||
192 | #endif | 198 | #endif | ||
193 | 199 | | |||
194 | emit done(); | 200 | emit done(); | ||
195 | } | 201 | } | ||
196 | 202 | | |||
197 | 203 | |
This is leaking the file, is it not? It never deletes this object.