• Home
Name Date Size #Lines LOC

..--

android/03-May-2024-767412

common/03-May-2024-327172

cros_pkg/03-May-2024-875543

full_bisect_test/03-May-2024-864556

ndk/03-May-2024-422199

sysroot_wrapper/03-May-2024-581314

test/03-May-2024-1,305892

.gitignoreD03-May-202499 86

MAINTENANCED03-May-20245.9 KiB12398

README.bisect.mdD03-May-20248.5 KiB250187

README.pass_bisect.mdD03-May-20242.6 KiB8462

README.testing.mdD03-May-20242.3 KiB9569

__init__.pyD03-May-2024189 50

binary_search_perforce.pyD03-May-202416.1 KiB514411

binary_search_state.pyD03-May-202432.4 KiB901694

bisect_driver.pyD03-May-202413.5 KiB419290

common.pyD03-May-20248.5 KiB297233

compiler_wrapper.pyD03-May-20242.1 KiB6940

pass_mapping.pyD03-May-20241.2 KiB3521

run_bisect.pyD03-May-202412.9 KiB398317

run_bisect_tests.pyD03-May-20245.2 KiB178123

README.bisect.md

1# `run_bisect.py`
2
3`run_bisect.py` is a wrapper around the general purpose
4`binary_search_state.py`. It provides a user friendly interface for
5bisecting various compilation errors.  The 2 currently provided
6methods of bisecting are ChromeOS package and object bisection. Each
7method defines a default set of options to pass to
8`binary_search_state.py` and allow the user to override these defaults
9(see the "Overriding" section).
10
11Please note that all commands, examples, scripts, etc. are to be run from your
12chroot unless stated otherwise.
13
14## Bisection Methods
15
16### ChromeOS Package
17
18This method will bisect across all packages in a ChromeOS repository and find
19the offending packages (according to your test script). This method takes the
20following arguments:
21
22* board: The board to bisect on. For example: daisy, falco, etc.
23* remote: The IP address of the physical machine you're using to test with.
24
25By default the ChromeOS package method will do a simple interactive test that
26pings the machine and prompts the user if the machine is good.
27
281.  Setup: The ChromeOS package method requires that you have three build trees:
29
30    ```
31    /build/${board}.bad  - The build tree for your "bad" build
32    /build/${board}.good - The build tree for your "good" build
33    /build/${board}.work - A full copy of /build/${board}.bad
34    ```
35
361.  Cleanup: run_bisect.py does most cleanup for you, the only thing required by
37    the user is to cleanup all built images and the three build trees made in
38    `/build/`
39
401.  Default Arguments:
41
42    ```
43    --get_initial_items='cros_pkg/get_initial_items.sh'
44    --switch_to_good='cros_pkg/switch_to_good.sh'
45    --switch_to_bad='cros_pkg/switch_to_bad.sh'
46    --test_setup_script='cros_pkg/test_setup.sh'
47    --test_script='cros_pkg/interactive_test.sh'
48    --incremental
49    --prune
50    --file_args
51    ```
52
531.  Additional Documentation: See `./cros_pkg/README.cros_pkg_triage` for full
54    documentation of ChromeOS package bisection.
55
561.  Examples:
57
58    1.  Basic interactive test package bisection, on daisy board:
59
60        ```
61        ./run_bisect.py package daisy 172.17.211.184
62        ```
63
64    2.  Basic boot test package bisection, on daisy board:
65
66        ```
67        ./run_bisect.py package daisy 172.17.211.184 -t cros_pkg/boot_test.sh
68        ```
69
70### ChromeOS Object
71
72This method will bisect across all objects in a ChromeOS package and find
73the offending objects (according to your test script). This method takes the
74following arguments:
75
76* board: The board to bisect on. For example: daisy, falco, etc.
77* remote: The IP address of the physical machine you're using to test with.
78* package: The package to bisect with. For example: chromeos-chrome
79* dir: (Optional) the directory for your good/bad build trees. Defaults to
80       $BISECT_DIR or /tmp/sysroot_bisect. This value will set $BISECT_DIR
81       for all bisecting scripts.
82
83By default the ChromeOS object method will do a simple interactive test that
84pings the machine and prompts the user if the machine is good.
85
861.  Setup: The ChromeOS package method requires that you populate your good and
87    bad set of objects. `sysroot_wrapper` will automatically detect the
88    `BISECT_STAGE` variable and use this to populate emerged objects. Here is an
89    example:
90
91    ```
92    # Defaults to /tmp/sysroot_bisect
93    export BISECT_DIR="/path/to/where/you/want/to/store/builds/"
94
95    export BISECT_STAGE="POPULATE_GOOD"
96    ./switch_to_good_compiler.sh
97    emerge-${board} -C ${package_to_bisect}
98    emerge-${board} ${package_to_bisect}
99
100    export BISECT_STAGE="POPULATE_BAD"
101    ./switch_to_bad_compiler.sh
102    emerge-${board} -C {package_to_bisect}
103    emerge-${board} ${package_to_bisect}
104    ```
105
1061.  Cleanup: The user must clean up all built images and the populated object
107    files.
108
1091.  Default Arguments:
110
111    ```
112    --get_initial_items='sysroot_wrapper/get_initial_items.sh'
113    --switch_to_good='sysroot_wrapper/switch_to_good.sh'
114    --switch_to_bad='sysroot_wrapper/switch_to_bad.sh'
115    --test_setup_script='sysroot_wrapper/test_setup.sh'
116    --test_script='sysroot_wrapper/interactive_test.sh'
117    --noincremental
118    --prune
119    --file_args
120    ```
121
1221.  Additional Documentation: See `./sysroot_wrapper/README` for full
123    documentation of ChromeOS object file bisecting.
124
1251.  Examples:
126
127    1.  Basic interactive test object bisection, on daisy board for cryptohome
128        package: `./run_bisect.py object daisy 172.17.211.184 cryptohome`
129
130    2.  Basic boot test package bisection, on daisy board for cryptohome
131        package: `./run_bisect.py object daisy 172.17.211.184 cryptohome
132        --test_script=sysroot_wrapper/boot_test.sh`
133
134### Android object
135
136NOTE: Because this isn't a ChromeOS bisection tool, the concept of a
137      chroot doesn't exist. Just run this tool from a normal shell.
138
139This method will bisect across all objects in the Android source tree and
140find the offending objects (according to your test script). This method takes
141the following arguments:
142
143*   `android_src`: The location of your android source tree
144
145*   `num_jobs`: (Optional) The number of jobs to pass to make. This is dependent
146    on how many cores your machine has. A good number is probably somewhere
147    around 5 to 10.
148
149*   `device_id`: (Optional) The serial code for the device you are testing on.
150    This is used to determine which device should be used in case multiple
151    devices are plugged into your computer. You can get serial code for your
152    device by running "adb devices".
153
154*   `dir`: (Optional) the directory for your good/bad build trees. Defaults to
155    `$BISECT_DIR` or `~/ANDROID_BISECT/`. This value will set `$BISECT_DIR` for
156    all bisecting scripts.
157
158  By default the Android object method will do a simple interactive test that
159  pings the machine and prompts the user if the machine is good.
160
1611.  Setup: The Android object method requires that you populate your good and
162    bad set of objects. The Android compiler wrapper will automatically detect
163    the `BISECT_STAGE` variable and use this to populate emerged objects. Here
164    is an example:
165
166    ```
167    # Defaults to ~/ANDROID_BISECT/
168    export BISECT_DIR="/path/to/where/you/want/to/store/builds/"
169
170    export BISECT_STAGE="POPULATE_GOOD"
171    # Install the "good" compiler
172    ./switch_to_good_compiler.sh
173    make clean
174    make -j <your_preferred_number_of_jobs>
175
176    export BISECT_STAGE="POPULATE_BAD"
177    # Install the "bad" compiler
178    ./switch_to_bad_compiler.sh
179    make clean
180    make -j <your_preferred_number_of_jobs>
181    ```
182
1831.  Cleanup: The user must clean up all built images and the populated object
184    files.
185
1861.  Default Arguments:
187
188    ```
189    --get_initial_items='android/get_initial_items.sh'
190    --switch_to_good='android/switch_to_good.sh'
191    --switch_to_bad='android/switch_to_bad.sh'
192    --test_setup_script='android/test_setup.sh'
193    --test_script='android/interactive_test.sh'
194    --incremental
195    --prune
196    --file_args
197    ```
198
1991.  Additional Documentation: See `./android/README.android` for full
200    documentation of Android object file bisecting.
201
2021.  Examples:
203
204    1.  Basic interactive test android bisection, where the android source is at
205        ~/android_src: `./run_bisect.py android ~/android_src`
206
207    2. Basic boot test android bisection, where the android source is at
208       `~/android_src`, and 10 jobs will be used to build android:
209       `./run_bisect.py
210       android ~/android_src --num_jobs=10
211       --test_script=sysroot_wrapper/boot_test.sh`
212
213### Resuming
214
215`run_bisect.py` and `binary_search_state.py` offer the
216ability to resume a bisection in case it was interrupted by a
217SIGINT, power failure, etc. Every time the tool completes a
218bisection iteration its state is saved to disk (usually to the file
219`./bisect_driver.py.state`). If passed the --resume option, the tool
220it will automatically detect the state file and resume from the last
221completed iteration.
222
223### Overriding
224
225You can run `./run_bisect.py --help` or `./binary_search_state.py
226--help` for a full list of arguments that can be overriden. Here are
227a couple of examples:
228
229Example 1 (do boot test instead of interactive test):
230
231```
232./run_bisect.py package daisy 172.17.211.182 --test_script=cros_pkg/boot_test.sh
233```
234
235Example 2 (do package bisector system test instead of interactive test, this
236           is used to test the bisecting tool itself -- see comments in
237           hash_test.sh for more details):
238
239```
240./run_bisect.py package daisy 172.17.211.182 \
241    --test_script=common/hash_test.sh --test_setup_script=""
242```
243
244Example 3 (enable verbose mode, disable pruning, and disable verification):
245
246```
247./run_bisect.py package daisy 172.17.211.182
248      --verbose --prune=False --verify=False
249```
250

