What is the name for this bug-finding technique an

2019-05-19 03:31发布

问题:

Let's say I have some giant program P which I know has a bug in it: when I run it with argument A it prints the ugly error message E. In shell notation, this happens:

$ ./P A
E
$

Now I don't have any idea what causes the bug, but it appears to be deterministic. My approach to finding the bug is to "isolate" it. I "reduce" the program P to the "smallest" version that still generates the error E given the argument A. By "reduce", I mean I will chop out parts of the program and manually inline functions, testing at every stage that P A --> E and not a success response or some other error message. Once I can't reduce it any more, I have a small program that probably gets to the core of the issue.

This process is fairly mechanical: it doesn't require much "insight" on my part. It feels like it could be done automatically: there could be some program X which, given P, A, and E, spits out the smallest program P' such that P reduces to P' and P' A --> E.

So, does this strategy have a name, and has it been automated in any sense for any programming language?

回答1:

Finally stumbled over something that answers my question! Apparently, this technique is known as "reduction" or "minimization". See:

  • CReduce, which performs a generalized version of the reduction that I described, specifically for C programs.
  • Delta, a very similar program.
  • DustMite, another similar program, for minimizing D programs.
  • Delta debugging, a page which describes the general process.
  • A Guide to Testcase Reduction on the GCC wiki.