forked from qt-creator/qt-creator
debugger: fix disassembler output handling on Mac
Apple's gdb produces MI-style output even for CLI commands when in MI mode.
This commit is contained in:
@@ -3970,41 +3970,47 @@ void GdbEngine::handleFetchDisassemblerByCli(const GdbResponse &response)
|
||||
QTC_ASSERT(ac.agent, return);
|
||||
|
||||
if (response.resultClass == GdbResultDone) {
|
||||
const QString someSpace = _(" ");
|
||||
// First line is something like
|
||||
// "Dump of assembler code from 0xb7ff598f to 0xb7ff5a07:"
|
||||
GdbMi output = response.data.findChild("consolestreamoutput");
|
||||
QStringList res;
|
||||
foreach (QByteArray line, output.data().split('\n')) {
|
||||
line = line.trimmed();
|
||||
if (line.startsWith("=> "))
|
||||
line = line.mid(3);
|
||||
if (line.startsWith("Current language:"))
|
||||
continue;
|
||||
if (line.startsWith("The current source"))
|
||||
continue;
|
||||
if (line.startsWith("0x")) {
|
||||
int pos1 = line.indexOf('<');
|
||||
int pos2 = line.indexOf('+', pos1);
|
||||
int pos3 = line.indexOf('>', pos2);
|
||||
if (pos3 >= 0) {
|
||||
QByteArray ba = " <+" + line.mid(pos2 + 1, pos3 - pos2 - 1);
|
||||
ba = line.left(pos1 - 1) + ba.rightJustified(4)
|
||||
+ ">: " + line.mid(pos3 + 2);
|
||||
res.append(_(ba));
|
||||
} else {
|
||||
res.append(_(line));
|
||||
// Apple's gdb produces MI output even for CLI commands.
|
||||
GdbMi lines = response.data.findChild("asm_insns");
|
||||
if (lines.isValid()) {
|
||||
ac.agent->setContents(parseDisassembler(lines));
|
||||
} else {
|
||||
const QString someSpace = _(" ");
|
||||
// First line is something like
|
||||
// "Dump of assembler code from 0xb7ff598f to 0xb7ff5a07:"
|
||||
GdbMi output = response.data.findChild("consolestreamoutput");
|
||||
QStringList res;
|
||||
foreach (QByteArray line, output.data().split('\n')) {
|
||||
line = line.trimmed();
|
||||
if (line.startsWith("=> "))
|
||||
line = line.mid(3);
|
||||
if (line.startsWith("Current language:"))
|
||||
continue;
|
||||
if (line.startsWith("The current source"))
|
||||
continue;
|
||||
if (line.startsWith("0x")) {
|
||||
int pos1 = line.indexOf('<');
|
||||
int pos2 = line.indexOf('+', pos1);
|
||||
int pos3 = line.indexOf('>', pos2);
|
||||
if (pos3 >= 0) {
|
||||
QByteArray ba = " <+" + line.mid(pos2 + 1, pos3 - pos2 - 1);
|
||||
ba = line.left(pos1 - 1) + ba.rightJustified(4)
|
||||
+ ">: " + line.mid(pos3 + 2);
|
||||
res.append(_(ba));
|
||||
} else {
|
||||
res.append(_(line));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
res.append(someSpace + _(line));
|
||||
}
|
||||
res.append(someSpace + _(line));
|
||||
// Drop "End of assembler dump." line.
|
||||
res.takeLast();
|
||||
if (res.size() > 1)
|
||||
ac.agent->setContents(res.join(_("\n")));
|
||||
else
|
||||
fetchDisassemblerByAddressCli(ac.agent);
|
||||
}
|
||||
// Drop "End of assembler dump." line.
|
||||
res.takeLast();
|
||||
if (res.size() > 1)
|
||||
ac.agent->setContents(res.join(_("\n")));
|
||||
else
|
||||
fetchDisassemblerByAddressCli(ac.agent);
|
||||
} else {
|
||||
QByteArray msg = response.data.findChild("msg").data();
|
||||
//76^error,msg="No function contains program counter for selected..."
|
||||
|
||||
Reference in New Issue
Block a user