README.pass_bisect.md

1# Pass bisection
2
3This document describes a feature for the bisection tool, which provides
4pass and transformation level bisection for a bad object file.
5
6Before reading this document, please refer to README.bisect for general usage
7of the bisection tool.
8
9The benefit of using pass level bisection is:
10When building a bad object file, it can tell you which pass and transformation
11in the compiler caused the error.
12
13*Notice:* This tool will only work for LLVM/clang, since it is using options
14`-opt-bisect-limit` and `print-debug-counter` that only exist in LLVM.
15
16## Arguments
17
18All the required arguments in object-file-level bisection tool are still
19to be provided. In addition, you will need to add the following arguments:
20
211. `--pass_bisect`: enables pass level bisection
222. `--ir_diff`: enables output of IR differences
23
24Please refer to `--help` or the examples below for details about how to use
25them.
26
27## HOW TO USE: ChromeOS
28
29*TODO* - Future work: Currently this only works for Android.
30
31## HOW TO USE: Android
32
331.  Prerequisites: A general setup is still needed for Android, which means that
34    you need to populate good and bad set of objects with two versions of
35    compilers.
36
37    See the documentation in `README.bisect.md` for more detailed instructions.
38
391.  Pass/Transformation Bisection: If you do not wish to override the other
40    arguments, this command should be sufficient to do pass/transformation level
41    bisection:
42
43    ```
44    ./run_bisect.py android PATH_TO_ANDROID_HOME_DIR
45                --pass_bisect=’android/generate_cmd.sh46                --prune=False
47                --ir_diff
48                --verbose
49    ```
50
51    Where:
52
53    ```
54    --pass_bisect:
55        Enables pass/transformation level bisection and with default
56        script to generate the command as ‘android/generate_cmd.sh’.
57    --prune:
58        For now, prune must be set to False to return only the first
59        bad item.
60    --ir_diff:
61        Optional argument to print out IR differences.
62    --verbose:
63        To show IR diff, verbose needs to be on.
64    ```
65
66    Other default arguments:
67
68    ```
69    --get_initial_items='android/get_initial_items.sh'
70    --switch_to_good='android/switch_to_good.sh'
71    --switch_to_bad='android/switch_to_bad.sh'
72    --test_setup_script='android/test_setup.sh'
73    --test_script='android/interactive_test.sh'
74    --incremental
75    --prune
76    --file_args
77    ```
78
79    You can always override them if needed. See README.bisect for more
80    details.
81
821.  Other features: Features such as resuming, number of jobs, and device id
83    remain the same as before. See README.bisect for more details.
84

