lmdebug reference

Complete command-line subcommand and flag reference, domain schema contexts and methods (lmdebug, net, sys, proc, detect, shark), standard lmcode_std_v3 REST and CLI interfaces, and exit codes for lmdebug.

Host and CLI subcommands

Subcommand or flagArguments and optionsDescription
--versionnonePrint the lmdebug version string and exit 0.
capsnonePrint platform, OS, architecture, effective root/capability bits, supported commands, and mutating verbs as JSON.
--lmcode-schema[--json]Print the embedded lmdebug schema summary or raw schema JSON bytes.
--lmcode-signaturesnonePrint canonical context, function, and method signatures including the 226 standard lmcode_std_v3 signatures.
--lmcode[--dry-run] [--plan-format json|text] [--dry-loop-limit N] <file.dslb> [...]Execute compiled LMScript bytecode, or emit an lmscript.host_plan.v1 host-effect plan when --dry-run is passed.
pcap[--version | --lmcode-schema [--json] | --lmcode-signatures | [--dry-run] --lmcode <file.dslb>]Run the packet-capture and protocol-analysis sub-host exposing context shark: Shark.
dns / digdns <host> | dig <name> [TYPE] [@server]Resolve IPv4/IPv6 addresses via getaddrinfo or send an RFC 1035 UDP DNS query and emit JSON records.
ifaddrs / linkifaddrs | link | link set <iface> [up|down] [mtu N] [--apply] [--force] [--if-match ID] [--audit-file PATH]List interface addresses or dump rtnetlink link devices and 64-bit counters; plan or apply link state and MTU changes.
ethtool<iface> [-i|--driver-info|-S|--statistics]Query link speed, duplex, autoneg, carrier, driver/firmware metadata, or NIC statistics via SIOCETHTOOL as JSON.
route / rule / neighroute | rule | neighDump kernel IPv4/IPv6 routing tables, policy routing rules, or ARP/NDP neighbor tables over rtnetlink as JSON.
counters / socketscounters | sockets [tcp|udp|unix] [--listen] [--summary]Read /proc/net protocol counters or inspect socket tables with PID ownership attribution and state summaries.
trace / tracepath / mtrtrace <host> [maxttl] [--pmtu] [-l len] | tracepath <host> | mtr <host> [--cycles N] [--interval MS] [--timeout MS] [--max-ttl N]Run IPv4 UDP traceroute, path-MTU discovery, or multi-cycle per-hop loss and latency statistics as JSON (requires root or CAP_NET_RAW).
arping<iface> <host> [--count N] [--interval MS] [--timeout MS]Send bounded IPv4 ARP reachability probes on an Ethernet interface (requires root or CAP_NET_RAW).
scan / pipescan <host> [--ports SPEC] [--timeout MS] [--concurrency N] | pipe <host> <port> | pipe --listen <port> [--forever]Run unprivileged parallel TCP connect port scans or open a binary-safe TCP stdio bridge.
ping / iperf3ping <host> [options] | iperf3 [options]Run the statically linked iputils ping engine or iperf3 throughput client/server engine.
sys cpu / mem / disk / topsys cpu [--interval MS] | sys mem | sys disk [--interval MS] [--count N] | sys top [--interval MS] [--count N] [--top N] [--sort cpu|mem|disk]Sample aggregate and per-core CPU deltas, memory/swap/PSI pressure, per-device disk I/O rates, or top processes as JSON.
sys set<KEY=VALUE> [--apply] [--force] [--if-match ID] [--audit-file PATH]Plan or apply a persistent /proc/sys sysctl modification through the mutation framework.
proc [list] / show / killproc [list] [--user U] [--name TEXT] [--pid PID] [--sort pid|cpu|mem|name] [--top N] [--fds] [--net] | proc show <PID> [--fds] [--net] [--maps] | proc kill <PID> [--signal SIG] [--apply] [--force] [--if-match ID] [--audit-file PATH]Enumerate processes, deep-inspect one PID, or plan/send a reuse-safe signal via pidfd_send_signal.
detect scan / autorunsdetect scan <PATH> [--rules PATH] [--max-size MB] | detect autoruns [--root DIR] [--json]Scan files or directories with embedded static libyara rules or enumerate Linux persistence locations and suspicion rankings.
detect hashesdetect hashes import <PATH> [--db PATH] [--format auto|plain|malwarebazaar-sha256|threatfox-ioc] [--source NAME] [--apply] | detect hashes scan <PATH> [--db PATH] [--recursive] | detect hashes status [--db PATH]Import SHA-256/MD5 feeds into an offline LMHASH01 signature store, scan files against the store, or check database status.
detect quarantine / restoredetect quarantine <PATH> [--quarantine-dir DIR] [--rule NAME:SEVERITY] [--apply] [--force] | detect restore <ID> [--quarantine-dir DIR] [--apply] [--force]Plan or execute file quarantine into a 0700 store with SHA-256 sidecar metadata, or restore a quarantined file by ID.

