forked from qt-creator/qt-creator
debugger: fix optical glitch for first instruction in disassembled function
Change-Id: I956e4b7b8afee843e1a282a0b8488fa9465faf06 Reviewed-on: http://codereview.qt.nokia.com/4117 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -45,7 +45,7 @@ void DisassemblerLine::fromString(const QString &unparsed)
|
|||||||
{
|
{
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
for (int i = 0; i != unparsed.size(); ++i) {
|
for (int i = 0; i != unparsed.size(); ++i) {
|
||||||
uint c = unparsed.at(i).unicode();
|
const uint c = unparsed.at(i).unicode();
|
||||||
if (c == ' ' || c == ':' || c == '\t') {
|
if (c == ' ' || c == ':' || c == '\t') {
|
||||||
pos = i;
|
pos = i;
|
||||||
break;
|
break;
|
||||||
@@ -66,8 +66,9 @@ void DisassemblerLine::fromString(const QString &unparsed)
|
|||||||
addr.chop(1);
|
addr.chop(1);
|
||||||
if (addr.startsWith(QLatin1String("0x")))
|
if (addr.startsWith(QLatin1String("0x")))
|
||||||
addr.remove(0, 2);
|
addr.remove(0, 2);
|
||||||
address = addr.toULongLong(0, 16);
|
bool ok = false;
|
||||||
if (address)
|
address = addr.toULongLong(&ok, 16);
|
||||||
|
if (ok)
|
||||||
data = unparsed.mid(pos + 1);
|
data = unparsed.mid(pos + 1);
|
||||||
else
|
else
|
||||||
data = unparsed;
|
data = unparsed;
|
||||||
@@ -112,7 +113,7 @@ void DisassemblerLines::appendLine(const DisassemblerLine &dl)
|
|||||||
m_rowCache[dl.address] = m_data.size();
|
m_rowCache[dl.address] = m_data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append source line: Cache current file
|
// Append source line: Cache current file.
|
||||||
struct SourceFileCache
|
struct SourceFileCache
|
||||||
{
|
{
|
||||||
QString fileName;
|
QString fileName;
|
||||||
@@ -126,7 +127,7 @@ void DisassemblerLines::appendSourceLine(const QString &fileName, uint lineNumbe
|
|||||||
|
|
||||||
if (fileName.isEmpty() || lineNumber == 0)
|
if (fileName.isEmpty() || lineNumber == 0)
|
||||||
return;
|
return;
|
||||||
lineNumber--; // fix 1..n range.
|
lineNumber--; // Fix 1..n range.
|
||||||
SourceFileCache *cache = sourceFileCache();
|
SourceFileCache *cache = sourceFileCache();
|
||||||
if (fileName != cache->fileName) {
|
if (fileName != cache->fileName) {
|
||||||
cache->fileName = fileName;
|
cache->fileName = fileName;
|
||||||
@@ -135,8 +136,8 @@ void DisassemblerLines::appendSourceLine(const QString &fileName, uint lineNumbe
|
|||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
QTextStream ts(&file);
|
QTextStream ts(&file);
|
||||||
cache->lines = ts.readAll().split(QLatin1Char('\n'));
|
cache->lines = ts.readAll().split(QLatin1Char('\n'));
|
||||||
} // open
|
}
|
||||||
} // different file
|
}
|
||||||
if (lineNumber >= uint(cache->lines.size()))
|
if (lineNumber >= uint(cache->lines.size()))
|
||||||
return;
|
return;
|
||||||
DisassemblerLine dl;
|
DisassemblerLine dl;
|
||||||
@@ -177,7 +178,6 @@ void DisassemblerLines::appendUnparsed(const QString &unparsed)
|
|||||||
m_data.append(dl);
|
m_data.append(dl);
|
||||||
m_lastFunction = function;
|
m_lastFunction = function;
|
||||||
}
|
}
|
||||||
//line.replace(pos1, pos2 - pos1, "");
|
|
||||||
}
|
}
|
||||||
DisassemblerLine dl;
|
DisassemblerLine dl;
|
||||||
dl.address = line.left(pos1 - 1).toULongLong(0, 0);
|
dl.address = line.left(pos1 - 1).toULongLong(0, 0);
|
||||||
@@ -200,9 +200,8 @@ QString DisassemblerLine::toString() const
|
|||||||
QString str;
|
QString str;
|
||||||
if (isAssembler()) {
|
if (isAssembler()) {
|
||||||
if (address)
|
if (address)
|
||||||
str += _("0x%1 ").arg(address, 0, 16);
|
str += _("0x%1 <+0x%1> ").arg(offset, 4, 16, QLatin1Char('0'))
|
||||||
if (offset)
|
.arg(address, 0, 16);
|
||||||
str += _("<+0x%1> ").arg(offset, 4, 16, QLatin1Char('0'));
|
|
||||||
str += _(" ");
|
str += _(" ");
|
||||||
str += data;
|
str += data;
|
||||||
} else if (isCode()) {
|
} else if (isCode()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user