README.testing.md

1# Testing the binary search tool
2
3This file explains how to set up and run the various kinds of bisection tests.
4
5The bisection tool comes with several sets of tests which you should
6run after updating any of the bisection tool scripts OR after updating
7the Android compiler wrapper (to make sure the wrapper will still work
8correctly with bisection).
9
10## Before you start.
11
12Before you can run the tests, your PYTHONPATH environment variable
13must be correct.  This means that it must include both the
14toolchain-utils directory and the `binary_search_tool` directory.  The
15easiest way to set it is:
16
17```
18$ cd toolchain-utils
19$ export PYTHONPATH=`pwd`:${PYTHONPATH}
20$ cd binary_search_tool
21$ export PYTHONPATH=`pwd`:${PYTHONPATH}
22```
23
24
25## Running the unittests.
26
27To run the basic unit tests:
28
29```
30$ cd toolchain-utils/binary_search_tool/test
31$ ./binary_search_tool_test.py
32```
33
34# Running the bisection tests, testing the compiler wrapper.
35
36If you want to run the bisection tests, and test the compiler wrapper
37(to make sure the `POPULATE_GOOD` and `POPULATE_BAD` stages are still
38working properly) you can do the following.
39
40If you are testing with the ANDROID COMPILER WRAPPER, you need to to some
41preliminary setup:
42
43Set up the compiler wrapper to replace GCC:
44
45```
46$ cd <android-root/prebuilts/clang/host/linux-x86/clang-368880/bin
47$ cp clang gcc
48$ whereis gcc
49gcc: /usr/bin/gcc /usr/lib/gcc /usr/bin/X11/gcc /usr/share/man/man1/gcc.1.gz
50$ cd /usr/bin
51$ ls -l gcc
52lrwxrwxrwx 1 root root 7 Feb  3 17:00 gcc -> gcc-4.8*
53$ sudo mv gcc gcc.real
54$ sudo ln -s \
55    <android-root>/prebuilts/clang/host/linux-x86/clang-3688880/bin/gcc gcc
56```
57
58Move to the correct directory, then run the test script:
59
60```
61$ cd toolchain-utils/binary_search_tool
62$ ./run_bisect_tests.py
63```
64
65If you are testing with the CHROMEOS COMPILER WRAPPER, you MUST run the
66tests from INSIDE your CHROOT (but you don't need to do any special setup):
67
68```
69$ cd <path-to-chromeos-root>
70$ cros_sdk
71$ cd ~/trunk/src/third_party/toolchain-utils
72```
73
74Set up your `PYTHONPATH`:
75
76```
77$ export PYTHONPATH=`pwd`:${PYTHONPATH}
78$ cd binary_search_tool
79$ export PYTHONPATH=`pwd`:${PYTHONPATH}
80```
81
82Run the test script:
83
84```
85$ ./run_bisect_tests.py
86```
87
88
89## Running the bisection tests, without testing the compiler wrapper.
90
91```
92$ cd toolchain-utils/binary_search_tool
93$ ./full_bisect_test/run-test-nowrapper.sh
94```
95