Argus.Pipeline.Disassemble (Panoptes v0.13.0)

Copy Markdown View Source

Resolves module identifiers to .beam paths and disassembles them.

This is the first stage of Argus.Pipeline: a thin wrapper around BeamSpy.BeamFile that handles module-atom, string-path, and raw beam-data inputs and bundles imports into the disassembled data so the emitter has everything it needs in one place.

Summary

Functions

Disassembles a .beam file (by path or raw beam data) into module data, bundling its imports and its Line-chunk table.

Resolves a list of module atoms, .beam file paths, or raw beam data binaries to a list of disassembly inputs.

Types

module_data()

@type module_data() :: %{
  :module => atom(),
  :exports => list(),
  :attributes => keyword(),
  :functions => list(),
  :imports => list(),
  :line_table => %{required(pos_integer()) => pos_integer()},
  optional(any()) => any()
}

module_input()

@type module_input() :: atom() | String.t() | binary()

Functions

disassemble_path(path)

@spec disassemble_path(String.t() | binary()) ::
  {:ok, module_data()} | {:error, term()}

Disassembles a .beam file (by path or raw beam data) into module data, bundling its imports and its Line-chunk table.

Returns {:ok, data} where data has the standard BeamSpy disassembly shape plus :imports and :line_table fields, or {:error, reason} on failure. The line table maps the disassembly's {:line, ref} references to real source lines (reference 0 — "no location" — has no entry); it is empty when the module has no parseable Line chunk, in which case no line_info facts can be emitted.

resolve_paths(modules)

@spec resolve_paths([module_input()]) ::
  {:ok, [String.t() | binary()]} | {:error, term()}

Resolves a list of module atoms, .beam file paths, or raw beam data binaries to a list of disassembly inputs.

Raw beam data (recognized by BeamSpy.BeamFile.beam_data?/1 — the "FOR1" IFF header or gzip magic) passes through untouched; every downstream BeamSpy reader accepts data and paths interchangeably. This lets callers holding in-memory bytecode (e.g. straight from Code.compile_string/2) analyze it without a temp-file round trip.

Returns {:ok, inputs} or {:error, {:not_found, ref}} on the first unresolved entry.