_ic: also print claims owned by provided address

This commit is contained in:
Lephenixnoir 2023-08-20 20:27:52 +02:00
parent 2dbd910379
commit 0373ae50fe
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 26 additions and 2 deletions

View File

@ -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<Claim const *> findClaimsOwnedBy(uint32_t address);
// TODO: Add non-exclusive claims/handle collisions

View File

@ -227,6 +227,19 @@ bool Disassembly::addExclusiveClaim(Claim const &c)
return exclusive;
}
std::vector<Claim const *> Disassembly::findClaimsOwnedBy(uint32_t address)
{
std::vector<Claim const *> 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

View File

@ -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");
}
}