MCPcopy Create free account
hub / github.com/KDE/kdevelop / processLine

Method processLine

plugins/debuggercommon/midebugger.cpp:149–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149void MIDebugger::processLine(const QByteArray& line)
150{
151 if (line != "(gdb) ") {
152 qCDebug(DEBUGGERCOMMON) << "Debugger output (pid =" << m_process->processId() << "): " << line;
153 }
154
155 FileSymbol file;
156 file.contents = line;
157
158 std::unique_ptr<MI::Record> r(m_parser.parse(&file));
159
160 if (!r)
161 {
162 // simply ignore the invalid MI message because both gdb and lldb
163 // sometimes produces invalid messages that can be safely ignored.
164 qCDebug(DEBUGGERCOMMON) << "Invalid MI message:" << line;
165 // We don't consider the current command done.
166 // So, if a command results in unparsable reply,
167 // we'll just wait for the "right" reply, which might
168 // never come. However, marking the command as
169 // done in this case is even more risky.
170 // It's probably possible to get here if we're debugging
171 // natively without PTY, though this is uncommon case.
172 return;
173 }
174
175 #ifndef DEBUG_NO_TRY
176 try
177 {
178 #endif
179 switch(r->kind)
180 {
181 case MI::Record::Result: {
182 auto& result = static_cast<MI::ResultRecord&>(*r);
183
184 // it's still possible for the user to issue a MI command,
185 // emit correct signal
186 if (m_currentCmd && m_currentCmd->isUserCommand()) {
187 emit userCommandOutput(QString::fromUtf8(line) + QLatin1Char('\n'));
188 } else {
189 emit internalCommandOutput(QString::fromUtf8(line) + QLatin1Char('\n'));
190 }
191
192 // protect against wild replies that sometimes returned from gdb without a pending command
193 if (!m_currentCmd)
194 {
195 qCWarning(DEBUGGERCOMMON) << "Received a result without a pending command";
196 throw std::runtime_error("Received a result without a pending command");
197 }
198 else if (m_currentCmd->token() != result.token)
199 {
200 std::stringstream ss;
201 ss << "Received a result with token not matching pending command. "
202 << "Pending: " << m_currentCmd->token() << "Received: " << result.token;
203 qCWarning(DEBUGGERCOMMON) << ss.str().c_str();
204 throw std::runtime_error(ss.str());
205 }
206

Callers

nothing calls this directly

Calls 15

isUserCommandMethod · 0.80
strMethod · 0.80
markAsCompletedMethod · 0.80
totalProcessingTimeMethod · 0.80
queueTimeMethod · 0.80
gdbProcessingTimeMethod · 0.80
isReasonErrorMethod · 0.80
newOutputMethod · 0.80
newLogStreamOutputMethod · 0.80
parseMethod · 0.45
tokenMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected