blob: d5bd999f5adf0273006a29cd57823900ee9da5a4 [file] [log] [blame] [view]
Jeremy Morse984fad22019-10-31 16:51:531# Dexter commands
2
3* [DexExpectProgramState](Commands.md#DexExpectProgramState)
4* [DexExpectStepKind](Commands.md#DexExpectStepKind)
5* [DexExpectStepOrder](Commands.md#DexExpectStepOrder)
6* [DexExpectWatchType](Commands.md#DexExpectWatchType)
7* [DexExpectWatchValue](Commands.md#DexExpectWatchValue)
8* [DexUnreachable](Commands.md#DexUnreachable)
Nabeel Omer7d8c19a2020-10-19 15:38:499* [DexLimitSteps](Commands.md#DexLimitSteps)
10* [DexLabel](Commands.md#DexLabel)
Jeremy Morse984fad22019-10-31 16:51:5311* [DexWatch](Commands.md#DexWatch)
Stephen Tozer0428d442021-12-01 13:00:2212* [DexDeclareAddress](Commands.md#DexDeclareAddress)
Tom Weaverc2c2be42021-05-25 11:47:1613* [DexDeclareFile](Commands.md#DexDeclareFile)
Stephen Tozer6cf69172021-10-18 11:36:2514* [DexFinishTest](Commands.md#DexFinishTest)
Jeremy Morse3a094d82022-01-10 11:22:5115* [DexCommandLine](Commands.md#DexCommandLine)
Jeremy Morse984fad22019-10-31 16:51:5316
17---
18## DexExpectProgramState
19 DexExpectProgramState(state [,**times])
20
21 Args:
22 state (dict): { 'frames': [
23 {
24 # StackFrame #
25 'function': name (str),
26 'is_inlined': bool,
27 'location': {
28 # SourceLocation #
29 'lineno': int,
30 'path': str,
31 'column': int,
32 },
33 'watches': {
34 expr (str): value (str),
35 expr (str): {
36 'value': str,
37 'type_name': str,
38 'could_evaluate': bool,
39 'is_optimized_away': bool,
40 'is_irretrievable': bool,
41 }
42 },
43 }
44 ]}
45
46 Keyword args:
47 times (int): Minimum number of times this state pattern is expected to
48 be seen. Defaults to 1. Can be 0.
49
50### Description
51Expect to see a given program `state` a certain number of `times`.
52
53For every debugger step the reported state is compared with the expected state.
54To consider the states a match:
55
56* The `SourceLocation` must match in both states. Omitted fields in the
57`SourceLocation` dictionary are ignored; they always match.
58* Each `expr` in `watches` in the expected state can either be a dictionary
59with the fields shown above, or a string representing its value. In either
60case, the actual value of `expr` in the debugger must match.
61* The function name and inline status are not considered.
62
63### Heuristic
64[TODO]
65
66
67---
68## DexExpectStepKind
69 DexExpectStepKind(kind, times)
70
71 Args:
72 kind (str): Expected step kind.
73 times (int): Expected number of encounters.
74
75### Description
76Expect to see a particular step `kind` a number of `times` while stepping
77through the program.
78
79`kind` must be one of:
80
81`FUNC`: The first step into a function which is defined in the test
82directory.</br>
83`FUNC_EXTERNAL`: A step over a function which is not defined in the test
84directory.</br>
85`FUNC_UNKNOWN`: The first step over a function an unknown definition
86location.</br>
87`VERTICAL_FORWARD`: A step onto a line after the previous step line in this
88frame.</br>
89`VERTICAL_BACKWARD`: A step onto a line before the previous step line in
90this frame.</br>
91`HORIZONTAL_FORWARD`: A step forward on the same line as the previous step in
92this frame.</br>
93`HORIZONTAL_BACKWARD`: A step backward on the same line as the previous step
94in this frame.</br>
95`SAME`: A step onto the same line and column as the previous step in this
96frame.</br>
97
98### Heuristic
99[TODO]
100
101
102---
103## DexExpectStepOrder
104 DexExpectStepOrder(*order)
105
106 Arg list:
107 order (int): One or more indices.
108
109### Description
110Expect the line every `DexExpectStepOrder` is found on to be stepped on in
111`order`. Each instance must have a set of unique ascending indices.
112
113### Heuristic
114[TODO]
115
116
117---
118## DexExpectWatchType
119 DexExpectWatchType(expr, *types [,**from_line=1][,**to_line=Max]
120 [,**on_line][,**require_in_order=True])
121
122 Args:
123 expr (str): expression to evaluate.
124
125 Arg list:
126 types (str): At least one expected type. NOTE: string type.
127
128 Keyword args:
129 from_line (int): Evaluate the expression from this line. Defaults to 1.
130 to_line (int): Evaluate the expression to this line. Defaults to end of
131 source.
132 on_line (int): Only evaluate the expression on this line. If provided,
133 this overrides from_line and to_line.
134 require_in_order (bool): If False the values can appear in any order.
135
136### Description
137Expect the expression `expr` to evaluate be evaluated and have each evaluation's
138type checked against the list of `types`
139
140### Heuristic
141[TODO]
142
143
144---
145## DexExpectWatchValue
146 DexExpectWatchValue(expr, *values [,**from_line=1][,**to_line=Max]
Stephen Tozer30bb6592022-04-28 14:01:28147 [,**on_line][,**require_in_order=True][,**float_range])
Jeremy Morse984fad22019-10-31 16:51:53148
149 Args:
150 expr (str): expression to evaluate.
151
152 Arg list:
153 values (str): At least one expected value. NOTE: string type.
154
155 Keyword args:
156 from_line (int): Evaluate the expression from this line. Defaults to 1.
157 to_line (int): Evaluate the expression to this line. Defaults to end of
158 source.
159 on_line (int): Only evaluate the expression on this line. If provided,
160 this overrides from_line and to_line.
161 require_in_order (bool): If False the values can appear in any order.
Stephen Tozer30bb6592022-04-28 14:01:28162 float_range (float): If provided, `values` must be floats, and will
163 match an actual value if they are within `float_range` of each other.
164
Jeremy Morse984fad22019-10-31 16:51:53165
166### Description
167Expect the expression `expr` to evaluate to the list of `values`
168sequentially.
169
170### Heuristic
171[TODO]
172
173
174---
175## DexUnreachable
Jeremy Morse0f92c112022-01-10 12:11:15176 DexUnreachable([, **from_line=1][,**to_line=Max][,**on_line])
Jeremy Morse984fad22019-10-31 16:51:53177
178### Description
Jeremy Morse0f92c112022-01-10 12:11:15179Expect the source line this is found on will never be stepped on to. If either
180'on_line' or both 'from_line' and 'to_line' are specified, checks that the
181specified line(s) are not stepped on.
Jeremy Morse984fad22019-10-31 16:51:53182
183### Heuristic
184[TODO]
185
186
187----
Tom Weaverc6aa8292020-06-05 11:53:56188## DexLimitSteps
OCHyamse35a5492021-05-17 08:07:46189 DexLimitSteps([expr, *values][, **from_line=1][,**to_line=Max]
OCHyams469833f2021-05-21 11:43:13190 [,**on_line][,**hit_count])
Tom Weaverc6aa8292020-06-05 11:53:56191
192 Args:
193 expr (str): variable or value to compare.
194
195 Arg list:
196 values (str): At least one potential value the expr may evaluate to.
197
198 Keyword args:
199 from_line (int): Define the start of the limited step range.
200 to_line (int): Define the end of the limited step range.
201 on_line (int): Define a range with length 1 starting and ending on the
202 same line.
OCHyams469833f2021-05-21 11:43:13203 hit_count (int): If provided, limit the number of times the command
204 triggers.
Tom Weaverc6aa8292020-06-05 11:53:56205
206### Description
OCHyamse35a5492021-05-17 08:07:46207Define a limited stepping range that may be predicated on a condition. When the
208leading line is stepped on and any condition '(expr) == (values[n])' is true or
209there are no conditions, set a range of temporary breakpoints within the test
OCHyams469833f2021-05-21 11:43:13210file defined by the range 'from_line' and 'to_line' or 'on_line'. This only
211happens 'hit_count' number of times if the argument is provided.
Tom Weaverc6aa8292020-06-05 11:53:56212
213The condition is only evaluated on the line 'from_line' or 'on_line'. If the
OCHyamse35a5492021-05-17 08:07:46214condition is not true at the start of the range, or that line is never stepped
215onto, the whole range is ignored.
Tom Weaverc6aa8292020-06-05 11:53:56216
217DexLimitSteps commands are useful for reducing the amount of steps gathered in
218large test cases that would normally take much longer to complete.
219
220----
Jeremy Morse984fad22019-10-31 16:51:53221## DexLabel
OCHyams487ab532021-04-23 11:00:16222 DexLabel(name [, **on_line])
Jeremy Morse984fad22019-10-31 16:51:53223
224 Args:
225 name (str): A unique name for this line.
226
OCHyams487ab532021-04-23 11:00:16227 Keyword args:
228 on_line (int): Specify a line number to label.
229
Jeremy Morse984fad22019-10-31 16:51:53230### Description
OCHyams487ab532021-04-23 11:00:16231Name the line this command is found on or 'on_line' if it is provided. Line
OCHyams723a8ae2021-05-21 07:35:17232names can be converted to line numbers with the `ref(str)` function. For
233example, `DexExpectWatchValues(..., on_line=ref('my_line_name'))`. Use
234arithmetic operators to get offsets from labels:
235
236 DexExpectWatchValues(..., on_line=ref('my_line_name') + 3)
237 DexExpectWatchValues(..., on_line=ref('my_line_name') - 5)
238
Jeremy Morse984fad22019-10-31 16:51:53239
240### Heuristic
241This command does not contribute to the heuristic score.
242
Tom Weaverc2c2be42021-05-25 11:47:16243----
Stephen Tozer0428d442021-12-01 13:00:22244## DexDeclareAddress
245 DexDeclareAddress(declared_address, expr, **on_line[, **hit_count])
246
247 Args:
248 declared_address (str): The unique name of an address, which can be used
249 in DexExpectWatch-commands.
250 expr (str): An expression to evaluate to provide the value of this
251 address.
252 on_line (int): The line at which the value of the expression will be
253 assigned to the address.
254 hit_count (int): If provided, reads the value of the source expression
255 after the line has been stepped onto the given number
256 of times ('hit_count = 0' gives default behaviour).
257
258### Description
259Declares a variable that can be used in DexExpectWatch- commands as an expected
260value by using the `address(str[, int])` function. This is primarily
261useful for checking the values of pointer variables, which are generally
262determined at run-time (and so cannot be consistently matched by a hard-coded
263expected value), but may be consistent relative to each other. An example use of
264this command is as follows, using a set of pointer variables "foo", "bar", and
265"baz":
266
267 DexDeclareAddress('my_addr', 'bar', on_line=12)
268 DexExpectWatchValue('foo', address('my_addr'), on_line=10)
269 DexExpectWatchValue('bar', address('my_addr'), on_line=12)
270 DexExpectWatchValue('baz', address('my_addr', 16), on_line=14)
271
272On the first line, we declare the name of our variable 'my_addr'. This name must
273be unique (the same name cannot be declared twice), and attempting to reference
274an undeclared variable with `address` will fail. The value of the address
275variable will be assigned as the value of 'bar' when line 12 is first stepped
276on.
277
278On lines 2-4, we use the `address` function to refer to our variable. The first
279usage occurs on line 10, before the line where 'my_addr' is assigned its value;
280this is a valid use, as we assign the address value and check for correctness
281after gathering all debug information for the test. Thus the first test command
282will pass if 'foo' on line 10 has the same value as 'bar' on line 12.
283
284The second command will pass iff 'bar' is available at line 12 - even if the
285variable and lines are identical in DexDeclareAddress and DexExpectWatchValue,
286the latter will still expect a valid value. Similarly, if the variable for a
287DexDeclareAddress command is not available at the given line, any test against
288that address will fail.
289
290The `address` function also accepts an optional integer argument representing an
291offset (which may be negative) to be applied to the address value, so
292`address('my_addr', 16)` resolves to `my_addr + 16`. In the above example, this
293means that we expect `baz == bar + 16`.
294
295### Heuristic
296This command does not contribute to the heuristic score.
297
298----
Tom Weaverc2c2be42021-05-25 11:47:16299## DexDeclareFile
300 DexDeclareFile(declared_file)
301
302 Args:
303 name (str): A declared file path for which all subsequent commands
304 will have their path attribute set too.
305
306### Description
307Set the path attribute of all commands from this point in the test onwards.
308The new path holds until the end of the test file or until a new DexDeclareFile
309command is encountered. Used in conjunction with .dex files, DexDeclareFile can
310be used to write your dexter commands in a separate test file avoiding inlined
311Dexter commands mixed with test source.
312
313### Heuristic
314This command does not contribute to the heuristic score.
Jeremy Morse984fad22019-10-31 16:51:53315
Stephen Tozer6cf69172021-10-18 11:36:25316----
317## DexFinishTest
318 DexFinishTest([expr, *values], **on_line[, **hit_count=0])
319
320 Args:
321 expr (str): variable or value to compare.
322
323 Arg list:
324 values (str): At least one potential value the expr may evaluate to.
325
326 Keyword args:
327 on_line (int): Define the line on which this command will be triggered.
328 hit_count (int): If provided, triggers this command only after the line
329 and condition have been hit the given number of times.
330
331### Description
332Defines a point at which Dexter will exit out of the debugger without waiting
333for the program to finish. This is primarily useful for testing a program that
334either does not automatically terminate or would otherwise continue for a long
335time after all test commands have finished.
336
337The command will trigger when the line 'on_line' is stepped on and either the
338condition '(expr) == (values[n])' is true or there are no conditions. If the
339optional argument 'hit_count' is provided, then the command will not trigger
340for the first 'hit_count' times the line and condition are hit.
341
342### Heuristic
343This command does not contribute to the heuristic score.
344
Jeremy Morse3a094d82022-01-10 11:22:51345----
346## DexCommandLine
347 DexCommandLine(command_line)
348
349 Args:
350 command_line (list): List of strings that form the command line.
351
352### Description
353Specifies the command line with which to launch the test. The arguments will
354be appended to the default command line, i.e. the path to the compiled binary,
355and will be passed to the program under test.
356
357This command does not contribute to any part of the debug experience testing or
358runtime instrumentation -- it's only for communicating arguments to the program
359under test.
360
361### Heuristic
362This command does not contribute to the heuristic score.
363
Jeremy Morse984fad22019-10-31 16:51:53364---
365## DexWatch
366 DexWatch(*expressions)
367
368 Arg list:
369 expressions (str): `expression` to evaluate on this line.
370
371### Description
372[Deprecated] Evaluate each given `expression` when the debugger steps onto the
373line this command is found on.
374
375### Heuristic
376[Deprecated]