forked from qt-creator/qt-creator
Debugger: Add display of mixed disassembler output for LLDB
Change-Id: I4997ce4fb4ce6a61cca67e36abb84c61a1c120f5 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -1719,18 +1719,43 @@ class Dumper(DumperBase):
|
|||||||
addr = lldb.SBAddress(base, self.target)
|
addr = lldb.SBAddress(base, self.target)
|
||||||
instructions = self.target.ReadInstructions(addr, 100)
|
instructions = self.target.ReadInstructions(addr, 100)
|
||||||
|
|
||||||
|
currentFile = None
|
||||||
|
currentLine = None
|
||||||
|
hunks = dict()
|
||||||
|
sources = dict()
|
||||||
result = 'disassembly={cookie="%s",' % args['cookie']
|
result = 'disassembly={cookie="%s",' % args['cookie']
|
||||||
result += ',lines=['
|
result += ',lines=['
|
||||||
for insn in instructions:
|
for insn in instructions:
|
||||||
comment = insn.GetComment(self.target)
|
comment = insn.GetComment(self.target)
|
||||||
addr = insn.GetAddress().GetLoadAddress(self.target)
|
addr = insn.GetAddress()
|
||||||
result += '{address="%s"' % addr
|
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),
|
result += ',inst="%s %s"' % (insn.GetMnemonic(self.target),
|
||||||
insn.GetOperands(self.target))
|
insn.GetOperands(self.target))
|
||||||
result += ',func_name="%s"' % functionName
|
result += ',func_name="%s"' % functionName
|
||||||
if comment:
|
if comment:
|
||||||
result += ',comment="%s"' % comment
|
result += ',comment="%s"' % comment
|
||||||
result += ',offset="%s"},' % (addr - base)
|
result += ',offset="%s"}' % (loadAddr - base)
|
||||||
self.report(result + ']')
|
self.report(result + ']')
|
||||||
|
|
||||||
def loadDumpers(self, args):
|
def loadDumpers(self, args):
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
quint64 address; // (ass) Address of instruction in memory/in binary.
|
quint64 address; // (ass) Address of instruction in memory/in binary.
|
||||||
QString function; // (ass) Function to which current instruction belongs.
|
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 offset; // (ass) Offset of instruction in relation to current function.
|
||||||
uint lineNumber; // (src) Line number in source.
|
uint lineNumber; // (src) Line number in source.
|
||||||
uint hunk; // (src) Number of hunk if source line was split
|
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.data = line["inst"].toUtf8();
|
||||||
dl.function = line["func-name"].toUtf8();
|
dl.function = line["func-name"].toUtf8();
|
||||||
dl.offset = line["offset"].toInt();
|
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();
|
QByteArray comment = line["comment"].data();
|
||||||
if (!comment.isEmpty())
|
if (!comment.isEmpty())
|
||||||
dl.data += QString::fromUtf8(" # " + comment);
|
dl.data += QString::fromUtf8(" # " + comment);
|
||||||
|
|||||||
Reference in New Issue
Block a user