diff --git a/include/fxos/disassembly.h b/include/fxos/disassembly.h index d0e2449..5435330 100644 --- a/include/fxos/disassembly.h +++ b/include/fxos/disassembly.h @@ -214,6 +214,9 @@ struct Disassembly claims which do not compare equal to c, this fails. */ bool addExclusiveClaim(Claim const &c); + /* Get all claims owned by a certain address. */ + std::vector findClaimsOwnedBy(uint32_t address); + // TODO: Add non-exclusive claims/handle collisions diff --git a/lib/disassembly.cpp b/lib/disassembly.cpp index 9142315..743c375 100644 --- a/lib/disassembly.cpp +++ b/lib/disassembly.cpp @@ -227,6 +227,19 @@ bool Disassembly::addExclusiveClaim(Claim const &c) return exclusive; } +std::vector Disassembly::findClaimsOwnedBy(uint32_t address) +{ + std::vector claims; + + /* Since we don't order by owner we have to tank the linear search */ + for(auto const &c: this->claims) { + if(c.owner == address) + claims.push_back(&c); + } + + return claims; +} + //--- // DisassemblyPass diff --git a/shell/i.cpp b/shell/i.cpp index 43c53b7..1cb80b1 100644 --- a/shell/i.cpp +++ b/shell/i.cpp @@ -34,11 +34,19 @@ void _ic(Session &session, struct _ic_args const &args) return; for(uint32_t address: args.addresses) { + fmt::print("Claim over 0x{:08x}:\n", address); Claim const *claim = session.current_space->disasm.getClaimAt(address); if(claim) - fmt::print("0x{:08x} is claimed by {}\n", address, claim->str()); + fmt::print(" 0x{:08x} is claimed by {}\n", address, claim->str()); else - fmt::print("0x{:08x} is not claimed\n", address); + fmt::print(" 0x{:08x} is not claimed\n", address); + + auto dep = session.current_space->disasm.findClaimsOwnedBy(address); + fmt::print("Claims owned by 0x{:08x}:\n", address); + for(Claim const *c: dep) + fmt::print(" - {}\n", c->str()); + if(!dep.size()) + fmt::print(" (none)\n"); } }