From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.bugs Subject: bug#18294: 24.3; gud and/or gdb: Add hooks to detect when a source file is visited during debugging Date: Tue, 19 Aug 2014 11:59:41 +0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1408424476 14685 80.91.229.3 (19 Aug 2014 05:01:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 Aug 2014 05:01:16 +0000 (UTC) To: 18294@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 19 07:01:10 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1XJbXh-0007tv-VX for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Aug 2014 07:01:10 +0200 Original-Received: from localhost ([::1]:47965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJbXh-0001k7-J4 for geb-bug-gnu-emacs@m.gmane.org; Tue, 19 Aug 2014 01:01:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJbXc-0001ih-OD for bug-gnu-emacs@gnu.org; Tue, 19 Aug 2014 01:01:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJbXa-0007yD-Qf for bug-gnu-emacs@gnu.org; Tue, 19 Aug 2014 01:01:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJbXa-0007y7-NT for bug-gnu-emacs@gnu.org; Tue, 19 Aug 2014 01:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XJbXa-00021O-6y for bug-gnu-emacs@gnu.org; Tue, 19 Aug 2014 01:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuri Khan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Aug 2014 05:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18294 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14084244047619 (code B ref -1); Tue, 19 Aug 2014 05:01:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Aug 2014 05:00:04 +0000 Original-Received: from localhost ([127.0.0.1]:46862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XJbWa-0001yE-0T for submit@debbugs.gnu.org; Tue, 19 Aug 2014 01:00:01 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43769) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XJbWV-0001xw-Hq for submit@debbugs.gnu.org; Tue, 19 Aug 2014 00:59:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJbWO-0006xf-1y for submit@debbugs.gnu.org; Tue, 19 Aug 2014 00:59:50 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:43459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJbWN-0006xU-VH for submit@debbugs.gnu.org; Tue, 19 Aug 2014 00:59:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJbWM-0001SG-4J for bug-gnu-emacs@gnu.org; Tue, 19 Aug 2014 00:59:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJbWI-0006w5-Ei for bug-gnu-emacs@gnu.org; Tue, 19 Aug 2014 00:59:46 -0400 Original-Received: from mail-ig0-x230.google.com ([2607:f8b0:4001:c05::230]:50694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJbWI-0006vv-6y for bug-gnu-emacs@gnu.org; Tue, 19 Aug 2014 00:59:42 -0400 Original-Received: by mail-ig0-f176.google.com with SMTP id hn18so9442428igb.9 for ; Mon, 18 Aug 2014 21:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=u7WRJsKgxlSdgG6lk+ZPBwXd0Iw2IL4q5Rab+z1aOkE=; b=GZhJX7xaY+CMKgPhuKpUwJgL/FDAx3mHcZt7zCRZ6flCtgiOtUfGacZBluxW/cV2wb 620L73repv6FrNdKqmOe0LYwYEwFbPRIoq+f1hsvK+v5EF8gMJMb5eql4QiwHcwsRmsQ VidW3qIf0sIPVYdZxkFqwbAinWyVoAdfUNnG8ISAk6wjSA3sGvcVIqDBBJ8odtm7FMI0 HfINSS8l53EJzlRje1K78WZaCngKI4Tgz5e8EUTb9gcnJFc9QagK9L5Vnk10NOdXwt5+ 923SNLC+toqob05Jcz0wXn7rN35xvt9DpER2B+K9FHba5dgyAB7c+o7K0+MgKCZX7Mf7 vPMw== X-Received: by 10.42.68.1 with SMTP id v1mr39652596ici.49.1408424381262; Mon, 18 Aug 2014 21:59:41 -0700 (PDT) Original-Received: by 10.107.6.30 with HTTP; Mon, 18 Aug 2014 21:59:41 -0700 (PDT) X-Google-Sender-Auth: PB0GBjdjhwgcnq5E6nlHcRIF54Y X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92526 Archived-At: Hello, I am writing a minor mode to control the debugger from a source buffer by pressing single-letter keystrokes, e.g. "n" for gud-next, etc. The mode itself is very simple =E2=80=94 it has a keymap, and it sets the buffe= r read-only while it is active so as to free these keys from their usual 'self-insert-command' bindings. I need to be able to enable this mode for the same buffers where gdb allows clicking in the fringe to set a breakpoint, and at the same time as gdb sets up reaction to these clicks. For that purpose, I currently advise the 'gdb-init-buffer' function. Additionally, I need to detect when debugging is finished, in order to disable the mode in all buffers, so that the user would be able to edit files again. Currently, I advise 'gdb-reset' and loop over all buffers, disabling the mode. It would be nice if gdb-mi.el provided hooks that I could add to instead of advising gdb functions. Implementation proposal: * Add a normal hook 'gdb-init-buffer-hook' that runs at the end of 'gdb-init-buffer' with the buffer being initialized still current. * Add a normal hook 'gdb-reset-hook' that runs at the end of 'gdb-reset'. Additional considerations: The mode I am writing might be useful for Gud backends other than gdbmi. To generalize to those, I would need the following hooks: * A hook that can be used to enable the mode. It needs to run at the start of a debugging session, once for each existing buffer visiting a source file of the program being debugged, with that buffer being current. Additionally, it needs to run when a new buffer is opened while debugging, iff that buffer is visiting a source file of the program being debugged. * A hook that can be used to disable the mode. It needs to run once when a debugging session ends. Alternatively, a hook that runs once for each buffer in which the above hook has previously ran. In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.10.7) of 2014-03-08 on lamiak, modified by Debian Windowing system distributor `The X.Org Foundation', version 11.0.11501000 System Description: Ubuntu 14.04.1 LTS Configured using: `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu' '--prefix=3D/usr' '--sharedstatedir=3D/var/lib' '--libexecdir=3D/usr/lib' '--localstatedir=3D/var/lib' '--infodir=3D/usr/share/info' '--mandir=3D/usr/share/man' '--with-pop=3Dyes' '--enable-locallisppath=3D/etc/emacs24:/etc/emacs:/usr/local/share/emacs/2= 4.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-l= isp:/usr/share/emacs/site-lisp' '--with-crt-dir=3D/usr/lib/x86_64-linux-gnu' '--with-x=3Dyes' '--with-x-toolkit=3Dgtk3' '--with-toolkit-scroll-bars' 'build_alias=3Dx86_64-linux-gnu' 'CFLAGS=3D-g -O2 -fstack-protector --param=3Dssp-buffer-size=3D4 -Wformat -Werror=3Dformat-security -Wall' 'LDFLAGS=3D-Wl,-Bsymbolic-functions -Wl,-z,relro' 'CPPFLAGS=3D-D_FORTIFY_SOURCE=3D2'' Important settings: value of $LC_MONETARY: en_US.UTF-8 value of $LC_NUMERIC: en_US.UTF-8 value of $LC_TIME: en_DK.utf8 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: Emacs-Lisp Minor modes in effect: global-whitespace-mode: t global-git-gutter-mode: t git-gutter-mode: t shell-dirtrack-mode: t show-paren-mode: t global-hl-line-mode: t cua-mode: t diff-auto-refine-mode: t auto-revert-mode: t yas-global-mode: t yas-minor-mode: t global-srecode-minor-mode: t global-ede-mode: t ede-minor-mode: t tabbar-mode: t desktop-save-mode: t server-mode: t tooltip-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Recent input: f g u d - m i n o r - m o d e C-g v g u d - m i n o r - m o d e - h o o k C-g M-x r e p o r Recent messages: Mark saved where search started Mark set Mark saved where search started [2 times] Quit Type "q" to restore previous buffer, to scroll help. byte-code: Beginning of buffer [3 times] mouse-2, RET: find variable's definition uncompressing gud.el.gz...done Note: file is write protected Here is not Git work tree [2 times] Quit [2 times] Load-path shadows: ~/.emacs.d/browse-kill-ring/browse-kill-ring hides /usr/share/emacs24/site-lisp/emacs-goodies-el/browse-kill-ring /usr/share/emacs/24.3/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup /usr/share/emacs24/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/24.3/lisp/textmodes/ispell /usr/share/emacs24/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/24.3/lisp/textmodes/flyspell Features: (pp misearch multi-isearch jka-compr find-func shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils cc-langs cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs gdb-mi bindat json gud ibuf-ext ibuffer windmove ede/dired persistent-soft pcache font-utils highlight-beyond-fill-column disp-table whitespace hi-lock sql-indent sql browse-kill-ring redo git-gutter tramp tramp-compat auth-source gnus-util mm-util mail-prsvr password-cache tramp-loaddefs shell pcomplete paren hl-line cua-base unicode-fonts warnings magit-key-mode magit package iswitchb ido esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc esh-groups eshell esh-module esh-mode esh-util ediff-merg ediff-diff ediff-wind ediff-help ediff-util ediff-mult ediff-init ediff view grep format-spec epa epg epg-config diff-mode autorevert git-rebase-mode thingatpt git-commit-mode log-edit pcvs-util add-log yasnippet dropdown-list semantic/bovine/gcc semantic/dep semantic/ia semantic/analyze/refs semantic/db-find semantic/db-ref semantic/analyze semantic/sort semantic/scope semantic/analyze/fcn semantic/db srecode/mode semantic/senator semantic/format semantic/ctxt semantic/wisent semantic/wisent/wisent semantic/decorate pulse srecode/insert srecode/filters srecode/args srecode/find srecode/map srecode/ctxt semantic/tag-ls semantic/find srecode/compile srecode/dictionary srecode/table srecode semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local vc-git ede/cpp-root ede/emacs ede/speedbar ede/files ede ede/base ede/auto ede/source eieio-base eieio-speedbar speedbar sb-image ezimage dframe eieio-custom wid-edit eieio byte-opt bytecomp byte-compile cconv cedet tabbar framemove advice help-fns advice-preload windcycle help-mode dired+ dired-x cl-macs gv dired-aux dired easymenu cl cl-lib desktop saveplace server derived debian-el debian-el-loaddefs pylint compile comint ansi-color ring haskell-mode-autoloads edmacro kmacro emacs-goodies-el emacs-goodies-custom emacs-goodies-loaddefs easy-mmode dpkg-dev-el dpkg-dev-el-loaddefs devhelp time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dbusbind dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)