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: Sat, 23 Jul 2016 09:22:12 -0400 Message-ID: <4f9332d4-68a8-4179-0ef3-b6aa0bfa04b1@gmail.com> References: <5782E073.6000505@gmail.com> <837fcsdzkj.fsf@gnu.org> <20f2bf0b-8805-103d-9aeb-648317b270d6@gmail.com> <8360rwwxdq.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="CaMbROnAhTUdSLvr6jILOcDV4OBOb3hUV" X-Trace: ger.gmane.org 1469280161 848 80.91.229.3 (23 Jul 2016 13:22:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Jul 2016 13:22:41 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 23 15:22:32 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 1bQwsx-0001iS-TV for ged-emacs-devel@m.gmane.org; Sat, 23 Jul 2016 15:22:32 +0200 Original-Received: from localhost ([::1]:52125 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQwsw-0005jM-Vq for ged-emacs-devel@m.gmane.org; Sat, 23 Jul 2016 09:22:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQwsq-0005jE-Sq for emacs-devel@gnu.org; Sat, 23 Jul 2016 09:22:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQwsn-00052q-CA for emacs-devel@gnu.org; Sat, 23 Jul 2016 09:22:24 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.130]:58524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQwsn-00052f-19; Sat, 23 Jul 2016 09:22:21 -0400 Original-Received: from [172.17.11.203] ([162.223.5.123]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0La7Bu-1b3O6v3yWM-00m13E; Sat, 23 Jul 2016 15:22:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: <8360rwwxdq.fsf@gnu.org> X-Provags-ID: V03:K0:CNRd5wFmWs0O/qEhZGNPIn5FqEzl14d4BeC2wzJIF0uPGqSmn4Q IOmc2QCtHxn5427xcbMSXTuH8CoTFHlf6yZNVC73PleFadGp2MgL18S+M642mrkAMFn8ohA KJNiGoMukqGB979yYSw40BunGWMlcggK/7pdGAsObk1cb26ZslXswguWAtueS1qP/xpdPLL MOHpAYWlIsSNaEBcrDRyA== X-UI-Out-Filterresults: notjunk:1;V01:K0:DYqIxr5Rd8E=:PZccpORnXZ+G0Kzz/Psd0s 0lsDX1qVBmnRaJfgnq/G87NrU2wZZn0jeGVunzUUzUmv3N0nZxug7fIa2AP24eu8uLI4sDbaI kqsZj4yDJDbns9q27gQL63nTxitcDa6jwsANHKtZ5RlX68D5AXT8D1sOnlInplQSr7JbQiR0R fPfyMxOrVokQ5PgI86DYT5i+SrEsIArTHba1BdRrIXqGI+pZlIi/ezNL1++BFG48cFgDOoavC itDa7q3kkZhgyipe/UhIRW7u4uhFoObiuUCXaPEFEsp6JZfPiL8vMn9YOtkW4VY9Tt9jg1n3h Sy+GAvA7fH1kwfRunSyVXORuW/oC9suAAAu6HRFSVa4bk6H9zFQWZapoQmwqy4lSX9ISKN6jw VqUXao1ccbh1esm2SqvfDMcy/X5jJMI1FEIs3YwJccUdb1t8VhU/cIJQ0A2nKs1DdG1N1j7zt FCcf5la+bMUrcWlB3EAIcuNggi8Xwno728mOahOUvq/KrBEOPJUvzSl/Qe8kZ2HjtOFi813c1 JDlR23vh12N77YnnKSYYaNk8+xB83Q9w7+agg7KCRknMti8PgCAuVMyvsra86FiHftD+mAuKm 0Jtc4h6lUuBQ+frAX0olciF+RvLpw1faIPLwUhqmHp9O609AG4MHRddje2YoiLTU1EnijsOjb 8Wetu79sAsflN55TMifuZfoaJaReKU5IBKmLBmDTmMAhIGvFRH8sEI1oatnrGDWPCXLM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.130 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:206064 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CaMbROnAhTUdSLvr6jILOcDV4OBOb3hUV Content-Type: multipart/mixed; boundary="jb1V6gjhwisT6KcTMPVKa8u96F8sGL0xR" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: Eli Zaretskii Cc: emacs-devel@gnu.org Message-ID: <4f9332d4-68a8-4179-0ef3-b6aa0bfa04b1@gmail.com> Subject: Re: Bisecting display bugs References: <5782E073.6000505@gmail.com> <837fcsdzkj.fsf@gnu.org> <20f2bf0b-8805-103d-9aeb-648317b270d6@gmail.com> <8360rwwxdq.fsf@gnu.org> In-Reply-To: <8360rwwxdq.fsf@gnu.org> --jb1V6gjhwisT6KcTMPVKa8u96F8sGL0xR Content-Type: multipart/mixed; boundary="------------D124A32D468BF66A22856053" This is a multi-part message in MIME format. --------------D124A32D468BF66A22856053 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2016-07-23 04:51, Eli Zaretskii wrote: >> Cc: Emacs developers >> From: Cl=C3=A9ment Pit--Claudel >> Date: Fri, 22 Jul 2016 14:55:36 -0400 >> >> Thanks for your comments! I've attached an updated patch. >=20 > LGTM, thanks. One comment: >=20 >> +- You should produce the =E2=80=98../reproduce-your-bug.el=E2=80=99 s= cript 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). >=20 > Suggest to say explicitly what is "the right error code" (yes, that > means repeating what you said just 20 lines above, but the relation is > not 100% clear). Thanks; here's a diff against the previous patch (I've attached the updat= ed patch). I also added a note about full rebuilds. --- =20 Some caveats: - make sure your uncommitted changes are saved somewhere else. + make sure your uncommitted changes are saved somewhere else. Also, + for bisecting small ranges, a full clean and rebuild might not be + needed. =20 - using =E2=80=98(kill-emacs EXIT-CODE)=E2=80=99). + using =E2=80=98(kill-emacs EXIT-CODE)=E2=80=99: 1 if the bug is presen= t, 0 if it is + not, and 125 if it can't tell). --- --------------D124A32D468BF66A22856053 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 0facdcbf9d3722e96c5810ee837fea0fa496cb79 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 | 108 ++++++++++++++++++++++++++++++++++++++++++++= ++++++ admin/notes/repo | 3 +- 2 files changed, 110 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..dadd46a --- /dev/null +++ b/admin/notes/bisecting @@ -0,0 +1,108 @@ +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. Also, + for bisecting small ranges, a full clean and rebuild might not be + needed. + +- 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: 1 if the bug is presen= t, 0 if it is + not, and 125 if it can't tell). + +* 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 --------------D124A32D468BF66A22856053-- --jb1V6gjhwisT6KcTMPVKa8u96F8sGL0xR-- --CaMbROnAhTUdSLvr6jILOcDV4OBOb3hUV 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 iQIcBAEBCAAGBQJXk2+EAAoJEPqg+cTm90wjTfkP/3iGwjtF8geazUszEHhK5tt8 4elF4gT2fE9obz8M10DcOVj/s9xIYMNbhHFHdiuDRC2KT71VJ+r2EfIBxQNWer/f 8kVXUEhKmKQh1Sy9+5RicVyvJzNXAW0QDjD2E/ODyWlxLXNWNGCSIcRAhHIJZPU2 0A4/arLy7LqQTqK14QLS+o0ArJw1+udHZFmVlO2Fg7pFf5vaPsKPC90JcU9HXyyR 6KB2Fu72WPAbSaNV59h38rNCHFA94lzkeOEYjDSBQxoaFrUJrxKzmqg5mXzCjlr3 8q5yd8CzuYs0nf0c089cHdkPhxFo/tgkFtMT0vuLmv1ni9Sw2gPE9dq11o1ssSUB 5f5c8r+DHwoUTbC6P1EO34tk1NQRGLUXTTUTxahgZNhex3x00irXhz3dVTmkSBq5 sYh10P1DGTxRj2uWrJ6g+gFhbIVfxf/X7I3GWYGPYyOm0UZ6IgA2TN6xbJqTArmR RDBUWPwwsX6K6erPDecujsbncVFnIKBZJhFPNEbclhzxBCmly4RDW6H28v4atvMB S1fHx9tlltUfBvOz0XrItO+yQoGdd8YVSAZOqGGwR4hPqFz08BT+OynMVT5CCLXL Bmy8JxBrEosNo4L0PS1+RXXEeIs4Oqh3THeplwV3xulU9p7Gzvhu47Ww0aElk9A+ jA9KzbW9zfCabpeHHuSz =4uG3 -----END PGP SIGNATURE----- --CaMbROnAhTUdSLvr6jILOcDV4OBOb3hUV--