1*84dc0c20SWu XiangCheng.. include:: ../disclaimer-zh_CN.rst 2*84dc0c20SWu XiangCheng 3*84dc0c20SWu XiangCheng:Original: :doc:`../../../admin-guide/bug-bisect` 4*84dc0c20SWu XiangCheng 5*84dc0c20SWu XiangCheng:译者: 6*84dc0c20SWu XiangCheng 7*84dc0c20SWu XiangCheng 吴想成 Wu XiangCheng <bobwxc@email.cn> 8*84dc0c20SWu XiangCheng 9*84dc0c20SWu XiangCheng二分(bisect)缺陷 10*84dc0c20SWu XiangCheng+++++++++++++++++++ 11*84dc0c20SWu XiangCheng 12*84dc0c20SWu XiangCheng(英文版)最后更新:2016年10月28日 13*84dc0c20SWu XiangCheng 14*84dc0c20SWu XiangCheng引言 15*84dc0c20SWu XiangCheng===== 16*84dc0c20SWu XiangCheng 17*84dc0c20SWu XiangCheng始终尝试由来自kernel.org的源代码构建的最新内核。如果您没有信心这样做,请将 18*84dc0c20SWu XiangCheng错误报告给您的发行版供应商,而不是内核开发人员。 19*84dc0c20SWu XiangCheng 20*84dc0c20SWu XiangCheng找到缺陷(bug)并不总是那么容易,不过仍然得去找。如果你找不到它,不要放弃。 21*84dc0c20SWu XiangCheng尽可能多的向相关维护人员报告您发现的信息。请参阅MAINTAINERS文件以了解您所 22*84dc0c20SWu XiangCheng关注的子系统的维护人员。 23*84dc0c20SWu XiangCheng 24*84dc0c20SWu XiangCheng在提交错误报告之前,请阅读“Documentation/admin-guide/reporting-issues.rst”。 25*84dc0c20SWu XiangCheng 26*84dc0c20SWu XiangCheng设备未出现(Devices not appearing) 27*84dc0c20SWu XiangCheng==================================== 28*84dc0c20SWu XiangCheng 29*84dc0c20SWu XiangCheng这通常是由udev/systemd引起的。在将其归咎于内核之前先检查一下。 30*84dc0c20SWu XiangCheng 31*84dc0c20SWu XiangCheng查找导致缺陷的补丁 32*84dc0c20SWu XiangCheng=================== 33*84dc0c20SWu XiangCheng 34*84dc0c20SWu XiangCheng使用 ``git`` 提供的工具可以很容易地找到缺陷,只要缺陷是可复现的。 35*84dc0c20SWu XiangCheng 36*84dc0c20SWu XiangCheng操作步骤: 37*84dc0c20SWu XiangCheng 38*84dc0c20SWu XiangCheng- 从git源代码构建内核 39*84dc0c20SWu XiangCheng- 以此开始二分 [#f1]_:: 40*84dc0c20SWu XiangCheng 41*84dc0c20SWu XiangCheng $ git bisect start 42*84dc0c20SWu XiangCheng 43*84dc0c20SWu XiangCheng- 标记损坏的变更集:: 44*84dc0c20SWu XiangCheng 45*84dc0c20SWu XiangCheng $ git bisect bad [commit] 46*84dc0c20SWu XiangCheng 47*84dc0c20SWu XiangCheng- 标记正常工作的变更集:: 48*84dc0c20SWu XiangCheng 49*84dc0c20SWu XiangCheng $ git bisect good [commit] 50*84dc0c20SWu XiangCheng 51*84dc0c20SWu XiangCheng- 重新构建内核并测试 52*84dc0c20SWu XiangCheng- 使用以下任一与git bisect进行交互:: 53*84dc0c20SWu XiangCheng 54*84dc0c20SWu XiangCheng $ git bisect good 55*84dc0c20SWu XiangCheng 56*84dc0c20SWu XiangCheng 或:: 57*84dc0c20SWu XiangCheng 58*84dc0c20SWu XiangCheng $ git bisect bad 59*84dc0c20SWu XiangCheng 60*84dc0c20SWu XiangCheng 这取决于您测试的变更集上是否有缺陷 61*84dc0c20SWu XiangCheng- 在一些交互之后,git bisect将给出可能导致缺陷的变更集。 62*84dc0c20SWu XiangCheng 63*84dc0c20SWu XiangCheng- 例如,如果您知道当前版本有问题,而4.8版本是正常的,则可以执行以下操作:: 64*84dc0c20SWu XiangCheng 65*84dc0c20SWu XiangCheng $ git bisect start 66*84dc0c20SWu XiangCheng $ git bisect bad # Current version is bad 67*84dc0c20SWu XiangCheng $ git bisect good v4.8 68*84dc0c20SWu XiangCheng 69*84dc0c20SWu XiangCheng 70*84dc0c20SWu XiangCheng.. [#f1] 您可以(可选地)在开始git bisect的时候提供good或bad参数 71*84dc0c20SWu XiangCheng ``git bisect start [BAD] [GOOD]`` 72*84dc0c20SWu XiangCheng 73*84dc0c20SWu XiangCheng如需进一步参考,请阅读: 74*84dc0c20SWu XiangCheng 75*84dc0c20SWu XiangCheng- ``git-bisect`` 的手册页 76*84dc0c20SWu XiangCheng- `Fighting regressions with git bisect(用git bisect解决回归) 77*84dc0c20SWu XiangCheng <https://www.kernel.org/pub/software/scm/git/docs/git-bisect-lk2009.html>`_ 78*84dc0c20SWu XiangCheng- `Fully automated bisecting with "git bisect run"(使用git bisect run 79*84dc0c20SWu XiangCheng 来全自动二分) <https://lwn.net/Articles/317154>`_ 80*84dc0c20SWu XiangCheng- `Using Git bisect to figure out when brokenness was introduced 81*84dc0c20SWu XiangCheng (使用Git二分来找出何时引入了错误) <http://webchick.net/node/99>`_ 82