From fbe452650214ae1b4fc4653f2a51c89a093531b3 Mon Sep 17 00:00:00 2001 From: "Edward J. Schwartz" Date: Sat, 6 Jan 2024 08:14:14 -0500 Subject: [PATCH] Fix #65 It's not clear why we were calling getUndefinedRanges, and it had a substantial performance impact so I removed it. --- CHANGELOG.md | 4 ++++ src/main/java/kaiju/tools/disasm/DisasmStrategy.java | 12 +++--------- .../kaiju/tools/disasm/impl/X86ImproverStrategy.java | 3 +-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb6115c..dba4b18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Current Release +## 240106 +- Bugfixes: +* Improve performance of Disassembly Improvements (#65) + ## 231227 - Improvements: * Support for Ghidra 11.0 diff --git a/src/main/java/kaiju/tools/disasm/DisasmStrategy.java b/src/main/java/kaiju/tools/disasm/DisasmStrategy.java index e3de3a9..0e01008 100644 --- a/src/main/java/kaiju/tools/disasm/DisasmStrategy.java +++ b/src/main/java/kaiju/tools/disasm/DisasmStrategy.java @@ -96,7 +96,7 @@ default Pair makeAlignment(Listing listing, final Address * this is a default implementation that shouldn't rely on * architecture, but can be overriden if needed for some reason. */ - default Pair makeCode(Program currentProgram, Listing listing, AddressSetView allAddresses, final Address address, TaskMonitor monitor) { + default Pair makeCode(Program currentProgram, Listing listing, final Address address, TaskMonitor monitor) { // Making code at a previous gap might have converted this gap to code, so we need to // check again to see if this address range is still a gap... if (GhidraTypeUtilities.getBlockType(listing, address) == GhidraTypeUtilities.BlockType.CODE) { @@ -110,14 +110,8 @@ default Pair makeCode(Program currentProgram, Listing lis } // debug(this, "Making code at " + address); - AddressSetView undefinedAddresses = null; - try { - undefinedAddresses = listing.getUndefinedRanges(allAddresses, false, monitor); - } catch (CancelledException e) { - final AddressRange range = new AddressRangeImpl(address, address); - return new Pair(range, 0); - } - final DisassembleCommand disassembleCmd = new DisassembleCommand(address, undefinedAddresses, true); + + final DisassembleCommand disassembleCmd = new DisassembleCommand(address, null, true); disassembleCmd.enableCodeAnalysis(true); disassembleCmd.applyTo(currentProgram, monitor); diff --git a/src/main/java/kaiju/tools/disasm/impl/X86ImproverStrategy.java b/src/main/java/kaiju/tools/disasm/impl/X86ImproverStrategy.java index 870f078..c8aa572 100644 --- a/src/main/java/kaiju/tools/disasm/impl/X86ImproverStrategy.java +++ b/src/main/java/kaiju/tools/disasm/impl/X86ImproverStrategy.java @@ -92,8 +92,7 @@ public Pair analyzeGap(final AddressRange range) { if (b == 0xCC) { return makeAlignment(listing, minAddr, monitor); } else { - AddressSetView allAddresses = memory.getAllInitializedAddressSet(); - return makeCode(currentProgram, listing, allAddresses, minAddr, monitor); + return makeCode(currentProgram, listing, minAddr, monitor); } case DATA: if (b == 0x00)