From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Extend gdb to filter registers Date: Tue, 21 Jan 2020 20:50:46 -0500 Message-ID: <2BEA3843-859E-481B-8561-35384438EF7F@gmail.com> References: <878spmuerf.fsf@mail.linkov.net> <83wod3bx8i.fsf@gnu.org> <9f5ddaa5-0234-a17b-bdd7-81d70a0a50d6@gmx.at> <83FFF194-64CD-409E-8B7A-5A9DF91E79DE@gmail.com> <83v9pb314t.fsf@gnu.org> <838sm510d6.fsf@gnu.org> <83muakzoy5.fsf@gnu.org> <71042c9f-478b-47c8-f27e-1348e9f4536d@gmx.at> <83iml8zkbm.fsf@gnu.org> <6ad85759-7408-f177-38f6-45a72c2f5a9e@gmx.at> <83eevwzi79.fsf@gnu.org> <68ef651e-9319-b392-af1c-4564d5db9112@gmx.at> <831rrvzc81.fsf@gnu.org> <997C9AD2-D8DD-45DC-9195-28FEC907B2C4@gmail.com> <83muajxs04.fsf@gnu.org> <416593FF-C4BE-478F-B5AC-3379235146ED@gmail.com> <83lfq3xp66.fsf@gnu.org> <679953AF-F50A-4ABE-B836-150BA0F95DAE@gmail.com> <83h80rxlae.fsf@gnu.org> <8A5A507A-6036-4894-A8B1-749109EBE605@gmail.com> <83wo9mvwco.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_FBE92095-3CE5-49D9-A6C0-43D18922FCA1" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="63709"; mail-complaints-to="usenet@ciao.gmane.io" Cc: martin rudalics , emacs-devel@gnu.org, monnier@iro.umontreal.ca, john@yates-sheets.org, Juri Linkov To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 22 02:51:31 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iu5B5-000GXo-5b for ged-emacs-devel@m.gmane-mx.org; Wed, 22 Jan 2020 02:51:31 +0100 Original-Received: from localhost ([::1]:34980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu5B3-0002jr-3X for ged-emacs-devel@m.gmane-mx.org; Tue, 21 Jan 2020 20:51:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40911) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iu5AW-0002Jn-T2 for emacs-devel@gnu.org; Tue, 21 Jan 2020 20:50:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iu5AV-0005Oj-O3 for emacs-devel@gnu.org; Tue, 21 Jan 2020 20:50:56 -0500 Original-Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:40812) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iu5AU-0005Nk-0U; Tue, 21 Jan 2020 20:50:54 -0500 Original-Received: by mail-qt1-x833.google.com with SMTP id v25so4404199qto.7; Tue, 21 Jan 2020 17:50:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=/pbzOS5mn71xJBus22sSYeOeWJ53Z4e4Sabkrx2IkwA=; b=bgihp/ZqWXu+cPQdxkja7hykoMpZG+/DRZa3w0UVOdzujpcSgIAfzua+BwEktqbsbS gcV6Q+n7sCVQy2LA0QamwTNFHCmhqdrzhR1a/nsiA7Jo5tLLrgbnEoVwcgkFLtfGG4P7 r8Vm26AI3Q8SK5M1f1KK0JNIgJzZpgVr9nbVKSrRRSD+NBnkEliFIY/KyH0WTnk0XzS6 2bKSW8GQ+28ngUtFd2ecjbpaoGBmRrz2RDFpO5AWeqpp7jQ/UbHDLz3r0Uw4VVPkQHZ5 udm6akaJbmItLhh6ycBzBc43uJHr42GTHJt99OAEHIiy3PnmQLVJ/rUBmbntBFv3DLDS TFdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=/pbzOS5mn71xJBus22sSYeOeWJ53Z4e4Sabkrx2IkwA=; b=grMG5VbryEVKDUzxvlft3LW9fVTjKnVD2XYZLq2+LAdyCUz3SxTDeIM3qAWGdvz+SK adjSFDcz0EwoHrujJhf97SgHkQf0HL2JoNMpOzVsrstzxEETf6rxABTMUsD9p26iTxRc x8uA6HZPQvAGZeyqLtfaJ+YYUFcc78eat0KrC15ixPL5nF/FFNoPvwNccsfXgJVgO4kt Coav+ltMn2O+2ssK4wCONvOMTZezi3KYQlf5lpA7w8LdRFJRTXk5I94O2Gb2fcpuSIte ZvSKWgJT8zMIUDFQaPhw+lH/wQ+nkwaOBCwzwnGCiCfieJGtcRMbpA25qBqZP4rObbPQ 4Xsw== X-Gm-Message-State: APjAAAU8HAkY7Z237MlOE6DiB+A9VxppWSlnYVkob7QrnX2PCxySixv3 94H4+0ty6gv32vIHCFF+w+F35B3N3xZanKsF X-Google-Smtp-Source: APXvYqwiKPVkOFy00kgEQc0+HQzHKq5wTlKFOZSak/pOUXMLBJuC6+/lUldi1XjLYHUWuc/rZv2hgg== X-Received: by 2002:aed:2d67:: with SMTP id h94mr4062684qtd.74.1579657851905; Tue, 21 Jan 2020 17:50:51 -0800 (PST) Original-Received: from [192.168.1.5] (c-174-60-229-153.hsd1.pa.comcast.net. [174.60.229.153]) by smtp.gmail.com with ESMTPSA id n190sm18388630qke.90.2020.01.21.17.50.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jan 2020 17:50:51 -0800 (PST) In-Reply-To: <83wo9mvwco.fsf@gnu.org> X-Mailer: Apple Mail (2.3608.40.2.2.4) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::833 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:244480 Archived-At: --Apple-Mail=_FBE92095-3CE5-49D9-A6C0-43D18922FCA1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >> So it seems the intension is to display source in new window, not = using only one window as I originally >> thought. I=E2=80=99d like to simplify it, put the decision logic into = one place. And then we can add customizability to it. >=20 > Thanks, sounds like a good plan to me. Here is my first attempt. I make every function that needs to display a = source buffer (only 2: gdb-goto-breakpoint, gud-display-line) use = gdb-display-source-buffer. Previously they either use (or = gdb-display-source-buffer display-buffer) or use (display-buffer).=20 Gdb-mi.el used to have a variable gdb-source-window, I changed it to = gdb-source-window-list. And now reusing a window is as simple as looking = at this list of windows. (No need to check for last-last-frame, etc).=20 I added a variable for maximum number of windows used for source buffer. = Right now the simple logic is to open as much windows as possible until = the max is reached, then we start to reuse windows. Creating new window = uses display-buffer-pop-up-window (I use this function just for = completeness, I would modify this part when adding customization, maybe = let user customize action for display-buffer?) Overall this patch doesn=E2=80=99t change the behavior except 1) new = window/not is now determined by gdb-maximum-source-window-count instead = of display-buffer 2) now gud also uses gdb=E2=80=99s display function, = so there is no check for gdb-mi vs gud anymore You=E2=80=99ll also notice that, when you quit, all the source windows = are left undeleted. That=E2=80=99s the original behavior and I have = another patch that restores the old window configuration the user have = before starting gdb. So I didn=E2=80=99t do anything about that. If you think this patch is fine, I=E2=80=99ll do these next: 1) add a = straightforward customization, preferably only one variable. 2) = currently gdb opens windows everywhere, I want to make it open in only = one continues area and maybe balance windows. Do you think this is worth = doing? Or it is suffice to let user customize the display-buffer action? Yuan --Apple-Mail=_FBE92095-3CE5-49D9-A6C0-43D18922FCA1 Content-Disposition: attachment; filename=simplify.patch Content-Type: application/octet-stream; x-unix-mode=0700; name="simplify.patch" Content-Transfer-Encoding: quoted-printable =46rom=2074a9a53ddf29b2caeeea0ddf3896418d59fada48=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Tue,=20= 21=20Jan=202020=2016:23:57=20-0500=0ASubject:=20[PATCH]=20Simplify=20= gdb-mi/gud=20display=20source=20buffer=20logic=0AMIME-Version:=201.0=0A= Content-Type:=20text/plain;=20charset=3DUTF-8=0A= Content-Transfer-Encoding:=208bit=0A=0A*=20lisp/progmodes/gdb-mi.el=20= (gdb-source-window):=20remove=0A(gdb-source-window-list,=20= gdb-max-source-window-count):=20new=0A(gdb-init-1,=20gdb-setup-windows,=20= gdb-restore-windows):=0Achange=20gdb-source-window=20to=20= gdb-source-window-list=0A(gdb-display-source-buffer):=20use=20new=20= logic=0A(gdb-goto-breakpoint):=20remove=20display-buffer=0Aand=20don=E2=80= =99t=20set=20gdb-source-buffer=20anymore=0A=0A*=20lisp/progmodes/gud.el=20= (gud-display-line):=20remove=20display-buffer=0Aand=20don=E2=80=99t=20= set=20gdb-source-buffer=20anymore;=20remove=20check=20for=20gdb-mi,=0Aso=20= we=20basically=20always=20set=20gdb-source-window-list=0A---=0A=20= lisp/progmodes/gdb-mi.el=20|=2050=20= +++++++++++++++++++++++++---------------=0A=20lisp/progmodes/gud.el=20=20= =20=20|=20=208=20++-----=0A=202=20files=20changed,=2034=20insertions(+),=20= 24=20deletions(-)=0A=0Adiff=20--git=20a/lisp/progmodes/gdb-mi.el=20= b/lisp/progmodes/gdb-mi.el=0Aindex=20e4233dacaf..27031e24f7=20100644=0A= ---=20a/lisp/progmodes/gdb-mi.el=0A+++=20b/lisp/progmodes/gdb-mi.el=0A@@=20= -211,7=20+211,11=20@@=20gdb-handler-list=0A=20(defvar=20= gdb-source-file-list=20nil=0A=20=20=20"List=20of=20source=20files=20for=20= the=20current=20executable.")=0A=20(defvar=20gdb-first-done-or-error=20= t)=0A-(defvar=20gdb-source-window=20nil)=0A+(defvar=20= gdb-source-window-list=20nil=0A+=20=20"List=20of=20windows=20used=20for=20= displaying=20source=20files.=0A+Sorted=20in=20most=20recently=20visited=20= first=20order.")=0A+(defvar=20gdb-max-source-window-count=202=0A+=20=20= "Maximum=20number=20of=20source=20windows=20to=20use.")=0A=20(defvar=20= gdb-inferior-status=20nil)=0A=20(defvar=20gdb-continuation=20nil)=0A=20= (defvar=20gdb-supports-non-stop=20nil)=0A@@=20-922,7=20+926,7=20@@=20= gdb-init-1=0A=20=09gdb-first-done-or-error=20t=0A=20=09= gdb-buffer-fringe-width=20(car=20(window-fringes))=0A=20=09gdb-debug-log=20= nil=0A-=09gdb-source-window=20nil=0A+=09gdb-source-window-list=20nil=0A=20= =09gdb-inferior-status=20nil=0A=20=09gdb-continuation=20nil=0A=20=20=20=20= =20=20=20=20=20gdb-buf-publisher=20'()=0A@@=20-2002,17=20+2006,29=20@@=20= gdb-show-stop-p=0A=20;;=20GDB=20frame=20(after=20up,=20down=20etc).=20=20= If=20no=20GDB=20frame=20is=20visible=20but=20the=20last=0A=20;;=20= visited=20breakpoint=20is,=20use=20that=20window.=0A=20(defun=20= gdb-display-source-buffer=20(buffer)=0A-=20=20(let*=20((last-window=20= (if=20gud-last-last-frame=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(get-buffer-window=0A-=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (gud-find-file=20(car=20gud-last-last-frame)))))=0A-=09=20(source-window=20= (or=20last-window=0A-=09=09=09=20=20=20=20(if=20(and=20gdb-source-window=0A= -=09=09=09=09=20=20=20=20=20(window-live-p=20gdb-source-window))=0A-=09=09= =09=09gdb-source-window))))=0A-=20=20=20=20(when=20source-window=0A-=20=20= =20=20=20=20(setq=20gdb-source-window=20source-window)=0A-=20=20=20=20=20= =20(set-window-buffer=20source-window=20buffer))=0A-=20=20=20=20= source-window))=0A+=20=20"Find=20a=20window=20to=20display=20BUFFER.=0A= +Always=20find=20a=20window=20to=20display=20buffer,=20and=20return=20= it."=0A+=20=20;;=20doesn't=20take=20care=20of=20setting=20up=20source=20= window(s)=0A+=20=20;;=20if=20`buffer'=20is=20already=20shown,=20use=20= that=20window=0A+=20=20(or=20(get-buffer-window=20buffer)=0A+=20=20=20=20= =20=20(progn=0A+=20=20=20=20=20=20=20=20;;=20first=20update=20window=20= list=0A+=20=20=20=20=20=20=20=20(setq=20gdb-source-window-list=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(cl-remove-if-not=20#'window-live-p=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20gdb-source-window-list))=0A+=20=20=20=20=20=20=20=20;;=20= create=20new=20or=20reuse?=0A+=20=20=20=20=20=20=20=20(if=20(>=20= gdb-max-source-window-count=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(length=20gdb-source-window-list))=0A+=20=20=20=20=20=20=20=20=20=20=20= =20;;=20create=20new=20window,=20push=20to=20list,=20return=20it=0A+=20=20= =20=20=20=20=20=20=20=20=20=20(car=20(push=20= (display-buffer-pop-up-window=20buffer=20nil)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20gdb-source-window-list))=0A= +=20=20=20=20=20=20=20=20=20=20;;=20reuse,=20we=20use=20the=20oldest=20= window=20and=20put=20that=20to=20front=0A+=20=20=20=20=20=20=20=20=20=20= (let=20((last-win=20(car=20(last=20gdb-source-window-list)))=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(rest=20(butlast=20= gdb-source-window-list)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (set-window-buffer=20last-win=20buffer)=0A+=20=20=20=20=20=20=20=20=20=20= =20=20(setq=20gdb-source-window-list=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(cons=20last-win=20rest))=0A+=20=20=20=20=20=20=20=20= =20=20=20=20last-win)))))=0A=20=0A=20=0A=20(defun=20gdbmi-start-with=20= (str=20offset=20match)=0A@@=20-3981,9=20+3997,7=20@@=20= gdb-goto-breakpoint=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(let*=20= ((buffer=20(find-file-noselect=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(file-exists-p=20= file)=20file=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(cdr=20(assoc=20bptno=20= gdb-location-alist)))))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(window=20(or=20(gdb-display-source-buffer=20buffer)=0A-=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(display-buffer=20buffer))))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(setq=20gdb-source-window=20window)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(window=20= (gdb-display-source-buffer=20buffer)))=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(with-current-buffer=20buffer=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(goto-char=20(point-min))=0A=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(forward-line=20(1-=20= (string-to-number=20line)))=0A@@=20-4597,7=20+4611,7=20@@=20= gdb-setup-windows=0A=20=20=20=20=20=20=20=20=20=20;;=20Put=20buffer=20= list=20in=20window=20if=20we=0A=20=20=20=20=20=20=20=20=20=20;;=20can't=20= find=20a=20source=20file.=0A=20=20=20=20=20=20=20=20=20=20= (list-buffers-noselect))))=0A-=20=20=20=20(setq=20gdb-source-window=20= (selected-window))=0A+=20=20=20=20(setq=20gdb-source-window-list=20(list=20= (selected-window)))=0A=20=20=20=20=20(let=20((win4=20= (split-window-right)))=0A=20=20=20=20=20=20=20(gdb-set-window-buffer=0A=20= =20=20=20=20=20=20=20(gdb-get-buffer-create=20'gdb-inferior-io)=20nil=20= win4))=0A@@=20-4639,7=20+4653,7=20@@=20gdb-restore-windows=0A=20=20=20=20= =20=20=20=20=20=20(if=20gud-last-last-frame=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(gud-find-file=20(car=20gud-last-last-frame))=0A=20=20=20=20= =20=20=20=20=20=20=20=20(gud-find-file=20gdb-main-file)))=0A-=20=20=20=20= =20=20=20=20(setq=20gdb-source-window=20win)))))=0A+=20=20=20=20=20=20=20= =20(setq=20gdb-source-window-list=20(list=20win))))))=0A=20=0A=20;;=20= Called=20from=20`gud-sentinel'=20in=20gud.el:=0A=20(defun=20gdb-reset=20= ()=0Adiff=20--git=20a/lisp/progmodes/gud.el=20b/lisp/progmodes/gud.el=0A= index=20567f452b93..ccf9026417=20100644=0A---=20a/lisp/progmodes/gud.el=0A= +++=20b/lisp/progmodes/gud.el=0A@@=20-2826,9=20+2826,7=20@@=20= gud-display-line=0A=20=09=20(buffer=0A=20=09=20=20(with-current-buffer=20= gud-comint-buffer=0A=20=09=20=20=20=20(gud-find-file=20true-file)))=0A-=09= =20(window=20(and=20buffer=0A-=09=09=20=20=20=20=20=20(or=20= (get-buffer-window=20buffer)=0A-=09=09=09=20=20(display-buffer=20buffer=20= '(nil=20(inhibit-same-window=20.=20t))))))=0A+=09=20(window=20(when=20= buffer=20(gdb-display-source-buffer=20buffer)))=0A=20=09=20(pos))=0A=20=20= =20=20=20(when=20buffer=0A=20=20=20=20=20=20=20(with-current-buffer=20= buffer=0A@@=20-2858,9=20+2856,7=20@@=20gud-display-line=0A=20=09=20=20=20= =20=20=20=20(widen)=0A=20=09=20=20=20=20=20=20=20(goto-char=20pos))))=0A=20= =20=20=20=20=20=20(when=20window=0A-=09(set-window-point=20window=20= gud-overlay-arrow-position)=0A-=09(if=20(eq=20gud-minor-mode=20'gdbmi)=0A= -=09=20=20=20=20(setq=20gdb-source-window=20window))))))=0A+=09= (set-window-point=20window=20gud-overlay-arrow-position)))))=0A=20=0A=20= ;;=20The=20gud-call=20function=20must=20do=20the=20right=20thing=20= whether=20its=20invoking=0A=20;;=20keystroke=20is=20from=20the=20GUD=20= buffer=20itself=20(via=20major-mode=20binding)=0A--=20=0A2.25.0=0A=0A= --Apple-Mail=_FBE92095-3CE5-49D9-A6C0-43D18922FCA1--