GUI: speed improvements in Disassembly
This commit is contained in:
parent
5fed31b1b3
commit
cb98624fad
|
|
@ -61,7 +61,6 @@ Disassembly::Disassembly(QWidget* parent) : AbstractTableView(parent), mDisassem
|
|||
|
||||
// Slots
|
||||
connect(Bridge::getBridge(), SIGNAL(repaintGui()), this, SLOT(reloadData()));
|
||||
connect(Bridge::getBridge(), SIGNAL(updateDump()), this, SLOT(reloadData()));
|
||||
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(debugStateChangedSlot(DBGSTATE)));
|
||||
connect(this, SIGNAL(selectionChanged(dsint)), this, SLOT(selectionChangedSlot(dsint)));
|
||||
connect(Config(), SIGNAL(tokenizerConfigUpdated()), this, SLOT(tokenizerConfigUpdatedSlot()));
|
||||
|
|
@ -1375,6 +1374,9 @@ dsint Disassembly::getInstructionRVA(dsint index, dsint count)
|
|||
*/
|
||||
Instruction_t Disassembly::DisassembleAt(dsint rva)
|
||||
{
|
||||
if(mMemPage->getSize() < (duint)rva)
|
||||
return Instruction_t();
|
||||
|
||||
QByteArray wBuffer;
|
||||
duint base = mMemPage->getBase();
|
||||
duint wMaxByteCountToRead = 16 * 2;
|
||||
|
|
@ -1388,9 +1390,13 @@ Instruction_t Disassembly::DisassembleAt(dsint rva)
|
|||
wMaxByteCountToRead += mCodeFoldingManager->getFoldedSize(rvaToVa(rva), rvaToVa(rva + wMaxByteCountToRead));
|
||||
|
||||
wMaxByteCountToRead = wMaxByteCountToRead > (size - rva) ? (size - rva) : wMaxByteCountToRead;
|
||||
if(!wMaxByteCountToRead)
|
||||
return Instruction_t();
|
||||
|
||||
wBuffer.resize(wMaxByteCountToRead);
|
||||
|
||||
mMemPage->read(wBuffer.data(), rva, wBuffer.size());
|
||||
if(!mMemPage->read(wBuffer.data(), rva, wBuffer.size()))
|
||||
return Instruction_t();
|
||||
|
||||
return mDisasm->DisassembleAt((byte_t*)wBuffer.data(), wBuffer.size(), base, rva);
|
||||
}
|
||||
|
|
@ -1577,53 +1583,48 @@ void Disassembly::prepareDataCount(const QList<dsint> & wRVAs, QList<Instruction
|
|||
}
|
||||
}
|
||||
|
||||
void Disassembly::prepareDataRange(dsint startRva, dsint endRva, QList<Instruction_t>* instBuffer)
|
||||
void Disassembly::prepareDataRange(dsint startRva, dsint endRva, const std::function<void(Instruction_t)> & disassembled)
|
||||
{
|
||||
QList<dsint> wRVAs;
|
||||
if(startRva == endRva)
|
||||
dsint wAddrPrev = startRva;
|
||||
dsint wAddr = wAddrPrev;
|
||||
|
||||
while(true)
|
||||
{
|
||||
wRVAs.append(startRva);
|
||||
prepareDataCount(wRVAs, instBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
int wCount = 0;
|
||||
dsint addr = startRva;
|
||||
while(addr <= endRva)
|
||||
{
|
||||
wRVAs.append(addr);
|
||||
addr = getNextInstructionRVA(addr, 1);
|
||||
wCount++;
|
||||
}
|
||||
prepareDataCount(wRVAs, instBuffer);
|
||||
if(wAddr >= endRva)
|
||||
break;
|
||||
wAddrPrev = wAddr;
|
||||
auto wInst = std::move(DisassembleAt(wAddr));
|
||||
wAddr += wInst.length;
|
||||
if(wAddr == wAddrPrev)
|
||||
break;
|
||||
disassembled(std::move(wInst));
|
||||
}
|
||||
}
|
||||
|
||||
void Disassembly::prepareData()
|
||||
{
|
||||
dsint wViewableRowsCount = getViewableRowsCount();
|
||||
QList<dsint> wRVAs;
|
||||
mInstBuffer.clear();
|
||||
mInstBuffer.reserve(wViewableRowsCount);
|
||||
|
||||
dsint wAddrPrev = getTableOffset();
|
||||
dsint wAddr = wAddrPrev;
|
||||
Instruction_t wInst;
|
||||
|
||||
int wCount = 0;
|
||||
|
||||
for(int wI = 0; wI < wViewableRowsCount && getRowCount() > 0; wI++)
|
||||
{
|
||||
wRVAs.append(wAddr);
|
||||
wAddrPrev = wAddr;
|
||||
wAddr = getNextInstructionRVA(wAddr, 1);
|
||||
|
||||
wInst = DisassembleAt(wAddr);
|
||||
wAddr += wInst.length;
|
||||
if(wAddr == wAddrPrev)
|
||||
break;
|
||||
|
||||
mInstBuffer.append(wInst);
|
||||
wCount++;
|
||||
}
|
||||
|
||||
setNbrOfLineToPrint(wCount);
|
||||
|
||||
prepareDataCount(wRVAs, &mInstBuffer);
|
||||
}
|
||||
|
||||
void Disassembly::reloadData()
|
||||
|
|
@ -1765,7 +1766,6 @@ void Disassembly::disassembleAt(dsint parVA, dsint parCIP, bool history, dsint n
|
|||
}
|
||||
*/
|
||||
emit disassembledAt(parVA, parCIP, history, newTableOffset);
|
||||
reloadData();
|
||||
}
|
||||
|
||||
QList<Instruction_t>* Disassembly::instructionsBuffer()
|
||||
|
|
@ -1830,7 +1830,6 @@ duint Disassembly::getSize()
|
|||
duint Disassembly::getTableOffsetRva()
|
||||
{
|
||||
return mInstBuffer.size() ? mInstBuffer.at(0).rva : 0;
|
||||
|
||||
}
|
||||
|
||||
void Disassembly::historyClear()
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public:
|
|||
|
||||
QString getAddrText(dsint cur_addr, char label[MAX_LABEL_SIZE]);
|
||||
void prepareDataCount(const QList<dsint> & wRVAs, QList<Instruction_t>* instBuffer);
|
||||
void prepareDataRange(dsint startRva, dsint endRva, QList<Instruction_t>* instBuffer);
|
||||
void prepareDataRange(dsint startRva, dsint endRva, const std::function<void(Instruction_t)> & disassembled);
|
||||
|
||||
//misc
|
||||
void setCodeFoldingManager(CodeFoldingHelper* CodeFoldingManager);
|
||||
|
|
|
|||
|
|
@ -1427,7 +1427,10 @@ void CPUDisassembly::copySelectionToFileSlot(bool copyBytes)
|
|||
void CPUDisassembly::pushSelectionInto(bool copyBytes, QTextStream & stream)
|
||||
{
|
||||
QList<Instruction_t> instBuffer;
|
||||
prepareDataRange(getSelectionStart(), getSelectionEnd(), &instBuffer);
|
||||
prepareDataRange(getSelectionStart(), getSelectionEnd(), [&instBuffer](Instruction_t inst)
|
||||
{
|
||||
instBuffer.append(std::move(inst));
|
||||
});
|
||||
|
||||
const int addressLen = getColumnWidth(0) / getCharWidth() - 1;
|
||||
const int bytesLen = getColumnWidth(1) / getCharWidth() - 1;
|
||||
|
|
@ -1503,7 +1506,10 @@ void CPUDisassembly::copyRvaSlot()
|
|||
void CPUDisassembly::copyDisassemblySlot()
|
||||
{
|
||||
QList<Instruction_t> instBuffer;
|
||||
prepareDataRange(getSelectionStart(), getSelectionEnd(), &instBuffer);
|
||||
prepareDataRange(getSelectionStart(), getSelectionEnd(), [&instBuffer](Instruction_t inst)
|
||||
{
|
||||
instBuffer.append(std::move(inst));
|
||||
});
|
||||
QString clipboard = "";
|
||||
for(int i = 0; i < instBuffer.size(); i++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue