Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 1 | # 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 Omer | 7d8c19a | 2020-10-19 15:38:49 | [diff] [blame] | 9 | * [DexLimitSteps](Commands.md#DexLimitSteps) |
| 10 | * [DexLabel](Commands.md#DexLabel) |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 11 | * [DexWatch](Commands.md#DexWatch) |
Stephen Tozer | 0428d44 | 2021-12-01 13:00:22 | [diff] [blame] | 12 | * [DexDeclareAddress](Commands.md#DexDeclareAddress) |
Tom Weaver | c2c2be4 | 2021-05-25 11:47:16 | [diff] [blame] | 13 | * [DexDeclareFile](Commands.md#DexDeclareFile) |
Stephen Tozer | 6cf6917 | 2021-10-18 11:36:25 | [diff] [blame] | 14 | * [DexFinishTest](Commands.md#DexFinishTest) |
Jeremy Morse | 3a094d8 | 2022-01-10 11:22:51 | [diff] [blame] | 15 | * [DexCommandLine](Commands.md#DexCommandLine) |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 16 | |
| 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 |
| 51 | Expect to see a given program `state` a certain number of `times`. |
| 52 | |
| 53 | For every debugger step the reported state is compared with the expected state. |
| 54 | To 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 |
| 59 | with the fields shown above, or a string representing its value. In either |
| 60 | case, 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 |
| 76 | Expect to see a particular step `kind` a number of `times` while stepping |
| 77 | through the program. |
| 78 | |
| 79 | `kind` must be one of: |
| 80 | |
| 81 | `FUNC`: The first step into a function which is defined in the test |
| 82 | directory.</br> |
| 83 | `FUNC_EXTERNAL`: A step over a function which is not defined in the test |
| 84 | directory.</br> |
| 85 | `FUNC_UNKNOWN`: The first step over a function an unknown definition |
| 86 | location.</br> |
| 87 | `VERTICAL_FORWARD`: A step onto a line after the previous step line in this |
| 88 | frame.</br> |
| 89 | `VERTICAL_BACKWARD`: A step onto a line before the previous step line in |
| 90 | this frame.</br> |
| 91 | `HORIZONTAL_FORWARD`: A step forward on the same line as the previous step in |
| 92 | this frame.</br> |
| 93 | `HORIZONTAL_BACKWARD`: A step backward on the same line as the previous step |
| 94 | in this frame.</br> |
| 95 | `SAME`: A step onto the same line and column as the previous step in this |
| 96 | frame.</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 |
| 110 | Expect 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 |
| 137 | Expect the expression `expr` to evaluate be evaluated and have each evaluation's |
| 138 | type 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 Tozer | 30bb659 | 2022-04-28 14:01:28 | [diff] [blame] | 147 | [,**on_line][,**require_in_order=True][,**float_range]) |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 148 | |
| 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 Tozer | 30bb659 | 2022-04-28 14:01:28 | [diff] [blame] | 162 | 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 Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 165 | |
| 166 | ### Description |
| 167 | Expect the expression `expr` to evaluate to the list of `values` |
| 168 | sequentially. |
| 169 | |
| 170 | ### Heuristic |
| 171 | [TODO] |
| 172 | |
| 173 | |
| 174 | --- |
| 175 | ## DexUnreachable |
Jeremy Morse | 0f92c11 | 2022-01-10 12:11:15 | [diff] [blame] | 176 | DexUnreachable([, **from_line=1][,**to_line=Max][,**on_line]) |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 177 | |
| 178 | ### Description |
Jeremy Morse | 0f92c11 | 2022-01-10 12:11:15 | [diff] [blame] | 179 | Expect 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 |
| 181 | specified line(s) are not stepped on. |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 182 | |
| 183 | ### Heuristic |
| 184 | [TODO] |
| 185 | |
| 186 | |
| 187 | ---- |
Tom Weaver | c6aa829 | 2020-06-05 11:53:56 | [diff] [blame] | 188 | ## DexLimitSteps |
OCHyams | e35a549 | 2021-05-17 08:07:46 | [diff] [blame] | 189 | DexLimitSteps([expr, *values][, **from_line=1][,**to_line=Max] |
OCHyams | 469833f | 2021-05-21 11:43:13 | [diff] [blame] | 190 | [,**on_line][,**hit_count]) |
Tom Weaver | c6aa829 | 2020-06-05 11:53:56 | [diff] [blame] | 191 | |
| 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. |
OCHyams | 469833f | 2021-05-21 11:43:13 | [diff] [blame] | 203 | hit_count (int): If provided, limit the number of times the command |
| 204 | triggers. |
Tom Weaver | c6aa829 | 2020-06-05 11:53:56 | [diff] [blame] | 205 | |
| 206 | ### Description |
OCHyams | e35a549 | 2021-05-17 08:07:46 | [diff] [blame] | 207 | Define a limited stepping range that may be predicated on a condition. When the |
| 208 | leading line is stepped on and any condition '(expr) == (values[n])' is true or |
| 209 | there are no conditions, set a range of temporary breakpoints within the test |
OCHyams | 469833f | 2021-05-21 11:43:13 | [diff] [blame] | 210 | file defined by the range 'from_line' and 'to_line' or 'on_line'. This only |
| 211 | happens 'hit_count' number of times if the argument is provided. |
Tom Weaver | c6aa829 | 2020-06-05 11:53:56 | [diff] [blame] | 212 | |
| 213 | The condition is only evaluated on the line 'from_line' or 'on_line'. If the |
OCHyams | e35a549 | 2021-05-17 08:07:46 | [diff] [blame] | 214 | condition is not true at the start of the range, or that line is never stepped |
| 215 | onto, the whole range is ignored. |
Tom Weaver | c6aa829 | 2020-06-05 11:53:56 | [diff] [blame] | 216 | |
| 217 | DexLimitSteps commands are useful for reducing the amount of steps gathered in |
| 218 | large test cases that would normally take much longer to complete. |
| 219 | |
| 220 | ---- |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 221 | ## DexLabel |
OCHyams | 487ab53 | 2021-04-23 11:00:16 | [diff] [blame] | 222 | DexLabel(name [, **on_line]) |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 223 | |
| 224 | Args: |
| 225 | name (str): A unique name for this line. |
| 226 | |
OCHyams | 487ab53 | 2021-04-23 11:00:16 | [diff] [blame] | 227 | Keyword args: |
| 228 | on_line (int): Specify a line number to label. |
| 229 | |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 230 | ### Description |
OCHyams | 487ab53 | 2021-04-23 11:00:16 | [diff] [blame] | 231 | Name the line this command is found on or 'on_line' if it is provided. Line |
OCHyams | 723a8ae | 2021-05-21 07:35:17 | [diff] [blame] | 232 | names can be converted to line numbers with the `ref(str)` function. For |
| 233 | example, `DexExpectWatchValues(..., on_line=ref('my_line_name'))`. Use |
| 234 | arithmetic 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 Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 239 | |
| 240 | ### Heuristic |
| 241 | This command does not contribute to the heuristic score. |
| 242 | |
Tom Weaver | c2c2be4 | 2021-05-25 11:47:16 | [diff] [blame] | 243 | ---- |
Stephen Tozer | 0428d44 | 2021-12-01 13:00:22 | [diff] [blame] | 244 | ## 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 |
| 259 | Declares a variable that can be used in DexExpectWatch- commands as an expected |
| 260 | value by using the `address(str[, int])` function. This is primarily |
| 261 | useful for checking the values of pointer variables, which are generally |
| 262 | determined at run-time (and so cannot be consistently matched by a hard-coded |
| 263 | expected value), but may be consistent relative to each other. An example use of |
| 264 | this 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 | |
| 272 | On the first line, we declare the name of our variable 'my_addr'. This name must |
| 273 | be unique (the same name cannot be declared twice), and attempting to reference |
| 274 | an undeclared variable with `address` will fail. The value of the address |
| 275 | variable will be assigned as the value of 'bar' when line 12 is first stepped |
| 276 | on. |
| 277 | |
| 278 | On lines 2-4, we use the `address` function to refer to our variable. The first |
| 279 | usage occurs on line 10, before the line where 'my_addr' is assigned its value; |
| 280 | this is a valid use, as we assign the address value and check for correctness |
| 281 | after gathering all debug information for the test. Thus the first test command |
| 282 | will pass if 'foo' on line 10 has the same value as 'bar' on line 12. |
| 283 | |
| 284 | The second command will pass iff 'bar' is available at line 12 - even if the |
| 285 | variable and lines are identical in DexDeclareAddress and DexExpectWatchValue, |
| 286 | the latter will still expect a valid value. Similarly, if the variable for a |
| 287 | DexDeclareAddress command is not available at the given line, any test against |
| 288 | that address will fail. |
| 289 | |
| 290 | The `address` function also accepts an optional integer argument representing an |
| 291 | offset (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 |
| 293 | means that we expect `baz == bar + 16`. |
| 294 | |
| 295 | ### Heuristic |
| 296 | This command does not contribute to the heuristic score. |
| 297 | |
| 298 | ---- |
Tom Weaver | c2c2be4 | 2021-05-25 11:47:16 | [diff] [blame] | 299 | ## 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 |
| 307 | Set the path attribute of all commands from this point in the test onwards. |
| 308 | The new path holds until the end of the test file or until a new DexDeclareFile |
| 309 | command is encountered. Used in conjunction with .dex files, DexDeclareFile can |
| 310 | be used to write your dexter commands in a separate test file avoiding inlined |
| 311 | Dexter commands mixed with test source. |
| 312 | |
| 313 | ### Heuristic |
| 314 | This command does not contribute to the heuristic score. |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 315 | |
Stephen Tozer | 6cf6917 | 2021-10-18 11:36:25 | [diff] [blame] | 316 | ---- |
| 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 |
| 332 | Defines a point at which Dexter will exit out of the debugger without waiting |
| 333 | for the program to finish. This is primarily useful for testing a program that |
| 334 | either does not automatically terminate or would otherwise continue for a long |
| 335 | time after all test commands have finished. |
| 336 | |
| 337 | The command will trigger when the line 'on_line' is stepped on and either the |
| 338 | condition '(expr) == (values[n])' is true or there are no conditions. If the |
| 339 | optional argument 'hit_count' is provided, then the command will not trigger |
| 340 | for the first 'hit_count' times the line and condition are hit. |
| 341 | |
| 342 | ### Heuristic |
| 343 | This command does not contribute to the heuristic score. |
| 344 | |
Jeremy Morse | 3a094d8 | 2022-01-10 11:22:51 | [diff] [blame] | 345 | ---- |
| 346 | ## DexCommandLine |
| 347 | DexCommandLine(command_line) |
| 348 | |
| 349 | Args: |
| 350 | command_line (list): List of strings that form the command line. |
| 351 | |
| 352 | ### Description |
| 353 | Specifies the command line with which to launch the test. The arguments will |
| 354 | be appended to the default command line, i.e. the path to the compiled binary, |
| 355 | and will be passed to the program under test. |
| 356 | |
| 357 | This command does not contribute to any part of the debug experience testing or |
| 358 | runtime instrumentation -- it's only for communicating arguments to the program |
| 359 | under test. |
| 360 | |
| 361 | ### Heuristic |
| 362 | This command does not contribute to the heuristic score. |
| 363 | |
Jeremy Morse | 984fad2 | 2019-10-31 16:51:53 | [diff] [blame] | 364 | --- |
| 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 |
| 373 | line this command is found on. |
| 374 | |
| 375 | ### Heuristic |
| 376 | [Deprecated] |