From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Bisecting display bugs Date: Fri, 22 Jul 2016 14:55:36 -0400 Message-ID: <20f2bf0b-8805-103d-9aeb-648317b270d6@gmail.com> References: <5782E073.6000505@gmail.com> <837fcsdzkj.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Mk5CkBopunhvBGl80qpJGwb1spFlgLi4i" X-Trace: ger.gmane.org 1469213768 15563 80.91.229.3 (22 Jul 2016 18:56:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Jul 2016 18:56:08 +0000 (UTC) Cc: Emacs developers To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 22 20:55:59 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bQfc6-0004mi-Ot for ged-emacs-devel@m.gmane.org; Fri, 22 Jul 2016 20:55:59 +0200 Original-Received: from localhost ([::1]:48898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQfc5-0000cV-NL for ged-emacs-devel@m.gmane.org; Fri, 22 Jul 2016 14:55:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQfbz-0000cB-8X for emacs-devel@gnu.org; Fri, 22 Jul 2016 14:55:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQfbt-0005ag-4D for emacs-devel@gnu.org; Fri, 22 Jul 2016 14:55:50 -0400 Original-Received: from mout.kundenserver.de ([212.227.17.13]:51090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQfbs-0005aU-PE; Fri, 22 Jul 2016 14:55:45 -0400 Original-Received: from [172.17.11.203] ([162.223.5.123]) by mrelayeu.kundenserver.de (mreue102) with ESMTPSA (Nemesis) id 0MSJ1n-1bssvV3I9D-00TQkL; Fri, 22 Jul 2016 20:55:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: <837fcsdzkj.fsf@gnu.org> X-Provags-ID: V03:K0:Cy9Q//RbipYnEej+jPTC4uGK0rj4OOFFkbV8PA/Z08azPNQGLQe XIyCjz6+JjGi0FqpYBF85bhUIhC90tGavsJtIfpzitjL4bcN2Lm/Z9FHUyGdMKjswDGFcNd VgiL7N9iI2ciM3cY/l+YpAItXE1jc9jiI+1RxFM4rana7XEOYnD5UFZRzwbxIAIxWNvl73h TI5VR9th72WdCF0wr7Rcg== X-UI-Out-Filterresults: notjunk:1;V01:K0:cmyVrPAJjWQ=:OsBxHlvqxRlt/i/Cyxco9R 951AJHcHywjj1lKBxyl8g921NvtBYrXGxV2EqisILFMBC9/JkjYFKwJ35ndXw8mtJbN8Fxmaq OMHxHryxhoqq9m5LDeGDcbeM60V23g8O8oHhX1fhp4X8pr42zDB4NrkAdZpplBQivaCZBsb9Y UfvmZhKLk+DwLBBSRNs25ueEC92FaMj7L6VqYikfw7f2vGDjJSvLESIZeSNFfg0oqHyHwd6XJ n2HxKZEL9865BGw6Lwhw+QF3F1yg2zg1rMaIGR796te19ezex47k/JgfSs7UuJzVRc41hcBMU wxhd2WaE2ns097/UTVZLDpbLZVXEMEHZbVcxmI3aelQ9nklDHYNJWEsi3kHhECa/ZrgbIOyHa L9uda4SbR45RE2DPkDQKD/ZIlP8XZfPtIwDByDbJSYMiuv6Zdg+G8VL5hwYSahxsxSFEVHxhl Q8y7MBOptOiC+koMNpRbl7dU3xzI84OkVR08Zr0bOVl40B6PnzTOTnGbfE/rYOTOzlXMj/DKI u++Tl/e8Zzz+XBQaBWHgm+PgBWXH5WSfIIU6DmLhXLsPF9vVorlBNBuj+vT9eqLiZkLoT0s+b nEnDeKZMqy/Rqqp7Xk/IOLDSx6h1l+VqEPNVHiZuPg2YzhX4v1jS0ciUcNNM9TMxQF+m4OSQn I47X+hJHEzmtnOKuqstO7SEKA2KVX1Ip7uRKIhj8KTA6x9MXmMh1Yx2JZOkPK8GSAsOM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.13 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:206047 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Mk5CkBopunhvBGl80qpJGwb1spFlgLi4i Content-Type: multipart/mixed; boundary="UjscAl7soorLpDDuhqjbH0S7i987rPfp4" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: Eli Zaretskii Cc: Emacs developers Message-ID: <20f2bf0b-8805-103d-9aeb-648317b270d6@gmail.com> Subject: Re: Bisecting display bugs References: <5782E073.6000505@gmail.com> <837fcsdzkj.fsf@gnu.org> In-Reply-To: <837fcsdzkj.fsf@gnu.org> --UjscAl7soorLpDDuhqjbH0S7i987rPfp4 Content-Type: multipart/mixed; boundary="------------378F8A627495DD7E3C62AC52" This is a multi-part message in MIME format. --------------378F8A627495DD7E3C62AC52 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > Thanks again for working on this. Thanks for your comments! I've attached an updated patch. --------------378F8A627495DD7E3C62AC52 Content-Type: text/x-diff; name="0001-Add-notes-about-using-git-bisect-to-pinpoint-Emacs-b.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Add-notes-about-using-git-bisect-to-pinpoint-Emacs-b.pa"; filename*1="tch" =46rom bb565a03c35103c5ec60dd42582eafdbdc21b725 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Cl=3DC3=3DA9ment=3D20Pit--Claudel?=3D Date: Mon, 11 Jul 2016 01:47:01 +0200 Subject: [PATCH] Add notes about using `git bisect' to pinpoint Emacs bug= s * admin/notes/bisecting: New file. * admin/notes/repo: Add pointer to admin/notes/bisecting. --- admin/notes/bisecting | 105 ++++++++++++++++++++++++++++++++++++++++++++= ++++++ admin/notes/repo | 3 +- 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 admin/notes/bisecting diff --git a/admin/notes/bisecting b/admin/notes/bisecting new file mode 100644 index 0000000..3a335a4 --- /dev/null +++ b/admin/notes/bisecting @@ -0,0 +1,105 @@ +HOW TO USE GIT BISECT TO PINPOINT EMACS BUGS -*- outline -*- + +This documents explains how to automate git bisect to find the commit +that introduced an Emacs bug. Bisecting automatically works best if +the bug is easy and quick to reproduce in a clean =E2=80=98emacs -Q=E2=80= =99 instance. + +For an Emacs-independent tutorial on bisecting, run =E2=80=98git help bi= sect=E2=80=99. + +* Automating =E2=80=98git bisect=E2=80=99 + +Use =E2=80=98git bisect run =E2=80=99 to automate the= bisecting +process. =E2=80=98=E2=80=99 should build Emacs, run = your bug +reproduction test, and return 0 if the current revision is good, 1 if +it's bad, and 125 to skip the current revision. + +Concretely, =E2=80=98=E2=80=99 usually looks like thi= s: + + #!/usr/bin/env bash + + # Remove leftovers from previous runs + git clean -xfd > /dev/null + # Build Emacs and skip commit if build fails + (./autogen.sh && ./configure --cache-file=3D/tmp/emacs.config.cache = && make -j4) || exit 125 + + # Reproduce the bug, writing output somewhere + src/emacs -Q -l "../reproduce-the-bug.el" || exit 125 + +Some caveats: + +- This script cleans Emacs' source directory with =E2=80=98git clean -xf= d=E2=80=99, so + make sure your uncommitted changes are saved somewhere else. + +- You should produce the =E2=80=98../reproduce-your-bug.el=E2=80=99 scri= pt on your own + (it should check if the bug exists, and return the right error code + using =E2=80=98(kill-emacs EXIT-CODE)=E2=80=99). + +* Using =E2=80=98git bisect=E2=80=99 to find display-related bugs + +** Ways to programmatically detect display bugs + +Most bugs that manifest graphically can be checked for by +programmatically inspecting the following elements: + +- text properties +- window-start and window-end +- posn-at-point +- pos-visible-in-window-p +- frame-geometry +- window--dump-frame +- frame--size-history +- display-monitor-attributes-list +- C-u C-x =3D +- trace-redisplay and trace-to-stderr +- dump-glyph-matrix and dump-frame-glyph-matrix + +** When the above fails + +Some bugs are only apparent through visual inspection. Since building +Emacs takes a long time, it can be a pain to debug these manually. + +If your display bug has a clear manifestation in a screenshot of a +particular portion of Emacs display, and you have a program, like +'xwd', that can capture the content of the Emacs frame, and also have +ImageMagick installed, you can automate the comparison of the +redisplay results to make the bisection process fully automatic. + +Use the following template for =E2=80=98../reproduce-the-bug.el=E2=80=99= : it requires +ImageMagick (mogrify and identify) and xwd (if =E2=80=98xwd=E2=80=99 isn= 't available, +you can use ImageMagick's =E2=80=98import=E2=80=99 tool, passing it a =E2= =80=98-window=E2=80=99 +argument where =E2=80=98xwd=E2=80=99 wants =E2=80=98id=E2=80=99). + + (defun image-checksum (img-fname) + "Compute a checksum of IMG-FNAME's image data." + (car (process-lines "identify" "-quiet" "-format" "%#" img-fname))= ) + + (defun take-screenshot-and-exit (fname x y w h reference-fname) + "Save a screenshot of Emacs as FNAME, then exit. + X and Y are the coordinates of the top-left point of the area of + interest. W, and H are its dimensions. This function sets + Emacs' return code to 0 if the resulting screenshot matches + REFERENCE-FNAME, and 1 otherwise." + (let ((wid (frame-parameter nil 'outer-window-id)) + (crop-spec (format "%dx%d+%d+%d" w h x y))) + (call-process "xwd" nil nil nil "-silent" "-id" wid "-out" fname= ) + (call-process "mogrify" nil nil nil fname "-crop" crop-spec)) + (let ((same-picture (equal (image-checksum fname) + (image-checksum reference-fname)))) + (kill-emacs (if same-picture 0 1)))) + + (defun main () + ;; Reproduce your bug here + =E2=80=A6 + ;; Force a redisplay + (redisplay t) + ;; Insert rough X, Y, W, H values below + (run-with-timer 0 nil #'take-screenshot-and-exit + "screenshot.xwd" =E2=80=A6 =E2=80=A6 =E2=80=A6 =E2= =80=A6 "reference-screenshot.xwd")) + + (main) + +This script takes and crops a screenshot of Emacs after reproducing +your bug, then compares the result to a reference (cropped) +screenshot, and returns 0 if they match, and 1 otherwise. Cropping is +useful to weed out unrelated display changes; try to include only a +small portion of the screen containing your bug. diff --git a/admin/notes/repo b/admin/notes/repo index 3ab3da7..f169468 100644 --- a/admin/notes/repo +++ b/admin/notes/repo @@ -115,7 +115,8 @@ again. * Bisecting =20 This is a semi-automated way to find the revision that introduced a bug.= -Browse 'git help bisect' for technical instructions. +Browse 'git help bisect' and admin/notes/bisecting for technical +instructions. =20 * Maintaining ChangeLog history =20 --=20 2.7.4 --------------378F8A627495DD7E3C62AC52-- --UjscAl7soorLpDDuhqjbH0S7i987rPfp4-- --Mk5CkBopunhvBGl80qpJGwb1spFlgLi4i Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXkmwoAAoJEPqg+cTm90wjmfoP/2kmWojjKUpIxSTFDKXA8Eo9 iEbXZyXuQG4fTmUHY8BpM5H6IHbEfb3XcEndp6iYCPISd4FS+zzRuHsLW6u7sq7e 3JQXPkUksmvMiYD8/MxShCip9wCOrFplCXSQVGandb1r7CTDdGmhHbgY0jvcwavT tVsL77S5x9HSG+2MFoormLR51wcdumMqzAiusfyPFHa1s95teb2srdkiZaQp+DBT Zeg07P+uRfXvA5V6223HXt/vSV/hT+IqjDSx9tdZ7QASup0BxL8WFcCS/aJn+jL9 WGqam0UV8CfL7crnqrYfJodlrMxOrVzR9MftzsDy3adk3lTUXPnIJ8iC7xTUtxXv zyBzMlnvpHSyt0lA2d/xsjQfVv0L1MQ/kmYezCrRLPrySPb26LyOLrvTmK79GjVX miO83KS2T+zRN7PFjwkMEEt38Tb2rL6hq25hY64/vqJ2sYDYRIlMdXHWrkCt1Tyx fXTSLMaAIw5tZIcX5A8+9UJgj1KKHWhA57nabtSvmAihjU2lGU3qxkbKbNnRDdw8 nOHWEE0NeLvMzIaD8mNbYf6t88aBDNUOJb7S9gONlDoG07Ng5XCcchmQLoJ74VU4 Gl9gEfA2GeNH5/EQA2Rzm2ajMtkYkHthkihYqvs2AyVjSwyBHrgGHQKsdFPCmSo5 GKQIYlffXkwBdkT4tW7o =FmDM -----END PGP SIGNATURE----- --Mk5CkBopunhvBGl80qpJGwb1spFlgLi4i--