Capabilities, Networking, and System contexts (lmdebug, net, sys)

Context or typeMethod signatureDescription
context lmdebug: Metalmdebug.caps_json() -> string | lmdebug.apply_enabled() -> bool | lmdebug.force_enabled() -> bool | lmdebug.changes_remaining() -> intReturn the capability JSON document, check whether --apply or --force is active, or inspect remaining mutation budget.
context net: Netnet.dns_lookup(string) -> StrList | net.dns_query(string, string, string) -> DnsResultResolve host addresses via getaddrinfo or send a UDP RFC 1035 DNS query (name, type, server) and inspect rcode, answers, and error.
Netnet.interfaces() -> InterfaceList | net.links() -> LinkList | net.link_set(string, string, int) -> ChangeList interfaces with addresses (name, addr, netmask, family, mtu, up, loopback), dump rtnetlink link counters, or plan a link state/MTU change.
Netnet.ethtool_link(string) -> EthtoolLink | net.ethtool_driver(string) -> EthtoolDriver | net.ethtool_stats(string) -> EthtoolStatsQuery interface link settings (speed_mbps, duplex, autoneg, port, link_detected), driver info, or NIC statistics via SIOCETHTOOL.
Netnet.routes() -> RouteList | net.rules() -> RuleList | net.neighbors() -> NeighborList | net.counters() -> CounterListDump kernel routing tables, policy routing rules, ARP/NDP neighbors over rtnetlink, or /proc/net protocol counters.
Netnet.sockets(string, bool) -> SocketList | net.socket_summary(string) -> SocketSummaryList sockets filtered by protocol and listen_only flag with PID/process ownership, or compute per-family and TCP state totals.
Netnet.scan(string, string) -> ScanResult | net.check(string, int) -> boolRun a parallel TCP connect port scan over a port specification or perform a 750 ms boolean single-port check.
Netnet.tcp_connect(string, int) -> TcpConn | net.tcp_listen(int) -> TcpListenerOpen a blocking TCP client connection or bind a local TCP listener for deterministic loopback tests.
Netnet.trace(string, int) -> TraceResult | net.mtr(string, int) -> MtrResult | net.arping(string, string, int, int, int) -> ArpingResultRun IPv4 UDP traceroute, multi-cycle MTR loss/latency analysis, or explicit-interface ARP probes (errors reported via .error()).
context sys: Syssys.cpu() | sys.cpu(int) -> CpuResult | sys.mem() -> MemResultSample aggregate and per-core CPU utilization percentages over an interval, or read physical memory, swap, and PSI pressure.
Syssys.disk() | sys.disk(int) -> DiskResult | sys.top() | sys.top(int, int) -> TopResult | sys.set(string, string) -> ChangeMeasure block-device I/O byte rates, IOPS, and await, rank top processes by CPU/RSS/disk, or plan a /proc/sys sysctl change.

Process, Detection, Change, and Packet Capture contexts (proc, detect, shark)

