|
dex++ 0.3.1
C++ and C API reference
|
Whole-program cross-reference index for an AnalysisContext. More...
#include <analysis/xrefs.hpp>
Public Member Functions | |
| Xrefs ()=default | |
| Xrefs (const Xrefs &)=delete | |
| Xrefs & | operator= (const Xrefs &)=delete |
| Xrefs (Xrefs &&)=default | |
| Xrefs & | operator= (Xrefs &&)=default |
| std::span< const MethodId > | referrers () const |
| Identities of every defined method that contains at least one indexed instruction, in discovery order. | |
| const MethodId & | referrer_id (uint32_t referrer) const |
| Identity of one referrer. | |
| std::optional< Method > | referrer_method (uint32_t referrer) const |
| Materialize a Method handle for one referrer. | |
| std::span< const MethodXref > | method_refs (const MethodId &id) const |
All invoke sites whose declared target is exactly id. | |
| std::vector< std::pair< const MethodId *, std::span< const MethodXref > > > | method_refs_by_name (std::string_view name) const |
All invoke sites whose declared target has the bare name name, in any class and with any prototype — e.g. every call to "exec" or "loadUrl". | |
| std::span< const FieldXref > | field_refs (const FieldId &id) const |
All accesses (reads and writes) of the field id. | |
| std::vector< FieldXref > | field_reads (const FieldId &id) const |
Only the reads (iget* / sget*) of id. | |
| std::vector< FieldXref > | field_writes (const FieldId &id) const |
Only the writes (iput* / sput*) of id. | |
| std::span< const StringXref > | string_refs (std::string_view value) const |
All const-string loads of exactly value. | |
| std::vector< std::string_view > | referenced_strings () const |
| Every distinct string value loaded somewhere in the program. | |
| std::span< const TypeXref > | type_refs (std::string_view descriptor) const |
All type-referencing instructions naming descriptor. | |
| bool | empty () const |
Whole-program cross-reference index for an AnalysisContext.
Answers "who references X" for methods (call sites), fields (reads/writes), strings (const-string loads), and types (const-class / new-instance / check-cast / instance-of / new-array / filled-new-array). Built lazily on first AnalysisContext::xrefs() access and cached on the underlying impl.
Every site records the referrer — the defined method whose bytecode contains the instruction — as an index into referrers(), plus the instruction's code-unit offset. referrer_method() materializes a Method handle on demand.
When a class is defined in more than one loaded DEX file, only the code of its first definition is indexed: the one AnalysisContext::find_class() returns, and the one Android loads. The methods of a later definition never run, so they are not referrers.
Method references are literal: each invoke site is indexed under its declared target MethodId, with no class-hierarchy dispatch (use AnalysisContext::call_graph() — dispatch_targets(), callers() — for virtual dispatch). invoke-custom call sites and const-method-handle/-type operands are not indexed.
All spans and string_views returned by queries point into the index's own storage and stay valid for the lifetime of the AnalysisContext.
Move-only: copying would deep-copy every per-key site vector.
|
default |
|
delete |
|
default |
|
inline |
Identities of every defined method that contains at least one indexed instruction, in discovery order.
Site referrer fields index here.
|
inline |
Identity of one referrer.
Precondition: referrer < referrers().size().
| std::optional< Method > dex::Xrefs::referrer_method | ( | uint32_t | referrer | ) | const |
Materialize a Method handle for one referrer.
Returns nullopt when referrer >= referrers().size().
| std::span< const MethodXref > dex::Xrefs::method_refs | ( | const MethodId & | id | ) | const |
All invoke sites whose declared target is exactly id.
| std::vector< std::pair< const MethodId *, std::span< const MethodXref > > > dex::Xrefs::method_refs_by_name | ( | std::string_view | name | ) | const |
All invoke sites whose declared target has the bare name name, in any class and with any prototype — e.g. every call to "exec" or "loadUrl".
Each result pairs the matched target with its sites.
All accesses (reads and writes) of the field id.
Only the reads (iget* / sget*) of id.
Only the writes (iput* / sput*) of id.
| std::span< const StringXref > dex::Xrefs::string_refs | ( | std::string_view | value | ) | const |
All const-string loads of exactly value.
| std::vector< std::string_view > dex::Xrefs::referenced_strings | ( | ) | const |
Every distinct string value loaded somewhere in the program.
Useful as the enumeration step before substring/pattern filtering.
| std::span< const TypeXref > dex::Xrefs::type_refs | ( | std::string_view | descriptor | ) | const |
All type-referencing instructions naming descriptor.
|
inline |