forked from qt-creator/qt-creator
Debugger[CDB]: Fix run/jump to line for assembly code.
This commit is contained in:
@@ -1124,9 +1124,15 @@ void CdbEngine::doInterruptInferior(SpecialStopMode sm)
|
|||||||
void CdbEngine::executeRunToLine(const ContextData &data)
|
void CdbEngine::executeRunToLine(const ContextData &data)
|
||||||
{
|
{
|
||||||
// Add one-shot breakpoint
|
// Add one-shot breakpoint
|
||||||
BreakpointParameters bp(BreakpointByFileAndLine);
|
BreakpointParameters bp;
|
||||||
bp.fileName = data.fileName;
|
if (data.address) {
|
||||||
bp.lineNumber = data.lineNumber;
|
bp.type =BreakpointByAddress;
|
||||||
|
bp.address = data.address;
|
||||||
|
} else {
|
||||||
|
bp.type =BreakpointByFileAndLine;
|
||||||
|
bp.fileName = data.fileName;
|
||||||
|
bp.lineNumber = data.lineNumber;
|
||||||
|
}
|
||||||
postCommand(cdbAddBreakpointCommand(bp, BreakpointId(-1), true), 0);
|
postCommand(cdbAddBreakpointCommand(bp, BreakpointId(-1), true), 0);
|
||||||
continueInferior();
|
continueInferior();
|
||||||
}
|
}
|
||||||
@@ -1155,12 +1161,31 @@ void CdbEngine::setRegisterValue(int regnr, const QString &value)
|
|||||||
|
|
||||||
void CdbEngine::executeJumpToLine(const ContextData &data)
|
void CdbEngine::executeJumpToLine(const ContextData &data)
|
||||||
{
|
{
|
||||||
QByteArray cmd;
|
if (data.address) {
|
||||||
ByteArrayInputStream str(cmd);
|
// Goto address directly.
|
||||||
// Resolve source line address and go to that location
|
jumpToAddress(data.address);
|
||||||
str << "? `" << QDir::toNativeSeparators(data.fileName) << ':' << data.lineNumber << '`';
|
gotoLocation(Location(data.address));
|
||||||
const QVariant cookie = qVariantFromValue(data);
|
} else {
|
||||||
postBuiltinCommand(cmd, 0, &CdbEngine::handleJumpToLineAddressResolution, 0, cookie);
|
// Jump to source line: Resolve source line address and go to that location
|
||||||
|
QByteArray cmd;
|
||||||
|
ByteArrayInputStream str(cmd);
|
||||||
|
str << "? `" << QDir::toNativeSeparators(data.fileName) << ':' << data.lineNumber << '`';
|
||||||
|
const QVariant cookie = qVariantFromValue(data);
|
||||||
|
postBuiltinCommand(cmd, 0, &CdbEngine::handleJumpToLineAddressResolution, 0, cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CdbEngine::jumpToAddress(quint64 address)
|
||||||
|
{
|
||||||
|
// Fake a jump to address by setting the PC register.
|
||||||
|
QByteArray registerCmd;
|
||||||
|
ByteArrayInputStream str(registerCmd);
|
||||||
|
// PC-register depending on 64/32bit.
|
||||||
|
str << "r " << (startParameters().toolChainAbi.wordWidth() == 64 ? "rip" : "eip") << '=';
|
||||||
|
str.setHexPrefix(true);
|
||||||
|
str.setIntegerBase(16);
|
||||||
|
str << address;
|
||||||
|
postCommand(registerCmd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &cmd)
|
void CdbEngine::handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &cmd)
|
||||||
@@ -1169,20 +1194,20 @@ void CdbEngine::handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &cm
|
|||||||
return;
|
return;
|
||||||
// Evaluate expression: 5365511549 = 00000001`3fcf357d
|
// Evaluate expression: 5365511549 = 00000001`3fcf357d
|
||||||
// Set register 'rip' to hex address and goto lcoation
|
// Set register 'rip' to hex address and goto lcoation
|
||||||
QByteArray answer = cmd->reply.front();
|
QString answer = QString::fromAscii(cmd->reply.front()).trimmed();
|
||||||
const int equalPos = answer.indexOf(" = ");
|
const int equalPos = answer.indexOf(" = ");
|
||||||
if (equalPos == -1)
|
if (equalPos == -1)
|
||||||
return;
|
return;
|
||||||
answer.remove(0, equalPos + 3);
|
answer.remove(0, equalPos + 3);
|
||||||
QTC_ASSERT(qVariantCanConvert<ContextData>(cmd->cookie), return);
|
answer.remove(QLatin1Char('`'));
|
||||||
const ContextData cookie = qvariant_cast<ContextData>(cmd->cookie);
|
bool ok;
|
||||||
|
const quint64 address = answer.toLongLong(&ok, 16);
|
||||||
QByteArray registerCmd;
|
if (ok && address) {
|
||||||
ByteArrayInputStream str(registerCmd);
|
QTC_ASSERT(qVariantCanConvert<ContextData>(cmd->cookie), return);
|
||||||
// PC-register depending on 64/32bit.
|
const ContextData cookie = qvariant_cast<ContextData>(cmd->cookie);
|
||||||
str << "r " << (startParameters().toolChainAbi.wordWidth() == 64 ? "rip" : "eip") << "=0x" << answer;
|
jumpToAddress(address);
|
||||||
postCommand(registerCmd, 0);
|
gotoLocation(Location(cookie.fileName, cookie.lineNumber));
|
||||||
gotoLocation(Location(cookie.fileName, cookie.lineNumber));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::assignValueInDebugger(const WatchData *w, const QString &expr, const QVariant &value)
|
void CdbEngine::assignValueInDebugger(const WatchData *w, const QString &expr, const QVariant &value)
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ private:
|
|||||||
void handleRegisters(const CdbBuiltinCommandPtr &);
|
void handleRegisters(const CdbBuiltinCommandPtr &);
|
||||||
void handleDisassembler(const CdbBuiltinCommandPtr &);
|
void handleDisassembler(const CdbBuiltinCommandPtr &);
|
||||||
void handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &);
|
void handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &);
|
||||||
|
void jumpToAddress(quint64 address);
|
||||||
// Extension commands
|
// Extension commands
|
||||||
void handleThreads(const CdbExtensionCommandPtr &);
|
void handleThreads(const CdbExtensionCommandPtr &);
|
||||||
void handlePid(const CdbExtensionCommandPtr &reply);
|
void handlePid(const CdbExtensionCommandPtr &reply);
|
||||||
|
|||||||
Reference in New Issue
Block a user