Context or typeMethod signatureDescription
context proc: Procproc.list() -> ProcList | proc.show(int) -> ProcShow | proc.kill(int, string) -> ChangeEnumerate /proc processes, deep-inspect one PID (limits, fds, net, maps, uid, gid, threads), or plan/send a reuse-safe pidfd signal.
context detect: Detectdetect.scan(string) -> DetectScanResult | detect.autoruns() | detect.autoruns(string) -> AutorunListScan files or directories with embedded static libyara rules or enumerate Linux persistence locations and suspicion rankings.
Detectdetect.hash_import(string) -> Change | detect.hashes_scan(string) -> HashScanResult | detect.quarantine(string) -> Change | detect.restore(string) -> ChangePlan an LMHASH01 feed import, scan files against offline SHA-256/MD5 signatures, or plan file quarantine and restoration.
Changech.action() | ch.result() | ch.detail() | ch.plan_id() -> string | ch.dry_run() | ch.applied() | ch.needs_force() -> bool | ch.warnings() -> StrListInspect the dry-run or applied mutation envelope returned by net.link_set, sys.set, proc.kill, and detect mutations.
context shark: Sharkshark.interfaces() -> SharkIfaceList | shark.compile_filter(string, int) -> BpfProgram | shark.live(string, int, int, int, bool, bool, string) -> CaptureEnumerate libpcap capture interfaces, compile cBPF filter expressions offline, or capture live packets when permitted.
Shark / Captureshark.capture() | shark.open(string) -> Capture | c.count(string) -> int | c.save_pcapng(string) | c.save_fields_csv(string, string, string) -> voidCreate synthetic packet traces or open pcap/pcapng files, count packets matching display filters, and export CSV field projections or pcapng files.

Standard lmcode_std_v3 REST and CLI interfaces

Interface or functionSignature / annotationDescription
RestGet .. RestOptions@"/path/:param" fn h(x: RestExchange) -> void implements RestGetBind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler.
RestHandler@"/path" fn h(x: RestExchange) -> void implements RestHandlerBind a method-agnostic HTTP route handler.
CliCommand@"cmd" fn h(x: RestExchange) -> void implements CliCommandBind a named CLI subcommand dispatched by rest_cli.
CliOption@"--flag" fn h(x: RestExchange) -> void implements CliOptionBind a CLI option flag (--flag=val or --flag val) evaluated before the command handler.
rest_config / rest_routerest_config(key: string, val: string) -> void | rest_route(method: string, path: string, handler: string) -> voidConfigure host, port, or session (ephemeral or global) and dynamically register HTTP route handlers.
rest_serve / rest_stop / rest_clirest_serve() -> void | rest_stop() -> void | rest_cli(args: StrList) -> stringStart or stop the embedded standard HTTP server or dispatch CLI options, commands, and routes in-process.
RestExchangex.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) | x.get(string) -> string | x.has_query(string) | x.has_header(string) -> bool | x.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) | x.set(string, string) -> void | x.increment(string) -> intInspect request metadata, emit plain text or JSON responses, and read or mutate ephemeral/global session state.

Exit codes

Exit codeCategoryMeaning
0SuccessCLI subcommand, dry-run plan, or _lmcode_ bytecode program succeeded and all assertions passed.
1Operation errorDirect CLI diagnostic or subcommand failed at runtime.
2Usage errorInvalid CLI argument, unknown flag, or non-integer LMDEBUG_MAX_MEMORY_MB value.
3Host / VM errorBytecode load failure, schema mismatch, unhandled VM runtime exception, or exceeding the 4096 MiB memory limit.
4Contract failureAn application assertion (assert, assert_eq) failed inside an _lmcode_ script.
5Policy refusalMutation permanently refused by safety policy (e.g., write-only sysctls vm.drop_caches or vm.compact_memory, or signaling PID 1).
6Plan driftThe fresh plan_id computed during --apply did not match the --if-match sha256:<64hex> digest.