| 1 | <html> |
| 2 | <head> |
| 3 | <title>Delta</title> |
| 4 | </head> |
| 5 | <body bgcolor=white> |
| 6 | |
| 7 | <p><b>Maintainer:</b> <a href="http://danielwilkerson.com/">Daniel S. Wilkerson</a> |
| 8 | <br><b>Developer:</b> <a href="http://www.cs.berkeley.edu/~smcpeak/">Scott McPeak</a> |
| 9 | <br><b>Documenter:</b> <a href="http://http.cs.berkeley.edu/~sfg/">Simon Goldsmith</a> |
| 10 | |
| 11 | <h3>Summary</h3> |
| 12 | |
| 13 | <p>Delta assists you in minimizing "interesting" files subject to a |
| 14 | test of their interestingness. A common such situation is when |
| 15 | attempting to isolate a small failure-inducing substring of a large |
| 16 | input that causes your program to exhibit a bug. |
| 17 | |
| 18 | <p>Our implementation is based on the <a |
| 19 | href=http://www.st.cs.uni-sb.de/dd/>Delta Debugging algorithm</a>. <a |
| 20 | href=http://www.whyprogramsfail.com/>Andreas</a> wrote a book <a |
| 21 | href=http://www.whyprogramsfail.com/>"Why Programs Fail"</a> about |
| 22 | debugging programs. |
| 23 | |
| 24 | <p>This work was supported by professors <a |
| 25 | href=http://theory.stanford.edu/~aiken/>Alex Aiken</a> and <a |
| 26 | href=http://www.cs.berkeley.edu/~necula/>George Necula</a> and was |
| 27 | done at UC Berkeley. |
| 28 | |
| 29 | <h3>Releases</h3> |
| 30 | |
| 31 | <p>Feel free to just get the current Subversion repository version as |
| 32 | a guest user. |
| 33 | |
| 34 | <ul> |
| 35 | |
| 36 | <li><a |
| 37 | href="http://delta.tigris.org/files/documents/3103/33566/delta-2006.08.03.tar.gz">delta-2006.08.03.tar.gz</a> |
| 38 | md5: |
| 39 | <code> |
| 40 | 7be4ac4ae9c1eb01ccf29d413d4cc64a |
| 41 | </code> |
| 42 | This is the current recommended release. |
| 43 | |
| 44 | <li><a |
| 45 | href="http://delta.tigris.org/files/documents/3103/33236/delta-2006.07.15.tar.gz">delta-2006.07.15.tar.gz</a> |
| 46 | md5: |
| 47 | <code> |
| 48 | 57afa6d4e7d15f380803e878c24678ed |
| 49 | </code> |
| 50 | This release had a version that multidelta did not work without the -cpp flag. |
| 51 | |
| 52 | <li><a |
| 53 | href="http://delta.tigris.org/files/documents/3103/25616/delta-2005.09.13.tar.gz">delta-2005.09.13.tar.gz</a> |
| 54 | md5: |
| 55 | <code> |
| 56 | 588d65056ea48ae2a2ecee32598c5837 |
| 57 | </code> |
| 58 | This version had a bug that it was too hard to stop delta once it |
| 59 | started. |
| 60 | |
| 61 | <li>The first release of Delta was on 14 July 2003. It is now |
| 62 | retired. |
| 63 | |
| 64 | </ul> |
| 65 | |
| 66 | <h2>History</h2> |
| 67 | |
| 68 | <p>I first wrote delta out of necessity. Scott and I had a |
| 69 | quarter-million line (after prepossessing) C++ input that would crash |
| 70 | the C++ front-end we were working on, <a |
| 71 | href=http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/elsa/>Elsa</a>; |
| 72 | there was just no way we were going to minimize that by hand. I just |
| 73 | checked my little perl script into the CVS repository most of us used |
| 74 | in the Programming Languages group at Berkeley. Scott later added to |
| 75 | it. |
| 76 | |
| 77 | <p>I would hear occasionally of someone else in the group using it: |
| 78 | just a "Hey, thanks for delta!" every once in a while. One day, a |
| 79 | graduate student came into my office; he leaned back against the wall |
| 80 | and spoke in a low tone. "You know, some of our friends at Microsoft |
| 81 | Research have heard of your delta tool. They would really like to use |
| 82 | it. They asked me to ask you if you could please <em>release it as |
| 83 | Open Source</em>; the BSD license is preferred." |
| 84 | |
| 85 | <p>I GPL'ed it right away. A few years later I relented and it is now |
| 86 | released under the BSD license. So there you go, you have Microsoft |
| 87 | to thank for the existence of delta as an open-source project. I |
| 88 | think it is quite interesting given their often unfriendly public |
| 89 | stance on Open Source, such as that it is <a |
| 90 | href=http://www.theregister.co.uk/2000/07/31/ms_ballmer_linux_is_communism/>Communism</a>. |
| 91 | I guess they want to commune with us after all. |
| 92 | |
| 93 | <p>I presented Delta at <a href="http://www.codecon.org/2006/">CodeCon |
| 94 | 2006</a>. The slides are <a href=delta_codecon.ppt>here</a>. |
| 95 | |
| 96 | <h2>Usage overview</h2> |
| 97 | |
| 98 | <p>The best way to understand how to use delta is with an example of |
| 99 | its usage. <a href=#example>Below is one example</a> helpfully |
| 100 | written up for me by Simon Goldsmith; read it first. For those |
| 101 | wanting more, I also wrote a more detailed and harder to read document |
| 102 | describing each tool: <a href=using_delta.html>Using Delta</a>. |
| 103 | |
| 104 | <p>Note that what follows is an example of using delta to minimize an |
| 105 | input file to a program that reads programs, much as a compiler does. |
| 106 | Note two features of file minimization that are present in the |
| 107 | example. |
| 108 | |
| 109 | <h3>Do a controlled experiment.</h3> |
| 110 | |
| 111 | <p>Below we don't just minimize a file that causes Oink to produce an |
| 112 | error message, we minimize a file that causes gcc to accept AND oink |
| 113 | to reject in a specific way. That is, the test delta does is a |
| 114 | controlled experiment, where gcc is the control. Ignoring this aspect |
| 115 | of the problem seems to be a frequent mistake of first time users. |
| 116 | |
| 117 | <h3>Exploit nested structure.</h3> |
| 118 | |
| 119 | <p>One may minimize files of simpler syntax than C++ but really all |
| 120 | files are interesting in the first place because they are in some |
| 121 | language or another. Some simple configuration files are literally |
| 122 | just a list of lines but most languages have some nested structure. |
| 123 | Multidelta filters the input through the topformflat utility |
| 124 | (included) to suppress any newlines past a particular nesting depth; |
| 125 | this "explains" the nesting structure to the otherwise line-oriented |
| 126 | delta utility (a brilliantly simple idea of Scott McPeak's). If your |
| 127 | input file language has no nesting structure, you can hack on |
| 128 | multidelta to remove the filtration through topformflat or just use |
| 129 | the raw delta program. If your language has a different nesting |
| 130 | structure than C/C++, you can write your own multidelta and substitute |
| 131 | it. A simple flex program should suffice; it need not be terribly |
| 132 | accurate for delta to do well. |
| 133 | |
| 134 | <a name=example> |
| 135 | <h2>An example</h2> |
| 136 | </a> |
| 137 | |
| 138 | <p>Simon Goldsmith 8 April / 12 Sept, 2005. |
| 139 | |
| 140 | <p>Note that this example is edited for simplicity from the raw |
| 141 | output; we sincerely hope we did not introduce any bugs. |
| 142 | |
| 143 | <h3>Setup</h3> |
| 144 | |
| 145 | <p>(1) Make a new directory and copy the file to be minimized there. |
| 146 | <pre> |
| 147 | % mkdir deltaexample |
| 148 | % cd deltaexample/ |
| 149 | % cp ../nsCSSDataBlock-23801-1112390043.cpp.g.ii ./foo.ii |
| 150 | % chmod +w foo.ii |
| 151 | </pre> |
| 152 | |
| 153 | <p>(2) (optional) Put a read-only backup copy of the file in, say, orig/ . |
| 154 | <pre> |
| 155 | % mkdir orig |
| 156 | % cp foo.ii orig/ |
| 157 | % chmod -R a-w orig |
| 158 | </pre> |
| 159 | |
| 160 | <h3>Define interestingness</h3> |
| 161 | |
| 162 | <p>(3) Write a script (do not call it 'test' as that is a system |
| 163 | utility program) to test the interestingness of the file, as we do |
| 164 | below. |
| 165 | |
| 166 | <p>Note that for this example, "interesting" means the file passes gcc |
| 167 | but fails oink with a particular error message. That is, if 1) gcc |
| 168 | accepts, and 2) oink rejects with the desired error message, then we |
| 169 | return zero (meaning "interesting"). If anything else happens then we |
| 170 | return a nonzero exit code (meaning "not interesting") |
| 171 | |
| 172 | <p>Some reminders about shell: a zero exit code means "true"; so for |
| 173 | the purposes of &&, a zero exit code means "keep going" and grep |
| 174 | returns 0 if it matches, nonzero if not. We redirect output to |
| 175 | /dev/null because the output of delta is noisy. Be careful of quoting |
| 176 | hell: notice that we've used '.' to match characters like single |
| 177 | quote. |
| 178 | |
| 179 | <pre> |
| 180 | % cat > test1.sh |
| 181 | #!/bin/bash |
| 182 | |
| 183 | FILE=foo.ii |
| 184 | OINK=/home/simon/oink_all/oink/oink |
| 185 | GCC=/usr/bin/gcc |
| 186 | |
| 187 | $GCC -c $FILE -o /dev/null &> /dev/null && $OINK $FILE | \ |
| 188 | grep 'error: cannot convert argument type .class .* const &. ' \ |
| 189 | 'to receiver parameter type' \ |
| 190 | &> /dev/null |
| 191 | ^D |
| 192 | </pre> |
| 193 | |
| 194 | <p>(4) Make the script executable and run it on the file -- make sure |
| 195 | it returns 0. Optionally turn off the redirection to /dev/null |
| 196 | temporarily to check the error message that is being found by the |
| 197 | grep. |
| 198 | <pre> |
| 199 | % chmod +x test1.sh |
| 200 | % ./test1.sh foo.ii ; echo $? |
| 201 | 0 |
| 202 | </pre> |
| 203 | |
| 204 | <h3>Minimize automatically</h3> |
| 205 | |
| 206 | <p>(5) Run multidelta with the script on the file several times at, say, levels 0 0 1 1 2 2 10. |
| 207 | <pre> |
| 208 | % multidelta -level=0 ./test1.sh foo.ii |
| 209 | (check email) |
| 210 | % multidelta -level=0 ./test1.sh foo.ii |
| 211 | (read slashdot) |
| 212 | % multidelta -level=1 ./test1.sh foo.ii |
| 213 | % multidelta -level=1 ./test1.sh foo.ii |
| 214 | % multidelta -level=2 ./test1.sh foo.ii |
| 215 | % multidelta -level=2 ./test1.sh foo.ii |
| 216 | % multidelta -level=10 ./test1.sh foo.ii |
| 217 | % multidelta -level=10 ./test1.sh foo.ii |
| 218 | </pre> |
| 219 | |
| 220 | <p>(6) The input file will be modified in place and you should be left with something smaller. |
| 221 | <pre> |
| 222 | [simon@otter][deltaexample]$ ls -l |
| 223 | total 116 |
| 224 | -rw-r--r-- 1 simon simon 8451 Sep 12 17:10 foo.ii |
| 225 | -rw-r--r-- 1 simon simon 8948 Sep 12 17:10 foo.ii.bak |
| 226 | -rw-r--r-- 1 simon simon 8451 Sep 12 17:10 foo.ii.ok |
| 227 | -rw-r--r-- 1 simon simon 57739 Sep 12 17:10 log |
| 228 | -rw-r--r-- 1 simon simon 2752 Sep 12 17:10 multidelta.log |
| 229 | dr-xr-xr-x 2 simon simon 4096 Sep 12 17:16 orig/ |
| 230 | -rwxr-xr-x 1 simon simon 385 Sep 12 16:36 test1.sh* |
| 231 | -rw-r--r-- 1 simon simon 11 Sep 12 16:02 test1.sh~ |
| 232 | |
| 233 | [simon@otter][deltaexample]$ ls -l orig/ |
| 234 | total 552 |
| 235 | -r--r--r-- 1 simon simon 558970 Sep 12 16:00 foo.ii |
| 236 | </pre> |
| 237 | |
| 238 | <h3>Minimize further by hand</h3> |
| 239 | |
| 240 | <p>(7) Hack on foo.ii by hand, re-running test1.sh each time to check it |
| 241 | is still "interesting". Sometimes it helps to hack on foo.ii a little |
| 242 | to get delta unstuck and then rerun delta again. You might want to |
| 243 | run indent as well whenever you stop to look at foo.ii as topformflat |
| 244 | makes a mess. |
| 245 | |
| 246 | <p>Final file: |
| 247 | <pre> |
| 248 | class A {}; |
| 249 | int main() { |
| 250 | const A *val; |
| 251 | val->~A (); |
| 252 | } |
| 253 | </pre> |
| 254 | |
| 255 | <P>Note that the original file was about 560 KB! |
| 256 | |
| 257 | <h2>Endorsements</h2> |
| 258 | |
| 259 | <p>This section is just for fun because I've never had a tool so |
| 260 | widely used before. |
| 261 | |
| 262 | <pre> |
| 263 | Subject: Thanks for Delta |
| 264 | Date: Thu, 21 Jul 2005 21:13:20 -0700 |
| 265 | From: Flash Sheridan |
| 266 | To: Daniel S. Wilkerson |
| 267 | |
| 268 | This is just a quick thank-you note for Delta. Andrew Pinski pointed |
| 269 | me towards it after filing a GCC bug with a very long source file; it |
| 270 | immediately reduced a different bug file from 16K lines to ten (GCC |
| 271 | bug 22604). Oddly enough, it initially found a different bug (22603), |
| 272 | since I'd only specified "internal compiler error", not "segmentation |
| 273 | fault". I might not have been able to file either of these bugs |
| 274 | without Delta, since the code was proprietary, but the two |
| 275 | Delta-reduced files were small enough to make public. |
| 276 | |
| 277 | <hr align=left width=10%> |
| 278 | Subject: Re: Thanks for Delta |
| 279 | Date: Tue, 13 Sep 2005 10:56:10 -0700 |
| 280 | From: Flash Sheridan |
| 281 | To: Daniel S. Wilkerson |
| 282 | |
| 283 | Delta has become even more valuable since my initial thank-you note. |
| 284 | I'm not sure it's helped with all of the GCC bugs I've been filing |
| 285 | (I've been tracking them at |
| 286 | http://pobox.com/~flash/FlashsOpenSourceBugReports.html), but I |
| 287 | couldn't have filed most of them without Delta. Typically I find a |
| 288 | bug when GCC is compiling a large, confidential file, which I couldn't |
| 289 | post to Bugzilla. Delta has always been able to find a radically |
| 290 | smaller file, which I have been able to attach to my bug report. |
| 291 | |
| 292 | <hr align=left width=10%> |
| 293 | Date: Sun, 23 Oct 2005 22:01:42 +0200 (CEST) |
| 294 | From: Richard Guenther |
| 295 | To: Daniel S. Wilkerson |
| 296 | |
| 297 | > > > Thanks for your interest in Delta. I would be interested to |
| 298 | > > > hear more about what you are doing with it. If it is something |
| 299 | > > > I can put in the endoresements section ("Delta saved my |
| 300 | > > > daugher's life!") that would be great. |
| 301 | > > |
| 302 | > > Well, delta is saving a lot of gcc developers life ;) I would |
| 303 | > > guess 1 of 3 bugs sumitted to the gcc bugzilla get their testcase |
| 304 | > > reduced using delta. |
| 305 | > |
| 306 | > Holy moly! Can I quote that publicly such as on my web page? |
| 307 | |
| 308 | Yes - a little bit more accurate would be to say we're using delta to |
| 309 | reduce all testcases from the gcc bugzilla in case they get entered |
| 310 | unreduced. |
| 311 | </pre> |
| 312 | |
| 313 | <hr align=left width=10%> |
| 314 | |
| 315 | <p>Delta (both the algorithm and this tool) has been used in the <a |
| 316 | href=http://www-inst.eecs.berkeley.edu/~cs169/fa05/index.shtml>Cal |
| 317 | Berkeley (CS169)</a> and <a |
| 318 | href=http://www.stanford.edu/class/cs295/>Stanford (CS295)</a> in |
| 319 | software engineering classes. |
| 320 | |
| 321 | <pre> |
| 322 | Subject: Re: delta debugging on instructional machines? |
| 323 | Date: Mon, 24 Oct 2005 22:55:08 -0700 |
| 324 | From: Gilad Arnold <[email protected]> |
| 325 | To: Daniel S. Wilkerson |
| 326 | |
| 327 | We've just assigned a delta-related homework to the students today, |
| 328 | . . . We do hope that we can actually convince the students to use |
| 329 | delta in the course of their project development, but time will |
| 330 | tell. And thanks again! |
| 331 | |
| 332 | <hr align=left width=10%> |
| 333 | Subject: Re: use of delta in your class |
| 334 | Date: Mon, 24 Oct 2005 13:57:22 -0700 |
| 335 | From: Alex Aiken |
| 336 | To: Daniel S. Wilkerson |
| 337 | |
| 338 | Yes, I gave them a homework assignment for CS295 using delta. Feedback |
| 339 | was positive but unquantified. |
| 340 | </pre> |
| 341 | |
| 342 | <h2> </h2> |
| 343 | |
| 344 | </body> |
| 345 | </html> |