xref: /aosp_15_r20/art/tools/bisection_search/README.md (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard WorkerBisection Bug Search
2*795d594fSAndroid Build Coastguard Worker====================
3*795d594fSAndroid Build Coastguard Worker
4*795d594fSAndroid Build Coastguard WorkerBisection Bug Search is a tool for finding compiler optimizations bugs. It
5*795d594fSAndroid Build Coastguard Workeraccepts a program which exposes a bug by producing incorrect output and expected
6*795d594fSAndroid Build Coastguard Workeroutput for the program. It then attempts to narrow down the issue to a single
7*795d594fSAndroid Build Coastguard Workermethod and optimization pass under the assumption that interpreter is correct.
8*795d594fSAndroid Build Coastguard Worker
9*795d594fSAndroid Build Coastguard WorkerGiven methods in order M0..Mn finds smallest i such that compiling Mi and
10*795d594fSAndroid Build Coastguard Workerinterpreting all other methods produces incorrect output. Then, given ordered
11*795d594fSAndroid Build Coastguard Workeroptimization passes P0..Pl, finds smallest j such that compiling Mi with passes
12*795d594fSAndroid Build Coastguard WorkerP0..Pj-1 produces expected output and compiling Mi with passes P0..Pj produces
13*795d594fSAndroid Build Coastguard Workerincorrect output. Prints Mi and Pj.
14*795d594fSAndroid Build Coastguard Worker
15*795d594fSAndroid Build Coastguard WorkerHow to run Bisection Bug Search
16*795d594fSAndroid Build Coastguard Worker===============================
17*795d594fSAndroid Build Coastguard Worker
18*795d594fSAndroid Build Coastguard WorkerThere are two supported invocation modes:
19*795d594fSAndroid Build Coastguard Worker
20*795d594fSAndroid Build Coastguard Worker1. Regular invocation, dalvikvm command is constructed internally:
21*795d594fSAndroid Build Coastguard Worker
22*795d594fSAndroid Build Coastguard Worker        ./bisection_search.py -cp classes.dex --expected-output out_int --class Test
23*795d594fSAndroid Build Coastguard Worker
24*795d594fSAndroid Build Coastguard Worker2. Raw-cmd invocation, dalvikvm command is accepted as an argument.
25*795d594fSAndroid Build Coastguard Worker
26*795d594fSAndroid Build Coastguard Worker   Extra dalvikvm arguments will be placed on second position in the command
27*795d594fSAndroid Build Coastguard Worker   by default. {ARGS} tag can be used to specify a custom position.
28*795d594fSAndroid Build Coastguard Worker
29*795d594fSAndroid Build Coastguard Worker   If used in device mode, the command has to exec a dalvikvm instance. Bisection
30*795d594fSAndroid Build Coastguard Worker   will fail if pid of the process started by raw-cmd is different than pid of runtime.
31*795d594fSAndroid Build Coastguard Worker
32*795d594fSAndroid Build Coastguard Worker        ./bisection_search.py --raw-cmd='run.sh -cp classes.dex Test' --expected-retcode SUCCESS
33*795d594fSAndroid Build Coastguard Worker        ./bisection_search.py --raw-cmd='/bin/sh art {ARGS} -cp classes.dex Test' --expected-retcode SUCCESS
34*795d594fSAndroid Build Coastguard Worker
35*795d594fSAndroid Build Coastguard WorkerHelp:
36*795d594fSAndroid Build Coastguard Worker
37*795d594fSAndroid Build Coastguard Worker    bisection_search.py [-h] [-cp CLASSPATH] [--class CLASSNAME] [--lib LIB]
38*795d594fSAndroid Build Coastguard Worker                             [--dalvikvm-option [OPT [OPT ...]]] [--arg [ARG [ARG ...]]]
39*795d594fSAndroid Build Coastguard Worker                             [--image IMAGE] [--raw-cmd RAW_CMD]
40*795d594fSAndroid Build Coastguard Worker                             [--64] [--device] [--device-serial DEVICE_SERIAL]
41*795d594fSAndroid Build Coastguard Worker                             [--expected-output EXPECTED_OUTPUT]
42*795d594fSAndroid Build Coastguard Worker                             [--expected-retcode {SUCCESS,TIMEOUT,ERROR}]
43*795d594fSAndroid Build Coastguard Worker                             [--check-script CHECK_SCRIPT] [--logfile LOGFILE] [--cleanup]
44*795d594fSAndroid Build Coastguard Worker                             [--timeout TIMEOUT] [--verbose]
45*795d594fSAndroid Build Coastguard Worker
46*795d594fSAndroid Build Coastguard Worker    Tool for finding compiler bugs. Either --raw-cmd or both -cp and --class are required.
47*795d594fSAndroid Build Coastguard Worker
48*795d594fSAndroid Build Coastguard Worker    optional arguments:
49*795d594fSAndroid Build Coastguard Worker      -h, --help                                  show this help message and exit
50*795d594fSAndroid Build Coastguard Worker
51*795d594fSAndroid Build Coastguard Worker    dalvikvm command options:
52*795d594fSAndroid Build Coastguard Worker      -cp CLASSPATH, --classpath CLASSPATH        classpath
53*795d594fSAndroid Build Coastguard Worker      --class CLASSNAME                           name of main class
54*795d594fSAndroid Build Coastguard Worker      --lib LIB                                   lib to use, default: libart.so
55*795d594fSAndroid Build Coastguard Worker      --dalvikvm-option [OPT [OPT ...]]           additional dalvikvm option
56*795d594fSAndroid Build Coastguard Worker      --arg [ARG [ARG ...]]                       argument passed to test
57*795d594fSAndroid Build Coastguard Worker      --image IMAGE                               path to image
58*795d594fSAndroid Build Coastguard Worker      --raw-cmd RAW_CMD                           bisect with this command, ignore other command options
59*795d594fSAndroid Build Coastguard Worker
60*795d594fSAndroid Build Coastguard Worker    bisection options:
61*795d594fSAndroid Build Coastguard Worker      --64                                        x64 mode
62*795d594fSAndroid Build Coastguard Worker      --device                                    run on device
63*795d594fSAndroid Build Coastguard Worker      --device-serial DEVICE_SERIAL               device serial number, implies --device
64*795d594fSAndroid Build Coastguard Worker      --expected-output EXPECTED_OUTPUT           file containing expected output
65*795d594fSAndroid Build Coastguard Worker      --expected-retcode {SUCCESS,TIMEOUT,ERROR}  expected normalized return code
66*795d594fSAndroid Build Coastguard Worker      --check-script CHECK_SCRIPT                 script comparing output and expected output
67*795d594fSAndroid Build Coastguard Worker      --logfile LOGFILE                           custom logfile location
68*795d594fSAndroid Build Coastguard Worker      --cleanup                                   clean up after bisecting
69*795d594fSAndroid Build Coastguard Worker      --timeout TIMEOUT                           if timeout seconds pass assume test failed
70*795d594fSAndroid Build Coastguard Worker      --verbose                                   enable verbose output
71