mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 11:56:12 +00:00
Fix emulation not working after a debugging session
This commit is contained in:
parent
f627b1306b
commit
721870ac0e
@ -1123,6 +1123,7 @@ void CutterCore::startDebug()
|
|||||||
if (!currentlyDebugging) {
|
if (!currentlyDebugging) {
|
||||||
offsetPriorDebugging = getOffset();
|
offsetPriorDebugging = getOffset();
|
||||||
}
|
}
|
||||||
|
currentlyOpenFile = getConfig("file.path");
|
||||||
cmd("ood");
|
cmd("ood");
|
||||||
emit registersChanged();
|
emit registersChanged();
|
||||||
if (!currentlyDebugging) {
|
if (!currentlyDebugging) {
|
||||||
@ -1141,8 +1142,7 @@ void CutterCore::startEmulation()
|
|||||||
offsetPriorDebugging = getOffset();
|
offsetPriorDebugging = getOffset();
|
||||||
}
|
}
|
||||||
// clear registers, init esil state, stack, progcounter at current seek
|
// clear registers, init esil state, stack, progcounter at current seek
|
||||||
cmd("ar0; aei; aeim; aeip");
|
cmd("aei; aeim; aeip");
|
||||||
emit registersChanged();
|
|
||||||
if (!currentlyDebugging || !currentlyEmulating) {
|
if (!currentlyDebugging || !currentlyEmulating) {
|
||||||
// prevent register flags from appearing during debug/emul
|
// prevent register flags from appearing during debug/emul
|
||||||
setConfig("asm.flags", false);
|
setConfig("asm.flags", false);
|
||||||
@ -1153,6 +1153,7 @@ void CutterCore::startEmulation()
|
|||||||
emit changeDebugView();
|
emit changeDebugView();
|
||||||
emit flagsChanged();
|
emit flagsChanged();
|
||||||
}
|
}
|
||||||
|
emit registersChanged();
|
||||||
emit stackChanged();
|
emit stackChanged();
|
||||||
emit refreshCodeViews();
|
emit refreshCodeViews();
|
||||||
}
|
}
|
||||||
@ -1188,7 +1189,16 @@ void CutterCore::stopDebug()
|
|||||||
cmd(QString("dp- %1; o %2; .ar-").arg(QString::number(currentlyAttachedToPID), currentlyOpenFile));
|
cmd(QString("dp- %1; o %2; .ar-").arg(QString::number(currentlyAttachedToPID), currentlyOpenFile));
|
||||||
currentlyAttachedToPID = -1;
|
currentlyAttachedToPID = -1;
|
||||||
} else {
|
} else {
|
||||||
cmd("dk 9; oo; .ar-");
|
cmd(QString("dk 9; e cfg.debug=false; o %1; .ar-").arg(currentlyOpenFile));
|
||||||
|
// close ptrace file descriptors left open
|
||||||
|
QJsonArray openFilesArray = cmdj("oj").array();;
|
||||||
|
for (QJsonValue value : openFilesArray) {
|
||||||
|
QJsonObject openFile = value.toObject();
|
||||||
|
QString URI = openFile["uri"].toString();
|
||||||
|
if (URI.contains("ptrace")) {
|
||||||
|
cmd("o-" + QString::number(openFile["fd"].toInt()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
seekAndShow(offsetPriorDebugging);
|
seekAndShow(offsetPriorDebugging);
|
||||||
setConfig("asm.flags", true);
|
setConfig("asm.flags", true);
|
||||||
@ -1199,6 +1209,13 @@ void CutterCore::stopDebug()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CutterCore::syncAndSeekProgramCounter()
|
||||||
|
{
|
||||||
|
QString programCounterValue = cmd("dr?`drn PC`").trimmed();
|
||||||
|
seekAndShow(programCounterValue);
|
||||||
|
emit registersChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void CutterCore::continueDebug()
|
void CutterCore::continueDebug()
|
||||||
{
|
{
|
||||||
if (currentlyDebugging) {
|
if (currentlyDebugging) {
|
||||||
@ -1221,6 +1238,7 @@ void CutterCore::continueUntilDebug(QString offset)
|
|||||||
cmd("dcu " + offset);
|
cmd("dcu " + offset);
|
||||||
}
|
}
|
||||||
emit registersChanged();
|
emit registersChanged();
|
||||||
|
emit stackChanged();
|
||||||
emit refreshCodeViews();
|
emit refreshCodeViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1233,9 +1251,7 @@ void CutterCore::continueUntilCall()
|
|||||||
} else {
|
} else {
|
||||||
cmd("dcc");
|
cmd("dcc");
|
||||||
}
|
}
|
||||||
QString programCounterValue = cmd("dr?`drn PC`").trimmed();
|
syncAndSeekProgramCounter();
|
||||||
seekAndShow(programCounterValue);
|
|
||||||
emit registersChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1247,29 +1263,31 @@ void CutterCore::continueUntilSyscall()
|
|||||||
} else {
|
} else {
|
||||||
cmd("dcs");
|
cmd("dcs");
|
||||||
}
|
}
|
||||||
QString programCounterValue = cmd("dr?`drn PC`").trimmed();
|
syncAndSeekProgramCounter();
|
||||||
seekAndShow(programCounterValue);
|
|
||||||
emit registersChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::stepDebug()
|
void CutterCore::stepDebug()
|
||||||
{
|
{
|
||||||
if (currentlyDebugging) {
|
if (currentlyDebugging) {
|
||||||
cmdEsil("ds");
|
if (currentlyEmulating) {
|
||||||
QString programCounterValue = cmd("dr?`drn PC`").trimmed();
|
cmdEsil("aes");
|
||||||
seekAndShow(programCounterValue);
|
} else {
|
||||||
emit registersChanged();
|
cmd("ds");
|
||||||
|
}
|
||||||
|
syncAndSeekProgramCounter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::stepOverDebug()
|
void CutterCore::stepOverDebug()
|
||||||
{
|
{
|
||||||
if (currentlyDebugging) {
|
if (currentlyDebugging) {
|
||||||
cmdEsil("dso");
|
if (currentlyEmulating) {
|
||||||
QString programCounterValue = cmd("dr?`drn PC`").trimmed();
|
cmdEsil("aeso");
|
||||||
seekAndShow(programCounterValue);
|
} else {
|
||||||
emit registersChanged();
|
cmd("dso");
|
||||||
|
}
|
||||||
|
syncAndSeekProgramCounter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1277,9 +1295,7 @@ void CutterCore::stepOutDebug()
|
|||||||
{
|
{
|
||||||
if (currentlyDebugging) {
|
if (currentlyDebugging) {
|
||||||
cmd("dsf");
|
cmd("dsf");
|
||||||
QString programCounterValue = cmd("dr?`drn PC`").trimmed();
|
syncAndSeekProgramCounter();
|
||||||
seekAndShow(programCounterValue);
|
|
||||||
emit registersChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +227,7 @@ public:
|
|||||||
void startEmulation();
|
void startEmulation();
|
||||||
void attachDebug(int pid);
|
void attachDebug(int pid);
|
||||||
void stopDebug();
|
void stopDebug();
|
||||||
|
void syncAndSeekProgramCounter();
|
||||||
void continueDebug();
|
void continueDebug();
|
||||||
void continueUntilCall();
|
void continueUntilCall();
|
||||||
void continueUntilSyscall();
|
void continueUntilSyscall();
|
||||||
|
@ -139,6 +139,9 @@ void MemoryMapWidget::refreshMemoryMap()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Core()->currentlyEmulating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
memoryModel->beginResetModel();
|
memoryModel->beginResetModel();
|
||||||
memoryMaps = Core()->getMemoryMap();
|
memoryMaps = Core()->getMemoryMap();
|
||||||
memoryModel->endResetModel();
|
memoryModel->endResetModel();
|
||||||
|
Loading…
Reference in New Issue
Block a user