Commit 78b1b042 authored by hjk's avatar hjk Committed by hjk

debugger: replace artificial "{console,log}streamoutput" member in GdbMi

Use proper QByteArray member in GdbResponse instead. Less magic, and
does not break array-style reponses where all children are assumed to
be of the same "type".

Change-Id: Ief1efdeb0412f59836e1b2d6f4cb751ddef3216e
Reviewed-on: http://codereview.qt.nokia.com/1184Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent 1070da91
......@@ -120,7 +120,7 @@ void AbstractPlainGdbAdapter::handleInfoTarget(const GdbResponse &response)
// [some leading stdout here]
// >&" Entry point: 0x80831f0 0x08048134 - 0x08048147 is .interp\n"
// [some trailing stdout here]
QString msg = _(response.data.findChild("consolestreamoutput").data());
QString msg = _(response.consoleStreamOutput);
QRegExp needle(_("\\bEntry point: 0x([0-9a-f]+)\\b"));
if (needle.indexIn(msg) != -1) {
m_engine->m_entryPoint =
......
......@@ -676,8 +676,7 @@ static bool isAccessSpecifier(const QByteArray &ba)
// reads a MI-encoded item frome the consolestream
static bool parseConsoleStream(const GdbResponse &response, GdbMi *contents)
{
GdbMi output = response.data.findChild("consolestreamoutput");
QByteArray out = output.data();
QByteArray out = response.consoleStreamOutput;
int markerPos = out.indexOf('"') + 1; // position of 'success marker'
if (markerPos == 0 || out.at(markerPos) == 'f') { // 't' or 'f'
......@@ -1016,7 +1015,7 @@ void GdbEngine::handleDebuggingHelperValue3Classic(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
WatchData data = response.cookie.value<WatchData>();
QByteArray out = response.data.findChild("consolestreamoutput").data();
QByteArray out = response.consoleStreamOutput;
while (out.endsWith(' ') || out.endsWith('\n'))
out.chop(1);
QList<QByteArray> list = out.split(' ');
......
......@@ -124,16 +124,16 @@ void CoreGdbAdapter::handleTemporaryTargetCore(const GdbResponse &response)
return;
}
GdbMi console = response.data.findChild("consolestreamoutput");
int pos1 = console.data().indexOf('`');
int pos2 = console.data().indexOf('\'');
QByteArray console = response.consoleStreamOutput;
int pos1 = console.indexOf('`');
int pos2 = console.indexOf('\'');
if (pos1 == -1 || pos2 == -1) {
showMessage(tr("Attach to core failed."), StatusBar);
m_engine->notifyEngineSetupFailed();
return;
}
m_executable = console.data().mid(pos1 + 1, pos2 - pos1 - 1);
m_executable = console.mid(pos1 + 1, pos2 - pos1 - 1);
// Strip off command line arguments. FIXME: make robust.
int idx = m_executable.indexOf(_c(' '));
if (idx >= 0)
......
......@@ -171,8 +171,7 @@ static int &currentToken()
static QByteArray parsePlainConsoleStream(const GdbResponse &response)
{
GdbMi output = response.data.findChild("consolestreamoutput");
QByteArray out = output.data();
QByteArray out = response.consoleStreamOutput;
// FIXME: proper decoding needed
if (out.endsWith("\\n"))
out.chop(2);
......@@ -653,10 +652,8 @@ void GdbEngine::handleResponse(const QByteArray &buff)
//qDebug() << "\nLOG STREAM:" + m_pendingLogStreamOutput;
//qDebug() << "\nCONSOLE STREAM:" + m_pendingConsoleStreamOutput;
response.data.setStreamOutput("logstreamoutput",
m_pendingLogStreamOutput);
response.data.setStreamOutput("consolestreamoutput",
m_pendingConsoleStreamOutput);
response.logStreamOutput = m_pendingLogStreamOutput;
response.consoleStreamOutput = m_pendingConsoleStreamOutput;
m_pendingLogStreamOutput.clear();
m_pendingConsoleStreamOutput.clear();
......@@ -1688,7 +1685,7 @@ void GdbEngine::handleInfoProc(const GdbResponse &response)
if (response.resultClass == GdbResultDone) {
static QRegExp re(_("\\bprocess ([0-9]+)\n"));
QTC_ASSERT(re.isValid(), return);
if (re.indexIn(_(response.data.findChild("consolestreamoutput").data())) != -1)
if (re.indexIn(_(response.consoleStreamOutput)) != -1)
maybeHandleInferiorPidChanged(re.cap(1));
}
}
......@@ -1700,8 +1697,7 @@ void GdbEngine::handleShowVersion(const GdbResponse &response)
m_gdbVersion = 100;
m_gdbBuildVersion = -1;
m_isMacGdb = false;
GdbMi version = response.data.findChild("consolestreamoutput");
QString msg = QString::fromLocal8Bit(version.data());
QString msg = QString::fromLocal8Bit(response.consoleStreamOutput);
extractGdbVersion(msg,
&m_gdbVersion, &m_gdbBuildVersion, &m_isMacGdb);
if (m_gdbVersion > 60500 && m_gdbVersion < 200000)
......@@ -1726,9 +1722,8 @@ void GdbEngine::handleHasPython(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
m_hasPython = true;
GdbMi contents = response.data.findChild("consolestreamoutput");
GdbMi data;
data.fromStringMultiple(contents.data());
data.fromStringMultiple(response.consoleStreamOutput);
const GdbMi dumpers = data.findChild("dumpers");
foreach (const GdbMi &dumper, dumpers.children()) {
QByteArray type = dumper.findChild("type").data();
......@@ -2442,7 +2437,7 @@ void GdbEngine::handleWatchInsert(const GdbResponse &response)
BreakHandler *handler = breakHandler();
BreakpointResponse br = handler->response(id);
// "Hardware watchpoint 2: *0xbfffed40\n"
QByteArray ba = response.data.findChild("consolestreamoutput").data();
QByteArray ba = response.consoleStreamOutput;
GdbMi wpt = response.data.findChild("wpt");
if (wpt.isValid()) {
// Mac yields:
......@@ -2517,6 +2512,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response)
foreach (const GdbMi bkpt, response.data.children()) {
nr = bkpt.findChild("number").data();
rid = BreakpointResponseId(nr);
QTC_ASSERT(rid.isValid(), continue);
if (nr.contains('.')) {
// A sub-breakpoint.
BreakpointResponse sub;
......@@ -2664,8 +2660,7 @@ void GdbEngine::handleBreakListMultiple(const GdbResponse &response)
{
QTC_ASSERT(response.resultClass == GdbResultDone, /**/)
const BreakpointModelId id = response.cookie.value<BreakpointModelId>();
const QString str = QString::fromLocal8Bit(
response.data.findChild("consolestreamoutput").data());
const QString str = QString::fromLocal8Bit(response.consoleStreamOutput);
extractDataFromInfoBreak(str, id);
}
......@@ -2720,7 +2715,7 @@ void GdbEngine::handleBreakIgnore(const GdbResponse &response)
//
// gdb 6.3 does not produce any console output
QTC_ASSERT(response.resultClass == GdbResultDone, /**/)
QString msg = _(response.data.findChild("consolestreamoutput").data());
//QString msg = _(response.consoleStreamOutput);
BreakpointModelId id = response.cookie.value<BreakpointModelId>();
BreakHandler *handler = breakHandler();
BreakpointResponse br = handler->response(id);
......@@ -2890,7 +2885,7 @@ void GdbEngine::handleInfoLine(const GdbResponse &response)
// Old-style output: "Line 1102 of \"simple/app.cpp\" starts
// at address 0x80526aa <_Z10...+131> and ends at 0x80526b5
// <_Z10testQStackv+142>.\n"
QByteArray ba = response.data.findChild("consolestreamoutput").data();
QByteArray ba = response.consoleStreamOutput;
const BreakpointModelId id = response.cookie.value<BreakpointModelId>();
const int pos = ba.indexOf(' ', 5);
if (ba.startsWith("Line ") && pos != -1) {
......@@ -3214,8 +3209,7 @@ void GdbEngine::handleModulesList(const GdbResponse &response)
if (response.resultClass == GdbResultDone) {
// That's console-based output, likely Linux or Windows,
// but we can avoid the target dependency here.
QString data = QString::fromLocal8Bit(
response.data.findChild("consolestreamoutput").data());
QString data = QString::fromLocal8Bit(response.consoleStreamOutput);
QTextStream ts(&data, QIODevice::ReadOnly);
while (!ts.atEnd()) {
QString line = ts.readLine();
......@@ -3391,7 +3385,7 @@ void GdbEngine::handleStackListFrames(const GdbResponse &response)
if (!handleIt) {
// That always happens on symbian gdb with
// ^error,data={msg="Previous frame identical to this frame (corrupt stack?)"
// logstreamoutput="Previous frame identical to this frame (corrupt stack?)\n"
// logStreamOutput: "Previous frame identical to this frame (corrupt stack?)\n"
//qDebug() << "LISTING STACK FAILED: " << response.toString();
reloadRegisters();
return;
......@@ -3517,9 +3511,8 @@ void GdbEngine::handleThreadListIds(const GdbResponse &response)
void GdbEngine::handleThreadNames(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
GdbMi contents = response.data.findChild("consolestreamoutput");
GdbMi names;
names.fromString(contents.data());
names.fromString(response.consoleStreamOutput);
Threads threads = threadsHandler()->threads();
......@@ -4419,28 +4412,26 @@ DisassemblerLines GdbEngine::parseMiDisassembler(const GdbMi &lines)
return result;
}
DisassemblerLines GdbEngine::parseCliDisassembler(const GdbMi &output)
DisassemblerLines GdbEngine::parseCliDisassembler(const QByteArray &output)
{
const QString someSpace = _(" ");
// First line is something like
// "Dump of assembler code from 0xb7ff598f to 0xb7ff5a07:"
DisassemblerLines dlines;
foreach (const QByteArray &line, output.data().split('\n'))
foreach (const QByteArray &line, output.split('\n'))
dlines.appendUnparsed(_(line));
return dlines;
}
DisassemblerLines GdbEngine::parseDisassembler(const GdbMi &data)
DisassemblerLines GdbEngine::parseDisassembler(const GdbResponse &response)
{
// Apple's gdb produces MI output even for CLI commands.
// FIXME: Check whether wrapping this into -interpreter-exec console
// (i.e. usgind the 'ConsoleCommand' GdbCommandFlag makes a
// difference.
GdbMi lines = data.findChild("asm_insns");
GdbMi lines = response.data.findChild("asm_insns");
if (lines.isValid())
return parseMiDisassembler(lines);
GdbMi output = data.findChild("consolestreamoutput");
return parseCliDisassembler(output);
return parseCliDisassembler(response.consoleStreamOutput);
}
void GdbEngine::handleDisassemblerCheck(const GdbResponse &response)
......@@ -4454,7 +4445,7 @@ void GdbEngine::handleFetchDisassemblerByCliPointMixed(const GdbResponse &respon
QTC_ASSERT(ac.agent, return);
if (response.resultClass == GdbResultDone) {
DisassemblerLines dlines = parseDisassembler(response.data);
DisassemblerLines dlines = parseDisassembler(response);
if (dlines.coversAddress(ac.agent->address())) {
ac.agent->setContents(dlines);
return;
......@@ -4469,7 +4460,7 @@ void GdbEngine::handleFetchDisassemblerByCliPointPlain(const GdbResponse &respon
QTC_ASSERT(ac.agent, return);
if (response.resultClass == GdbResultDone) {
DisassemblerLines dlines = parseDisassembler(response.data);
DisassemblerLines dlines = parseDisassembler(response);
if (dlines.coversAddress(ac.agent->address())) {
ac.agent->setContents(dlines);
return;
......@@ -4487,7 +4478,7 @@ void GdbEngine::handleFetchDisassemblerByCliRangeMixed(const GdbResponse &respon
QTC_ASSERT(ac.agent, return);
if (response.resultClass == GdbResultDone) {
DisassemblerLines dlines = parseDisassembler(response.data);
DisassemblerLines dlines = parseDisassembler(response);
if (dlines.coversAddress(ac.agent->address())) {
ac.agent->setContents(dlines);
return;
......@@ -4502,7 +4493,7 @@ void GdbEngine::handleFetchDisassemblerByCliRangePlain(const GdbResponse &respon
QTC_ASSERT(ac.agent, return);
if (response.resultClass == GdbResultDone) {
DisassemblerLines dlines = parseDisassembler(response.data);
DisassemblerLines dlines = parseDisassembler(response);
if (dlines.size()) {
ac.agent->setContents(dlines);
return;
......@@ -5005,8 +4996,7 @@ void GdbEngine::handleCreateFullBacktrace(const GdbResponse &response)
{
if (response.resultClass == GdbResultDone) {
debuggerCore()->openTextEditor(_("Backtrace $"),
_(response.data.findChild("consolestreamoutput").data()
+ response.data.findChild("logstreamoutput").data()));
_(response.consoleStreamOutput + response.logStreamOutput));
}
}
......@@ -5053,8 +5043,8 @@ void GdbEngine::handleSetQmlStepBreakpoint(const GdbResponse &response)
{
//QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
if (response.resultClass == GdbResultDone) {
// "{logstreamoutput="tbreak 'myns::QScript::FunctionWrapper::proxyCall'\n"
//,consolestreamoutput="Temporary breakpoint 1 at 0xf166e7:
// logStreamOutput: "tbreak 'myns::QScript::FunctionWrapper::proxyCall'\n"
// consoleStreamOutput: "Temporary breakpoint 1 at 0xf166e7:
// file bridge/qscriptfunction.cpp, line 75.\n"}
QByteArray ba = parsePlainConsoleStream(response);
const int pos2 = ba.indexOf(" at 0x");
......
......@@ -568,9 +568,9 @@ private: ////////// View & Data Stuff //////////
//void handleFetchDisassemblerByMiRangePlain(const GdbResponse &response);
void handleDisassemblerCheck(const GdbResponse &response);
void handleBreakOnQFatal(const GdbResponse &response);
DisassemblerLines parseDisassembler(const GdbMi &data);
DisassemblerLines parseCliDisassembler(const GdbMi &lines);
DisassemblerLines parseMiDisassembler(const GdbMi &lines);
DisassemblerLines parseDisassembler(const GdbResponse &response);
DisassemblerLines parseCliDisassembler(const QByteArray &response);
DisassemblerLines parseMiDisassembler(const GdbMi &response);
bool m_disassembleUsesComma;
......
......@@ -228,19 +228,6 @@ void GdbMi::parseList(const char *&from, const char *to)
}
}
void GdbMi::setStreamOutput(const QByteArray &name, const QByteArray &content)
{
if (content.isEmpty())
return;
GdbMi child;
child.m_type = Const;
child.m_name = name;
child.m_data = content;
m_children += child;
if (m_type == Invalid)
m_type = Tuple;
}
static QByteArray ind(int indent)
{
return QByteArray(2 * indent, ' ');
......
......@@ -130,7 +130,6 @@ public:
qulonglong toAddress() const;
void fromString(const QByteArray &str);
void fromStringMultiple(const QByteArray &str);
void setStreamOutput(const QByteArray &name, const QByteArray &content);
private:
friend class GdbResponse;
......@@ -170,6 +169,8 @@ public:
GdbResultClass resultClass;
GdbMi data;
QVariant cookie;
QByteArray logStreamOutput;
QByteArray consoleStreamOutput;
};
void extractGdbVersion(const QString &msg,
......
......@@ -135,7 +135,7 @@ void GdbEngine::handleStackFramePython(const GdbResponse &response)
PRECONDITION;
if (response.resultClass == GdbResultDone) {
const bool partial = response.cookie.toBool();
QByteArray out = response.data.findChild("consolestreamoutput").data();
QByteArray out = response.consoleStreamOutput;
while (out.endsWith(' ') || out.endsWith('\n'))
out.chop(1);
int pos = out.indexOf("data=");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment