Commit d16aed43 authored by hjk's avatar hjk

Debugger: Add display of mixed disassembler output for LLDB

Change-Id: I4997ce4fb4ce6a61cca67e36abb84c61a1c120f5
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 47c79a10
......@@ -1719,18 +1719,43 @@ class Dumper(DumperBase):
addr = lldb.SBAddress(base, self.target)
instructions = self.target.ReadInstructions(addr, 100)
currentFile = None
currentLine = None
hunks = dict()
sources = dict()
result = 'disassembly={cookie="%s",' % args['cookie']
result += ',lines=['
for insn in instructions:
comment = insn.GetComment(self.target)
addr = insn.GetAddress().GetLoadAddress(self.target)
result += '{address="%s"' % addr
addr = insn.GetAddress()
loadAddr = addr.GetLoadAddress(self.target)
lineEntry = addr.GetLineEntry()
if lineEntry:
lineNumber = lineEntry.GetLine()
fileName = str(lineEntry.GetFileSpec())
if lineNumber != currentLine or fileName != currentFile:
currentLine = lineNumber
currentFile = fileName
key = "%s:%s" % (fileName, lineNumber)
hunk = hunks.get(key, 0) + 1
hunks[key] = hunk
source = sources.get(fileName, None)
if source is None:
with open(fileName, 'r') as f:
source = f.read().splitlines()
sources[fileName] = source
result += '{line="%s"' % lineNumber
result += ',file="%s"' % fileName
if 0 < lineNumber and lineNumber <= len(source):
result += ',inst="%s"' % source[lineNumber - 1]
result += ',hunk="%s"}' % hunk
result += '{address="%s"' % loadAddr
result += ',inst="%s %s"' % (insn.GetMnemonic(self.target),
insn.GetOperands(self.target))
result += ',func_name="%s"' % functionName
if comment:
result += ',comment="%s"' % comment
result += ',offset="%s"},' % (addr - base)
result += ',offset="%s"}' % (loadAddr - base)
self.report(result + ']')
def loadDumpers(self, args):
......
......@@ -56,6 +56,7 @@ public:
public:
quint64 address; // (ass) Address of instruction in memory/in binary.
QString function; // (ass) Function to which current instruction belongs.
QString fileName; // (src) Source file
uint offset; // (ass) Offset of instruction in relation to current function.
uint lineNumber; // (src) Line number in source.
uint hunk; // (src) Number of hunk if source line was split
......
......@@ -707,6 +707,10 @@ void LldbEngine::refreshDisassembly(const GdbMi &data)
dl.data = line["inst"].toUtf8();
dl.function = line["func-name"].toUtf8();
dl.offset = line["offset"].toInt();
dl.lineNumber = line["line"].toInt();
dl.fileName = line["file"].toUtf8();
dl.function = line["function"].toUtf8();
dl.hunk = line["hunk"].toInt();
QByteArray comment = line["comment"].data();
if (!comment.isEmpty())
dl.data += QString::fromUtf8(" # " + comment);
......
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