From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#30044: Emacs: Gud-mode: Debugging with gud: Window switching problem Date: Wed, 10 Jan 2018 20:58:51 -0500 Message-ID: <87fu7dp350.fsf@users.sourceforge.net> References: <20180109123311.klciuvflkdgm23pf@clausfischer.com> <20180110111945.fugo7cknqysarnny@clausfischer.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1515635900 29109 195.159.176.226 (11 Jan 2018 01:58:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 11 Jan 2018 01:58:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: 30044@debbugs.gnu.org To: Claus Fischer Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 11 02:58:15 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZS8A-00070j-Hz for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Jan 2018 02:58:10 +0100 Original-Received: from localhost ([::1]:58524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZSAA-0004Xi-Az for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Jan 2018 21:00:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZSA3-0004Vu-8U for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2018 21:00:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZS9y-0003kA-Bb for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2018 21:00:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43647) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZS9y-0003jm-8i for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2018 21:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eZS9x-0002iT-SD for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2018 21:00:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Jan 2018 02:00:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30044 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30044-submit@debbugs.gnu.org id=B30044.151563594210356 (code B ref 30044); Thu, 11 Jan 2018 02:00:01 +0000 Original-Received: (at 30044) by debbugs.gnu.org; 11 Jan 2018 01:59:02 +0000 Original-Received: from localhost ([127.0.0.1]:51544 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZS90-0002gy-DO for submit@debbugs.gnu.org; Wed, 10 Jan 2018 20:59:02 -0500 Original-Received: from mail-io0-f178.google.com ([209.85.223.178]:37966) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZS8y-0002gS-3t for 30044@debbugs.gnu.org; Wed, 10 Jan 2018 20:59:00 -0500 Original-Received: by mail-io0-f178.google.com with SMTP id d11so1569857iog.5 for <30044@debbugs.gnu.org>; Wed, 10 Jan 2018 17:59:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=2o2m1M2S4pPJ2YLQrTkT30E6sqbwMhuK+z/5CFYKck0=; b=W0Om3DWl4uybY719/afbcpdqNXsmWRU6BUz2YZQ3vmPPjZZ4ast+sWaA0EESUuzykR URQkZ6MY0l2fdBkWWVV4vzwM2cn2dMN8k01Huy0rsv/h2r1mcu546ZuDzxsdc8kcthk5 IPqNp1txHvFV/j/umQ7bXYmUW9BQdh/X2Jz1kU56J/Cy2GyHmQmt9jux5RJS0iCJ3DwH DP1tspoj5VpfFolm1fTH+1xdozrKBznBUM6U9ih8qlV6mWpPCkVT3pTU6aipm0My0dtP uWKPYy1+e9kbHd8oAU6yA2NBJFQul8fzlgUy0UvgDw5CBINGlyLsde0Oejchz58T7FSS V5qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=2o2m1M2S4pPJ2YLQrTkT30E6sqbwMhuK+z/5CFYKck0=; b=e4EDOOBvsAjPJrfUzRchNgEQTW50eIOHCYqqmNzAdFtH2S7fn/fbBRW0YwHfUGgM4Q rXJGMqB0UYTOks3KXB1tI1nMP1K+/oDZ2Gdt/Pw9zgGMsayE23ytruhVHA1K6qH9xUHD jwwT9rmA95vWS4rn9X7mTRHBfGiIrT1qEO0WyAB/sBDxIJmkBgiMfmk3iCAJIvGosPYJ rwZ05Hwf4pmcBWpnUjb8fxcQJPJidUYSsNNX/G2Fqw+VBOjvzTxOufRnsc9hOQhr/cyX KsAY4qKkHs1pSzf3zaRpXI2qSLKBY2IJ/2+aXk2vvN2EqEfZLFCd6TCNpNUTtwctU4lb kfxg== X-Gm-Message-State: AKwxyteMUp5cFi6FZXWhpzp2d9TG6j7ZefjH0c4us8xRPEGapnq60BDT HkxQtw+hmxx3VH1JGNcncEvTUA== X-Google-Smtp-Source: ACJfBouA26of4YK/WoKK6sXABsJedBKLXrM3j4aZRYqLJgHqDF3DGAHkNgwVQCRtGgyec7WSLSsy5w== X-Received: by 10.107.8.214 with SMTP id h83mr132876ioi.214.1515635933992; Wed, 10 Jan 2018 17:58:53 -0800 (PST) Original-Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id 137sm4328211itl.36.2018.01.10.17.58.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2018 17:58:52 -0800 (PST) In-Reply-To: <20180110111945.fugo7cknqysarnny@clausfischer.com> (Claus Fischer's message of "Wed, 10 Jan 2018 12:19:45 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:142018 Archived-At: Claus Fischer writes: > If that is so, the solution for me would be simple: let gud not > remember the window, but let it search for the window with buffer > name *gud...* and switch to that one. I have only one such buffer. That is basically what we have already, relevant code excerpts below. When gdb prints that a breakpoint is hit, Emacs runs the process filter which gud-mode sets up, `gud-filter'. It uses `get-buffer-window' to find the corresponding window and switches to it while calling `gud-display-frame'. And then `gud-display-line' shows the source buffer in any window but the current one (i.e., the one showing the gdb interaction). So to fix this, we would need to follow along this code path and see where things go wrong. This will be pretty much impossible without a reliable way of triggering the problem, as suggested in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=520647#10 (defun gud-filter (proc string) ... (with-current-buffer (process-buffer proc) (setq process-window (and gud-last-frame (>= (point) (process-mark proc)) (get-buffer-window (current-buffer))))) ... ;; Put the arrow on the source line. ;; This must be outside of the save-excursion ;; in case the source file is our current buffer. (if process-window (with-selected-window process-window (gud-display-frame)) (defun gud-display-frame () ... (gud-display-line (car gud-last-frame) (cdr gud-last-frame)) ;; Make sure the file named TRUE-FILE is in a buffer that appears on the screen ;; and that its line LINE is visible. ;; Put the overlay-arrow on the line LINE in that buffer. ;; Most of the trickiness in here comes from wanting to preserve the current ;; region-restriction if that's possible. We use an explicit display-buffer ;; to get around the fact that this is called inside a save-excursion. (defun gud-display-line (true-file line) (let* ((last-nonmenu-event t) ; Prevent use of dialog box for questions. (buffer (with-current-buffer gud-comint-buffer (gud-find-file true-file))) (window (and buffer (or (get-buffer-window buffer) (display-buffer buffer '(nil (inhibit-same-window . t)))))) ...