Launching TestFlows Machine: self-service deterministic simulation testing environment Read the post

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
2
3
4
5
6
7
0x401136            an address
*0x401136 an address, as GDB writes it
main a function or a variable, by its name
libc.so.6:malloc a name in one file, by its path or file name
init.c:106 a source line, from the line tables
$rip a register of the task, as it is now
main+4, $rsp-8 any of these moved by +N or -N

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
2
3
4
5
6
7
8
9
10
machine run [-h] [--back] [--no-wait] [--limit span] [--backstop-limit n] [--retry n]
[--strategy name] [--seed n] [--vcpu span] [--iters span] [--until predicate]
[--within duration] [--irqblk] [--rdtsc-exit] [--no-idle-skip]
[--auto-checkpoints n] [--mode mode,...] [--fast span] [--step span]
[--step-into span] [--fence span] [--vtime-rate span] [--vtime-add span]
[--timer-slack span] [--irq-delay [target=]span,...] [--vtime-io-cost span,...]
[--vtime-rdtsc-cost span,...] [--vtime-pause-cost span,...]
[--task-pin [tid=]set,...] [--task-sched mark,...] [--task-slice slice,...]
[--task-int int,...] [--when predicate]
run
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
machine run run1                             run one iteration
machine run run1 --iters 100 run 100 iterations
machine run run1 --iters 0 continue to the next hit
machine run run1 --mode step --iters 20 single-step 20 iterations
machine run run1 --mode fence --limit 50000 stop on 50000 branches
machine run run1 --until halted --no-wait leave it to the session
machine run run1 --until 'console~login:' until the console prints login:
machine run run1 --until 'entry>=500' until it reaches entry 500
machine run run1 --until vtime=+10ms until its clock moves 10 ms
machine run run1 --until tasks until its tasks can be listed
machine run run1 --until tid=41:at=main until tid 41 is at main
machine run run1 --until tgid=7:at=a.c:9 until tgid 7 reaches a.c:9
machine run run1 --until tid=41:write=sum until tid 41 writes sum
machine run run1 --until tgid=7:access=buf until tgid 7 touches buf
machine run run1 --within 10s until its clock has moved 10 s
machine run run1 --vtime-pause-cost 50:20us a PAUSE's cost drawn
machine run run1 --task-pin 56=1,2 tid 56 on vCPU 1 or 2
machine run run1 --until tasks --within 9s the first of the two
machine run run1 --irq-delay 0:2ms hold each interrupt up to 2 ms
machine run run1 --irq-delay blk=1ms hold disk interrupts 1 ms
machine run run1 --timer-slack 0:20ms draw the timer slack

Prints:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
progress       <done>/<batch> vtime=<time> entry=<id> ic=<instructions>
summary iterations: <n> run ic: <instructions in this run>
vtime: +<how far the clock moved in this run>
last dispatch VCPU EXIT ID RUN IC RCB TOTAL IC REGS HASH RIP RCX ITER
EXIT why it ended: IO, MMIO, HYPERCALL, HLT, INSTR_LIMIT
INSTR_LIMIT is the limit reached, or a cancel
IO with EXIT_SHUTDOWN is the guest powering off
ID the entry the dispatch wrote
RCB conditional branches retired, which replay matches on
REGS HASH a hash of the registers, which replay matches on
ITER which iteration of this command it was
task: the task event an --until predicate was met by
guest event a stop the guest asked for, such as a task switch
matched <n> with --when, how many dispatches it applied to
the rest of the iterations ran free
Stopped at the breakpoint, watchpoint or catchpoint hit, and tid

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
2
3
when /test:on       mode step,fast   fast=1:100k step=1:200
when /test:kernel task-sched hold
else mode fast

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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
when <predicate>
apply the clause only while the predicate holds. A
predicate is [subject:]state. The state is on, kernel,
off, syscall[=name] or int[=vec]. The subject is /path,
tid=N, tgid=N, cgroup=P, comm=NAME or none for any
focused task.
vcpu=N[,N] ANDs a vCPU set onto it.
mode <mode>[N],...
the modes to draw among: fast, step, step-into, free, fence
or keep. A mode may carry the limit it draws when it wins,
<mode>=<span>, as in mode step[3],fast[1] step=1:200.
free takes no limit.
vtime-rate <rate>[N],...
the machine-time rate: a number N, a fraction N/D, a span
of numerators such as 1:10, or keep.
vtime-add <duration>[N],...
time added to the clock before each dispatch: a duration
such as 500 or 10us, a span such as 10us:2ms, or keep.
task-sched <mark>[N],...
a mark for the task on the drawn vCPU: keep, hold, yield,
drain, drain-all.
task-int <int>[N],...
an interrupt for that task: none or preempt. This axis has
no keep: none is its do-nothing choice.
task-slice <choice>[N],...
that task's time slice: keep, default, a duration or a
range of durations, as in keep,default,10us:600us.
task-pin [<tid>=]<set>[N],...
where a task is placed when it next wakes, each choice a
set of vCPUs: 1-3 is all three, 1,2,3 is three choices of
one, free is any vCPU and none is no vCPU, which stops it
running. A placement policy, not confinement: a task
already queued elsewhere keeps that vCPU until it wakes.
<tid>= names the task. Without it, the task on the
drawn vCPU is placed. none requires <tid>=.
timer-slack <duration>
how late a timer may be in code that takes no exit, drawn
per dispatch: a duration or a span such as 0:20ms, at
most 1s. keep repeats the last slack drawn; with none
drawn yet, the run's own --timer-slack.
irq-delay [<target>=]<duration>,...
how long each interrupt is held before it is injected,
drawn per interrupt: a duration or a span such as 0:2ms,
at most 1s. A target is timer, ipi, init, blk, rng,
console, serial, keyboard, device or all. A bare span is
all. The most specific target wins. An interrupt never
overtakes one held before it on its line, its MSI vector,
or its vCPU's timer, IPI vector or INIT and SIPI.
vtime-io-cost <duration>[N],...
what an I/O, MMIO or hypercall exit costs on the clock,
drawn per dispatch: a duration such as 2000 or 2us, a span
such as 1us:20us, or keep; 1ns to 1s. The run's own cost
comes back when the run ends.
vtime-rdtsc-cost <duration>[N],...
what an RDTSC costs, the same way. Without it the RDTSC
cost follows the I/O cost.
vtime-pause-cost <duration>[N],...
what each PAUSE of a spin loop costs, the same way.

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
2
3
4
5
machine plan [-h] [--limit span] [--backstop-limit n] [--retry n] [--strategy name]
[--seed n] [--vcpu span] [--iters span] [--until predicate]
[--within duration] [--irqblk] [--rdtsc-exit] [--no-idle-skip]
[--auto-checkpoints n]
run file
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
2
3
machine plan run1 plan.txt                       run the clauses of plan.txt
machine plan run1 plan.txt --iters 100 --seed 7 100 iterations, seed 7
machine plan run1 - plan from standard input

