mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Crash: Lookup block numbers more efficiently.
We only care about the first one in these places anyway. Also make sure we don't try to match an invalid block number.
This commit is contained in:
parent
c1c8a70401
commit
b9fe48f42d
@ -427,12 +427,20 @@ bool Arm64Jit::DescribeCodePtr(const u8 *ptr, std::string &name) {
|
||||
name = "loadStaticRegisters";
|
||||
else {
|
||||
u32 addr = blocks.GetAddressFromBlockPtr(ptr);
|
||||
std::vector<int> numbers;
|
||||
blocks.GetBlockNumbersFromAddress(addr, &numbers);
|
||||
if (!numbers.empty()) {
|
||||
const JitBlock *block = blocks.GetBlock(numbers[0]);
|
||||
// Returns 0 when it's valid, but unknown.
|
||||
if (addr == 0) {
|
||||
name = "(unknown or deleted block)";
|
||||
return true;
|
||||
} else if (addr != (u32)-1) {
|
||||
name = "(outside space)";
|
||||
return true;
|
||||
}
|
||||
|
||||
int number = blocks.GetBlockNumberFromAddress(addr);
|
||||
if (number != -1) {
|
||||
const JitBlock *block = blocks.GetBlock(number);
|
||||
if (block) {
|
||||
name = StringFromFormat("(block %d at %08x)", numbers[0], block->originalAddress);
|
||||
name = StringFromFormat("(block %d at %08x)", number, block->originalAddress);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -375,6 +375,15 @@ void JitBlockCache::GetBlockNumbersFromAddress(u32 em_address, std::vector<int>
|
||||
block_numbers->push_back(i);
|
||||
}
|
||||
|
||||
int JitBlockCache::GetBlockNumberFromAddress(u32 em_address) {
|
||||
for (int i = 0; i < num_blocks_; i++) {
|
||||
if (blocks_[i].ContainsAddress(em_address))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
u32 JitBlockCache::GetAddressFromBlockPtr(const u8 *ptr) const {
|
||||
if (!codeBlock_->IsInSpace(ptr))
|
||||
return (u32)-1;
|
||||
|
@ -143,6 +143,8 @@ public:
|
||||
// Returns a list of block numbers - only one block can start at a particular address, but they CAN overlap.
|
||||
// This one is slow so should only be used for one-shots from the debugger UI, not for anything during runtime.
|
||||
void GetBlockNumbersFromAddress(u32 em_address, std::vector<int> *block_numbers);
|
||||
// Similar to above, but only the first matching address.
|
||||
int GetBlockNumberFromAddress(u32 em_address);
|
||||
int GetBlockNumberFromEmuHackOp(MIPSOpcode inst, bool ignoreBad = false) const;
|
||||
|
||||
u32 GetAddressFromBlockPtr(const u8 *ptr) const;
|
||||
|
@ -1145,13 +1145,7 @@ UI::EventReturn JitCompareScreen::OnCurrentBlock(UI::EventParams &e) {
|
||||
JitBlockCache *blockCache = MIPSComp::jit->GetBlockCache();
|
||||
if (!blockCache)
|
||||
return UI::EVENT_DONE;
|
||||
std::vector<int> blockNum;
|
||||
blockCache->GetBlockNumbersFromAddress(currentMIPS->pc, &blockNum);
|
||||
if (blockNum.size() > 0) {
|
||||
currentBlock_ = blockNum[0];
|
||||
} else {
|
||||
currentBlock_ = -1;
|
||||
}
|
||||
currentBlock_ = blockCache->GetBlockNumberFromAddress(currentMIPS->pc);
|
||||
UpdateDisasm();
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user