Running
| Command | Does |
|---|---|
machine run |
Run one or more vCPU iterations |
machine plan |
Run a multi-clause plan from a file |
machine control |
Control a run interactively |
machine wait |
Wait until a run satisfies a predicate |
machine cancel |
Cancel the run or replay in progress |
machine replay |
Replay recorded entries from the parent lineage |
machine play |
Play recorded entries without checking divergence |
machine diff |
Compare a run log entry against another |
machine run
Run one or more vCPU iterations. See Driving it.
The machine executes and the run log records each iteration, so the run can be replayed.
The mode sets how an iteration executes. Fast mode stops near the limit, a little late. Step mode stops exactly. Step-into mode also steps into syscalls, gates and injected events.
An iteration is one dispatch of a vCPU. It ends where the guest next exits to the machine, or at the limit. Its length is not fixed. One may be five instructions and the next a million.
The run stops after --iters iterations or when the --until predicate holds.
No count is right in advance, because how long a program runs is not known. Use
--until to stop where something happens, with --iters or a vtime predicate
as a bound.
A run that went too far is not lost. Use rewind or go to return to an earlier point.
A vtime predicate holds once the clock of the machine reaches a time. vtime>=T counts from the start of the run. vtime=+T counts from where the run is. The run stops at the end of the iteration that reaches the time.
A decisions, events or coverage predicate counts what a program makes through the guest API. Use decisions=+N to stop N decisions from now, before the last one is answered. Use events>=N to stop after event N is written. The guest stops there itself, so the stop is exact.
Options vary the run. They draw the mode, the limit and the virtual time rate. They also draw a scheduling mark, slice and interrupt for a task. The same seed draws the same values.
The --until predicates are those of wait, with decisions, events and coverage.
The console~ predicate signals that boot is done. The halted and activity=idle
predicates do not.
A console~ predicate takes a regular expression. The run stops at the entry that ends the line the match is on. A match on a line with no end, such as a prompt, stops the run where the machine goes idle.
The match is within a line, as output search finds it, and has at least one character. Use the point console~REGEX to go to the entry that printed the first byte of the match.
The name of another source takes the place of console, as in ttyS1~REGEX. The run then stops for a line that source prints. A line another source prints does not stop it.
The path of an output file takes the same place, as in /output/drop/app/debug.log~REGEX. A file that is dropped stops the run the same way. The run stores none of the file. A path that holds a ~ is quoted, as in ‘“/output/keep/app.log~“~ERROR’.
Only text the run prints from its start ends it. A line printed before does not.
Use machine wait --for to ask whether text was printed.
tid=N:at=LOC runs until tid N reaches LOC in its own code. tgid=N:at=LOC runs until any thread of the process does. The address is resolved when the run starts. The stop takes one of the 3 debug registers the run’s watchpoints use.
tid=N:write=LOC runs until an instruction writes the bytes LOC names while tid N is on a vCPU. tid=N:access=LOC runs until one reads or writes them. tgid=N:write=LOC and tgid=N:access=LOC stop for any thread of the process.
The run stops after the access. A write the kernel makes for the task counts. A variable or an expression is watched at its size of 1, 2, 4 or 8 bytes. The watch takes one of the 3 debug registers the run’s watchpoints use.
An address is watched through a cast that gives it a type, as GDB’s watch takes one. The address is a multiple of the size. tgid=N also stops for a kernel thread that works in the process’s memory.
A run that stops at LOC says the tid that reached it and where it stands. A watch also says the value the access left in the bytes. The machine records both at the stop, so a task in the kernel still shows them.
LOC is one of these, in the task’s process:
1 | 0x401136 an address |
The run log records each iteration as an entry. It also records interrupts and device input, so entries outnumber iterations.
The global timeout cancels the run in flight. Without one there is no limit. A timeout of 0 checks once without batching. Exit 3 means the predicate was not reached.
--iters is an upper bound, not a count. A batch is the iterations one request
of the command runs. It ends at every context switch of a focused task, a task
the focus command names. It also ends where a task reaches its own code.
Without --until, a batch that ends early ends the run. With --until, the run
goes on with the next batch. With --iters 0 and neither --until nor
--within, a switch does not end the batch. The response reports how many
iterations ran.
Every parameter is drawn for one iteration. The mode, the limit, the task marks and the interrupt apply to the task on that one vCPU.
Without --vcpu, a scheduling cycle dispatches every vCPU. It spends up to one
iteration for each. --iters 100 on four vCPUs buys 100 dispatches, not 400.
With --until, --iters and the predicate are both bounds. The first to fire
wins. --iters 500 --until on stops at 500 iterations or when a focused task
takes a vCPU.
Use --within to bound the run by the machine’s clock. The machine checks the
bound at every iteration, so a slow host does not end the run sooner. With
--until, the first of the two to hold ends it. Without --until, the run goes
on until the clock has moved that far.
Without --iters, only the timeout bounds the run, so --until tasks runs a
whole boot. A span is lo:hi, a range one value is drawn from for each dispatch.
A span bounds nothing either, so --iters 100:500 --until on keeps going.
--when bounds nothing. It names what must be true for the clause to apply to a
dispatch. A dispatch it excludes runs free, up to the crossing into the subject.
So --when /test:on --until /test:exit perturbs that program while its own
code runs. It runs free while the program is in the kernel or off the CPU. It
stops when the program is gone. --iters counts every dispatch, the ones that
ran free too.
--when takes on, kernel and off. Each is a state, not an edge.
The options of run make one clause of a plan. Use machine plan <run> <file>
for a run of more than one clause.
A hit of a breakpoint, watchpoint or catchpoint ends the run. Use --iters 0 to
run until one does, as GDB’s continue does.
Use --back to go back to the newest breakpoint, watchpoint or catchpoint hit
the run recorded, as reverse-continue does. The machine switches onto a branch
at that entry, as go does. The branch keeps the run’s stops as they are now. The
run stays as it was.
The command waits until the run ends. Use --no-wait to return once the request
is accepted. The session then drives the run to its --until alone. Use machine
wait with the same predicate to wait for it later.
1 | machine run [-h] [--back] [--no-wait] [--limit span] [--backstop-limit n] [--retry n] |
| Argument | Does |
|---|---|
run |
Run name |
| Option | Does |
|---|---|
--back |
Go back to the newest hit before now, onto a branch |
--no-wait |
Return once the session drives the run to its --until |
--limit span |
Default branches per dispatch under fast and fence, steps under step; 0 means no limit under fast, one step under step and the machine’s fence under fence; default 0 |
--backstop-limit n |
Step modes only: machine instructions a dispatch may run without stepping before it ends, 0 for the machine default (default: 0) |
--retry n |
Retries for an entry the host interrupted, default 2; 0 does not retry |
--strategy name |
How spans resolve when they name none: random, golden, sweep (default: random) |
--seed n |
Seed for the random and golden draw strategies (default: 0) |
--vcpu span |
The vCPU, or a span to draw one per dispatch (default: all) |
--iters span |
Iterations, an upper bound; 0 is unlimited (default: 1; with --until, unbounded) |
--until predicate |
Drive until this is true: a predicate of wait --for, or tid=N:at=LOC, tid=N:write=LOC or tid=N:access=LOC, or the same with tgid=N |
--within duration |
End the run when the machine’s clock has moved this far, such as 10s |
--irqblk |
Block IRQs during run |
--rdtsc-exit |
Record an entry for every RDTSC exit |
--no-idle-skip |
Keep machine time crawling while every vCPU is idle |
--auto-checkpoints n |
Auto-checkpoint every N entries; 0 turns it off, default the machine’s |
--mode mode,... |
Execution mode: fast, step, step-into, free, fence, or a comma list to draw among, each with an optional [weight] (default: fast) |
--fast span |
Limit fast draws when it wins (its member), overriding --limit |
--step span |
Limit step draws when it wins (its member), overriding --limit |
--step-into span |
Limit step-into draws when it wins (its member) |
--fence span |
Conditional branches to stop at when fence mode is drawn, overriding --limit |
--vtime-rate span |
Vtime rate for this run: n, n/d, or a span of either |
--vtime-add span |
Nanoseconds to push the clock forward before each dispatch |
--timer-slack span |
How late a timer may be in code that takes no exit, drawn per dispatch, at most 1s |
--irq-delay [target=]span,... |
Hold each interrupt a time drawn from its target’s span, at most 1s. A target is timer, ipi, init, blk, rng, console, serial, keyboard, device or all, and a bare span is all |
--vtime-io-cost span,... |
Machine time an I/O, MMIO or hypercall exit costs, drawn per dispatch from spans such as 2us or 50:20us, 1ns to 1s |
--vtime-rdtsc-cost span,... |
Machine time an RDTSC; it follows the I/O cost unless given costs, drawn per dispatch from spans such as 2us or 50:20us, 1ns to 1s |
--vtime-pause-cost span,... |
Machine time each PAUSE a spin loop executes costs, drawn per dispatch from spans such as 2us or 50:20us, 1ns to 1s |
--task-pin [tid=]set,... |
Draw per dispatch where a task is placed when it next wakes: a vCPU set such as 1-3, free or none; tid= names the task |
--task-sched mark,... |
Draw a scheduler mark per dispatch for the task on that vCPU: keep, hold, yield, drain, drain-all |
--task-slice slice,... |
Draw that task’s slice per dispatch: keep, default, or a duration range such as 10us:600us |
--task-int int,... |
Draw an interrupt for that task per dispatch: none, preempt |
--when predicate |
Apply the clause only while this holds |
Examples:
1 | machine run run1 run one iteration |
Prints:
1 | progress <done>/<batch> vtime=<time> entry=<id> ic=<instructions> |
See also:
machine plan
Run a multi-clause plan from a file. See Plans.
A plan varies how the run executes. Its clauses draw the mode, the virtual time,
and the scheduling and interrupts of tasks. Use --iters and --until to bound
the run, as with run.
A plan file is a list of clauses. A clause is an optional when predicate and the per-dispatch axes it draws for a dispatch it matches. Clauses are tried in order. The last to match supplies each axis, so a later clause overrides an earlier one.
The else clause applies to a dispatch that no when matched. It is the last clause of the file.
Braces may group a clause. # begins a comment. Blank lines are ignored.
A file of - reads the plan from standard input. The plan applies to the run of this command only. A later machine run runs without the plan. Run machine plan again to go on with it.
Example:
1 | when /test:on mode step,fast fast=1:100k step=1:200 |
Example: place tid 56 on vCPU 2 or 3 when it wakes, 2 three times as often as 3:
1 | else task-pin 56=golden:2[3],3[1] |
A clause names one when predicate, then any of these axes. An axis is a comma list of choices, one drawn per dispatch. [N] is an optional weight on a choice:
1 | when <predicate> |
A weight makes a choice win more often. mode step[3],fast[1] draws step three times as often as fast. keep is the choice that draws nothing. It holds the last value of the axis, so a clause can leave an axis alone part of the time.
A span is a range written lo:hi[:strategy[:step]]. The strategy is random, golden or sweep. One value is drawn from the span per dispatch.
A span is accepted by the mode member limit, vtime-rate, vtime-add, task-slice,
timer-slack, irq-delay and the run-level --limit. The three exit costs take
one too. The limit itself is not a clause axis. It is the default for a mode
with no member limit of its own.
The options of this command are plan-level. --limit and --strategy are the
defaults for a clause that names no span of its own. A clause axis overrides
them for the dispatches it matches. A dispatch that no clause matches runs free.
--seed seeds the draw strategies. --until, --iters and --vcpu bound and
steer the run as on run. The clause axes and when belong in the file, not here.
1 | machine plan [-h] [--limit span] [--backstop-limit n] [--retry n] [--strategy name] |
| Argument | Does |
|---|---|
run |
Run name |
file |
Plan file of when and else clauses, and their axes, or - to read standard input |
| Option | Does |
|---|---|
--limit span |
Default branches per dispatch under fast and fence, steps under step; 0 means no limit under fast, one step under step and the machine’s fence under fence; default 0 |
--backstop-limit n |
Step modes only: machine instructions a dispatch may run without stepping before it ends, 0 for the machine default (default: 0) |
--retry n |
Retries for an entry the host interrupted, default 2; 0 does not retry |
--strategy name |
How spans resolve when they name none: random, golden, sweep (default: random) |
--seed n |
Seed for the random and golden draw strategies (default: 0) |
--vcpu span |
The vCPU, or a span to draw one per dispatch (default: all) |
--iters span |
Iterations, an upper bound; 0 is unlimited (default: 1; with --until, unbounded) |
--until predicate |
Drive until this is true: a predicate of wait --for, or tid=N:at=LOC, tid=N:write=LOC or tid=N:access=LOC, or the same with tgid=N |
--within duration |
End the run when the machine’s clock has moved this far, such as 10s |
--irqblk |
Block IRQs during run |
--rdtsc-exit |
Record an entry for every RDTSC exit |
--no-idle-skip |
Keep machine time crawling while every vCPU is idle |
--auto-checkpoints n |
Auto-checkpoint every N entries; 0 turns it off, default the machine’s |
Examples:
1 | machine plan run1 plan.txt run the clauses of plan.txt |
Prints:
1 | tally one line for each clause, numbered from 1 |
See also:
machine control
Control a run interactively. See Interactive mode.
The prompt takes slash commands. They map to the commands of machine, with a syntax of their own.
Type /help at the prompt to list the commands. Use -c to send a slash command from the command line, without opening the prompt. Use -c /help to list the commands that way.
A semicolon between two slash commands runs the second after the first, and stops when the first fails. The prompt reads quotes as a shell reads them. A semicolon inside quotes is part of the word.
Use control log with a run to read the command history instead of driving the
machine. Use --entries to select the commands issued at given run entries. Use
-n to select commands by number.
1 | machine control [-h] [--entries range] [--wide] [--plain] [-n range] [-c cmd] run|log [run] |
| Argument | Does |
|---|---|
run|log |
Run name, or log to read history |
[run] |
With log: the run whose history to read |
| Option | Does |
|---|---|
--entries range |
With log: commands at one entry, or an inclusive range |
--wide |
With log: show the entries, vCPU, opcode and size of each command (default on a terminal) |
--plain |
With log: show the commands alone (default into a pipe or a file) |
-n, --lines range |
With log: commands: N for one, A:B for A through B, A: from A on, :B up to B, : for all, -N or -N: for the last N, and -A:-B counted from the end |
-c, --command cmd |
Slash command to run without opening the prompt, such as “/f@100” |
Examples:
1 | machine control run1 open the prompt for run1 |
See also:
machine wait
Wait until a run satisfies a predicate. See Waiting.
Use wait to script against a run. It waits for a state, an entry, a console line or a task event. Several runs, or every run of the session, may be waited for.
The predicates are running, ready, tasks, stopped, paused, halted,
activity=<name>, entry>=N, entry=+N, vtime>=T, vtime=+T, console~REGEX and a
task predicate. The tasks predicate holds once the operating system is up and
its task table is readable. That is before it execs anything in userland.
A console~REGEX predicate holds once the console prints a match. The name of another source takes the place of console, as in ttyS1~REGEX.
A task predicate is [who:]what. The what is exec, exit, sched, desched, on, kernel or off. The who is /path, cgroup=path, comm=name, tgid=N or tid=N. Omitting it means any focused task.
A path, a cgroup or a comm must already be focused. Such a subject means its
tgid. tgid=N means the tgid for exit and any of its tasks for exec. Use machine
tasks <run> --focused to see which task is on a vCPU.
Four of the seven are edges. exec fires where a task matching who entered the task table. exit fires where one left it.
sched fires where a task is given the CPU. desched fires where one gives it up.
Three are states, and they partition time. on holds while the task is on cpu in its own code, at CPL 3. That is where a forced decision can land between two of its own instructions.
kernel holds while that task is on cpu in the kernel. off holds while it is not the task on cpu at all.
Named runs must be in the current session. Use --all to wait for every run in
it.
The global timeout bounds the wait. Without one there is no limit. A timeout of 0 checks once.
Exit codes: 0 success, 2 error, 3 timeout.
1 | machine wait [-h] [--all] --for predicate [--interval s] [run ...] |
| Argument | Does |
|---|---|
[run ...] |
One or more runs (omit with --all) |
| Option | Does |
|---|---|
--all |
Wait for every run in the session |
--for predicate |
Predicate such as running, stopped, entry=+N or console~REGEX |
--interval s |
Poll every S seconds (default: 1) |
Examples:
1 | machine wait --for running run1 until run1 runs |
See also:
machine cancel
Cancel the run or replay in progress. See Cancelling a drive.
A run stops where it is. The stop falls where the host’s clock put it, so another recording of the same state does not stop there. Describe reports the run as not repeatable from that entry. A replay stops before its next entry.
Use --soft to stop the run at the end of the dispatch in progress. That stop
is an ordinary entry, and the run stays repeatable. It takes at most the run’s
dispatch bound, 1s by default. Ctrl-C stops a run this way, and a second Ctrl-C
stops it now.
1 | machine cancel [-h] [--soft] run |
| Argument | Does |
|---|---|
run |
Run name |
| Option | Does |
|---|---|
--soft |
Stop at the end of the dispatch in progress, which keeps the run repeatable |
Examples:
1 | machine cancel run1 cancel what run1 is running |
Refuses, and the way past:
1 | a run with nothing in progress machine state run1 |
See also:
machine replay
Replay recorded entries from the parent lineage. See Replay.
The command executes the recorded entries again. During replay, Machine checks each entry against the original recording. If they don’t match, Machine reports a divergence. It names the entry, with the expected and actual values.
Without a line, the parent’s entries are replayed. A fork at an entry leaves that entry with the parent. The branch starts at the next entry, so the entries of the parent end at the fork. Replaying past them reports no forward entries.
Use --to to stop at a point of the line that is replayed. The point is an
entry, a checkpoint or a time of that line. A checkpoint the parent took after
the fork is such a point.
The line of a run is its entries from the root on, across every fork. Naming a run replays the entries of its line. The run must be in the same tree. The entry this run stands on must be on the line replayed.
An entry that diverges is replayed again from the newest checkpoint before it, at most twice. It is not replayed again once it diverges the same way twice. An entry that the host interrupted is replayed again the same way. It is not a divergence.
Use --retry to set how many retries. --retry 0 replays each entry once. Use
--limit-margin to set how many conditional branches short of each recorded
entry the CPU’s counter interrupts. A smaller margin makes a miss more likely.
The replay stores what the branch keeps of its output. A branch that keeps an
output file its parent dropped is how the file is read. Use fork with
--keep-output to make one. What is stored does not change what the machine
executes.
1 | machine replay [-h] [--to point [point ...]] [--trace] [--retry n] [--limit-margin n] |
| Argument | Does |
|---|---|
run |
Run name |
[line] |
Run whose line to replay, defaulting to the parent’s |
| Option | Does |
|---|---|
--to point [point ...] |
Point of the line to replay to: ^checkpoint, #entry, -N for N entries back, a time such as 10ms or -10ms, console~regex, console:N where line N was printed, now, parent [n], root, or %mark (default: the end of the line) |
--trace |
Trace each iteration one by one |
--retry n |
Retries for an entry that diverges or the host interrupted, default 2; 0 does not retry |
--limit-margin n |
Conditional branches short of each recorded stop where the CPU’s counter interrupts (default: the run’s) |
--instr-margin n |
Instructions short of each stop placed by an instruction count where the CPU’s counter interrupts (default: the run’s) |
Examples:
1 | machine replay try2 replay the parent's entries |
Prints:
1 | text Replayed <n> entries to entry <id>. Converged. |
Refuses, and the way past:
1 | a run off the line it would replay machine replay try2 run1 |
See also:
machine play
Play recorded entries without checking divergence. See Replay.
Use --include and --exclude to select the event types to play. The entries
no type names are always played. They are the clock’s rate and steps, the focus,
the stops and the debugger’s writes. The RUN entries after them need them.
A play that leaves out irq delivers the interrupts the machine raises itself, as a recording does. The run records them as its own.
The line of a run is its entries from the root on, as replay says. The run named must be in the tree of this run, and need not be on its line. Divergence is not checked.
1 | machine play [-h] [-n range] [--include type [type ...]] [--exclude type [type ...]] |
| Argument | Does |
|---|---|
run |
Run name |
[line] |
Run whose line to play, defaulting to the parent’s |
| Option | Does |
|---|---|
-n, --entries range |
Entries: N for one, A:B for A through B, A: from A on, :B up to B, : for all, -N or -N: for the last N, and -A:-B counted from the end |
--include type [type ...] |
Play only these event types: run, irq, exception, random, device_in, block_done, exit_shutdown, system_shutdown, system_reset, checkpoint, cpuid, rng_seed |
--exclude type [type ...] |
Leave these event types out |
Examples:
1 | machine play run1 -n 295:300 play entries 295 to 300 of run1 |
See also:
machine diff
Compare a run log entry against another. See Replay.
The command compares the state recorded at two entries. It breaks the combined
hash into machine state, memory and disk, with register detail, so the layer
that differs shows. It reads the recorded log, so no replay is needed. Use
--show to choose sections and --context to add the entries before.
With no second operand, the entry is compared against the run it was replayed from. The answer says whether the replay converged. Naming a run compares against that run, at its own entry when given as other:m. A difference between two recordings says that they differ, not that a replay diverged.
1 | machine diff [-h] [--show sections] [--entry n] [--context n] run [other[:m]] |
| Argument | Does |
|---|---|
run |
Run name |
[other[:m]] |
Run to compare against, at its entry m; m defaults to --entry |
| Option | Does |
|---|---|
--show sections |
One or more, comma-separated: code, regs, stack, pt, instr, trace, events, timers, debug, xsave, irq, pic, ioapic, devs, mem, disk, hash, counts, entry, io, msrs, fullhash, all; default hash |
--entry n |
Compare specific entry N (0 = last entry) |
--context n |
Also show the N entries leading up to it, on both sides |
Examples:
1 | machine diff try2 compare try2 with the run it replayed |
See also: