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 flag | Arguments and options | Description |
|---|---|---|
| --version | none | Print the lmdebug version string and exit 0. |
| caps | none | Print 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-signatures | none | Print 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 / dig | dns <host> | dig <name> [TYPE] [@server] | Resolve IPv4/IPv6 addresses via getaddrinfo or send an RFC 1035 UDP DNS query and emit JSON records. |
| ifaddrs / link | ifaddrs | 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 / neigh | route | rule | neigh | Dump kernel IPv4/IPv6 routing tables, policy routing rules, or ARP/NDP neighbor tables over rtnetlink as JSON. |
| counters / sockets | counters | sockets [tcp|udp|unix] [--listen] [--summary] | Read /proc/net protocol counters or inspect socket tables with PID ownership attribution and state summaries. |
| trace / tracepath / mtr | trace <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 / pipe | scan <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 / iperf3 | ping <host> [options] | iperf3 [options] | Run the statically linked iputils ping engine or iperf3 throughput client/server engine. |
| sys cpu / mem / disk / top | sys 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 / kill | proc [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 / autoruns | detect 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 hashes | detect 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 / restore | detect 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 type | Method signature | Description |
|---|---|---|
| context lmdebug: Meta | lmdebug.caps_json() -> string | lmdebug.apply_enabled() -> bool | lmdebug.force_enabled() -> bool | lmdebug.changes_remaining() -> int | Return the capability JSON document, check whether --apply or --force is active, or inspect remaining mutation budget. |
| context net: Net | net.dns_lookup(string) -> StrList | net.dns_query(string, string, string) -> DnsResult | Resolve host addresses via getaddrinfo or send a UDP RFC 1035 DNS query (name, type, server) and inspect rcode, answers, and error. |
| Net | net.interfaces() -> InterfaceList | net.links() -> LinkList | net.link_set(string, string, int) -> Change | List interfaces with addresses (name, addr, netmask, family, mtu, up, loopback), dump rtnetlink link counters, or plan a link state/MTU change. |
| Net | net.ethtool_link(string) -> EthtoolLink | net.ethtool_driver(string) -> EthtoolDriver | net.ethtool_stats(string) -> EthtoolStats | Query interface link settings (speed_mbps, duplex, autoneg, port, link_detected), driver info, or NIC statistics via SIOCETHTOOL. |
| Net | net.routes() -> RouteList | net.rules() -> RuleList | net.neighbors() -> NeighborList | net.counters() -> CounterList | Dump kernel routing tables, policy routing rules, ARP/NDP neighbors over rtnetlink, or /proc/net protocol counters. |
| Net | net.sockets(string, bool) -> SocketList | net.socket_summary(string) -> SocketSummary | List sockets filtered by protocol and listen_only flag with PID/process ownership, or compute per-family and TCP state totals. |
| Net | net.scan(string, string) -> ScanResult | net.check(string, int) -> bool | Run a parallel TCP connect port scan over a port specification or perform a 750 ms boolean single-port check. |
| Net | net.tcp_connect(string, int) -> TcpConn | net.tcp_listen(int) -> TcpListener | Open a blocking TCP client connection or bind a local TCP listener for deterministic loopback tests. |
| Net | net.trace(string, int) -> TraceResult | net.mtr(string, int) -> MtrResult | net.arping(string, string, int, int, int) -> ArpingResult | Run IPv4 UDP traceroute, multi-cycle MTR loss/latency analysis, or explicit-interface ARP probes (errors reported via .error()). |
| context sys: Sys | sys.cpu() | sys.cpu(int) -> CpuResult | sys.mem() -> MemResult | Sample aggregate and per-core CPU utilization percentages over an interval, or read physical memory, swap, and PSI pressure. |
| Sys | sys.disk() | sys.disk(int) -> DiskResult | sys.top() | sys.top(int, int) -> TopResult | sys.set(string, string) -> Change | Measure 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 type | Method signature | Description |
|---|---|---|
| context proc: Proc | proc.list() -> ProcList | proc.show(int) -> ProcShow | proc.kill(int, string) -> Change | Enumerate /proc processes, deep-inspect one PID (limits, fds, net, maps, uid, gid, threads), or plan/send a reuse-safe pidfd signal. |
| context detect: Detect | detect.scan(string) -> DetectScanResult | detect.autoruns() | detect.autoruns(string) -> AutorunList | Scan files or directories with embedded static libyara rules or enumerate Linux persistence locations and suspicion rankings. |
| Detect | detect.hash_import(string) -> Change | detect.hashes_scan(string) -> HashScanResult | detect.quarantine(string) -> Change | detect.restore(string) -> Change | Plan an LMHASH01 feed import, scan files against offline SHA-256/MD5 signatures, or plan file quarantine and restoration. |
| Change | ch.action() | ch.result() | ch.detail() | ch.plan_id() -> string | ch.dry_run() | ch.applied() | ch.needs_force() -> bool | ch.warnings() -> StrList | Inspect the dry-run or applied mutation envelope returned by net.link_set, sys.set, proc.kill, and detect mutations. |
| context shark: Shark | shark.interfaces() -> SharkIfaceList | shark.compile_filter(string, int) -> BpfProgram | shark.live(string, int, int, int, bool, bool, string) -> Capture | Enumerate libpcap capture interfaces, compile cBPF filter expressions offline, or capture live packets when permitted. |
| Shark / Capture | shark.capture() | shark.open(string) -> Capture | c.count(string) -> int | c.save_pcapng(string) | c.save_fields_csv(string, string, string) -> void | Create 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 function | Signature / annotation | Description |
|---|---|---|
| RestGet .. RestOptions | @"/path/:param" fn h(x: RestExchange) -> void implements RestGet | Bind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler. |
| RestHandler | @"/path" fn h(x: RestExchange) -> void implements RestHandler | Bind a method-agnostic HTTP route handler. |
| CliCommand | @"cmd" fn h(x: RestExchange) -> void implements CliCommand | Bind a named CLI subcommand dispatched by rest_cli. |
| CliOption | @"--flag" fn h(x: RestExchange) -> void implements CliOption | Bind a CLI option flag (--flag=val or --flag val) evaluated before the command handler. |
| rest_config / rest_route | rest_config(key: string, val: string) -> void | rest_route(method: string, path: string, handler: string) -> void | Configure host, port, or session (ephemeral or global) and dynamically register HTTP route handlers. |
| rest_serve / rest_stop / rest_cli | rest_serve() -> void | rest_stop() -> void | rest_cli(args: StrList) -> string | Start or stop the embedded standard HTTP server or dispatch CLI options, commands, and routes in-process. |
| RestExchange | x.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) -> int | Inspect request metadata, emit plain text or JSON responses, and read or mutate ephemeral/global session state. |
Exit codes
| Exit code | Category | Meaning |
|---|---|---|
| 0 | Success | CLI subcommand, dry-run plan, or _lmcode_ bytecode program succeeded and all assertions passed. |
| 1 | Operation error | Direct CLI diagnostic or subcommand failed at runtime. |
| 2 | Usage error | Invalid CLI argument, unknown flag, or non-integer LMDEBUG_MAX_MEMORY_MB value. |
| 3 | Host / VM error | Bytecode load failure, schema mismatch, unhandled VM runtime exception, or exceeding the 4096 MiB memory limit. |
| 4 | Contract failure | An application assertion (assert, assert_eq) failed inside an _lmcode_ script. |
| 5 | Policy refusal | Mutation permanently refused by safety policy (e.g., write-only sysctls vm.drop_caches or vm.compact_memory, or signaling PID 1). |
| 6 | Plan drift | The fresh plan_id computed during --apply did not match the --if-match sha256:<64hex> digest. |