From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Executing Emacs commands when a gdb breakpoint is hit Date: Fri, 24 Jan 2020 10:01:29 +0200 Message-ID: <83ftg5s2p2.fsf@gnu.org> References: <83o8uwvekv.fsf@gnu.org> <831rrrv2vq.fsf@gnu.org> <83d0batene.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="124982"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 24 09:02:16 2020 Return-path: Envelope-to: geh-help-gnu-emacs@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 1iutuy-000WTQ-0u for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 24 Jan 2020 09:02:16 +0100 Original-Received: from localhost ([::1]:38506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iutux-0000gk-69 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 24 Jan 2020 03:02:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48188) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iutuW-0000bA-I7 for help-gnu-emacs@gnu.org; Fri, 24 Jan 2020 03:01:53 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:44649) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iutuW-0005fu-CY for help-gnu-emacs@gnu.org; Fri, 24 Jan 2020 03:01:48 -0500 Original-Received: from [176.228.60.248] (port=2258 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iutuV-0003KB-Nj for help-gnu-emacs@gnu.org; Fri, 24 Jan 2020 03:01:48 -0500 In-reply-to: (message from Skip Montanaro on Thu, 23 Jan 2020 15:00:16 -0600) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122283 Archived-At: > From: Skip Montanaro > Date: Thu, 23 Jan 2020 15:00:16 -0600 > Cc: Help GNU Emacs > > But in general, I must admit I find this design somewhat strange. GDB > offers you 3 extension languages: the CLI scripting, Python, and Guile > Scheme. Why not use one of these to do what you want? this is how the > GDB developers intended for you to extend the debugger for doing these > kinds of jobs. If you use Guile, you could even write code that is > almost Emacs Lisp ;-) > > Note that I'm not really trying to script GDB. I'm trying to adjust the display in Emacs of the file which is being > compiled. It seems to me that the proper language for that is ELisp. Emacs displays stuff by following the responses from GDB. So injecting such responses (by scripting GDB) will eventually allow you to solve your problem, either entirely in the scripting commands, or if customizing what Emacs does via the existing hooks. My point is that you shouldn't ask yourself "how do I run an Emacs function when a breakpoint is hit", because there's no way of doing that. This question encourages the line of thinking that leads you to write code that cannot work well, because this line of thinking is based on incorrect assumptions. > If I had (for > example) two different stop functions in my list (I don't currently), it's not clear how I'd guarantee the two > functions didn't step on one anothers' toes. The hook function receives the parsed MI response as its argument, so each function can decide whether it does anything in each case.