Prints:

1
2
3
4
5
tally         one line for each clause, numbered from 1
<choice>×<n> how many times that choice of an axis was drawn
matched <n> how many dispatches the clause applied to
marks held tasks a clause held that are still held at the end
then what run prints

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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
machine control run1                            open the prompt for run1
machine control run1 -c /help list the slash commands
machine control run1 -c '/help output' the help of /output
machine control run1 -c /f@100 run 100 iterations fast
machine control run1 -c '/checkpoint name cp1' create checkpoint cp1
machine control run1 -c '/rewind to ^cp1' put run1 back at cp1
machine control run1 -c '/send ls -la' type ls -la and Enter
machine control run1 -c '/send "a;b"' send a;b and Enter
machine control run1 -c '/exec run ls -la /' execute ls -la /
machine control run1 -c '/exec run -c echo $0' a line for the shell
machine control run1 -c '/exec start sleep 5' send it, get its id
machine control run1 -c /exec the processes of run1
machine control run1 -c '/fs ls / at ^cp1' the disk's files at cp1
machine control run1 -c '/f;/d' run, then dump
machine control log run1 the commands issued to run1
machine control log run1 --plain the commands alone

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
2
3
4
machine wait --for running run1               until run1 runs
machine wait --for stopped run1 until it stops
machine wait --for 'entry>=500' run1 until it reaches entry 500
machine --timeout 60 wait --for stopped run1 give up after 60 s

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
2
machine cancel run1         cancel what run1 is running
machine cancel run1 --soft at the end of its dispatch

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
2
3
machine replay [-h] [--to point [point ...]] [--trace] [--retry n] [--limit-margin n]
[--instr-margin n]
run [line]
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
2
3
4
5
6
machine replay try2                        replay the parent's entries
machine replay try2 --to '#300' replay up to entry 300
machine replay try2 --to ^cp2 replay up to checkpoint cp2
machine replay try2 run1 --to '#420' replay the line to run1
machine replay try2 --limit-margin 100 100 branches short of each stop
machine replay try2 --instr-margin 100000 100,000 instructions short

Prints:

1
2
3
4
text          Replayed <n> entries to entry <id>. Converged.
then the last dispatch, as run prints it
json converged entry_id replayed diverged result misses
nothing left Nothing to replay: already at entry <id>

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
2
machine play [-h] [-n range] [--include type [type ...]] [--exclude type [type ...]]
run [line]
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
2
machine play run1 -n 295:300  play entries 295 to 300 of run1
machine play try2 run1 play run1's entries on try2

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
2
3
machine diff try2                   compare try2 with the run it replayed
machine diff try2 --show code,regs include code and registers
machine diff try2 run1 compare try2 with run1 instead

See also: