Argus.Lines (Panoptes v0.13.0)

Copy Markdown View Source

Resolves anchor IDs to source lines using line_info facts.

Layer 1 stamps every instruction with the source line in effect (schema version 3), so an instruction ID resolves to its exact line and a function ID to its first stamped line. Build a table once per extraction with from_facts/1 or from_facts_dir/1, then resolve/2 the ID forms findings carry: witness-column strings, Argus.InstrId structs, or MFA tuples.

Resolution is best-effort by design: IDs from modules without a parseable Line chunk, compiler-generated code under a no-location marker, and strings that are not IDs at all resolve to nil, never a guess.

Summary

Types

t()

Line tables: exact per-instruction plus first-line per function.

Functions

Builds line tables from an extracted facts map (raw string rows, as returned by Argus.Pipeline.extract/2 with the default format).

Builds line tables from a .facts directory (the line_info.facts file written by Argus.Pipeline.run/3). A missing or unreadable file yields empty tables — every lookup resolves to nil.

Resolves an anchor to its source line, or nil.

Types

t()

@type t() :: %{
  by_instr: %{required(String.t()) => pos_integer()},
  by_func: %{required(String.t()) => pos_integer()}
}

Line tables: exact per-instruction plus first-line per function.

Functions

from_facts(facts)

@spec from_facts(%{required(atom()) => [[String.t()]]}) :: t()

Builds line tables from an extracted facts map (raw string rows, as returned by Argus.Pipeline.extract/2 with the default format).

from_facts_dir(dir)

@spec from_facts_dir(Path.t()) :: t()

Builds line tables from a .facts directory (the line_info.facts file written by Argus.Pipeline.run/3). A missing or unreadable file yields empty tables — every lookup resolves to nil.

resolve(lines, instr_id)

@spec resolve(t(), String.t() | Argus.InstrId.t() | mfa()) :: pos_integer() | nil

Resolves an anchor to its source line, or nil.

Accepts an instruction ID string ("Mod:func/arity#idx" — exact line), a function ID string ("Mod:func/arity" — the function's first line), an Argus.InstrId, or an MFA tuple. Any other string (module names, extractor placeholders like "dynamic") misses both tables and resolves to nil.