From unknown Sun Aug 10 20:05:51 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#79144 <79144@debbugs.gnu.org> To: bug#79144 <79144@debbugs.gnu.org> Subject: Status: [PATCH] New debugger-trap function to break to GDB Reply-To: bug#79144 <79144@debbugs.gnu.org> Date: Mon, 11 Aug 2025 03:05:51 +0000 retitle 79144 [PATCH] New debugger-trap function to break to GDB reassign 79144 emacs submitter 79144 Jeremy Bryant severity 79144 normal tag 79144 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 01 19:20:03 2025 Received: (at submit) by debbugs.gnu.org; 1 Aug 2025 23:20:03 +0000 Received: from localhost ([127.0.0.1]:59014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uhz2g-000768-07 for submit@debbugs.gnu.org; Fri, 01 Aug 2025 19:20:03 -0400 Received: from lists.gnu.org ([2001:470:142::17]:36332) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uhz2c-00074Z-QD for submit@debbugs.gnu.org; Fri, 01 Aug 2025 19:20:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhz2F-0001sA-Dy for bug-gnu-emacs@gnu.org; Fri, 01 Aug 2025 19:19:35 -0400 Received: from out-188.mta0.migadu.com ([2001:41d0:1004:224b::bc]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uhz2C-0004M8-Bb for bug-gnu-emacs@gnu.org; Fri, 01 Aug 2025 19:19:35 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeremybryant.net; s=key1; t=1754090368; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=P1QEfvk8McVU6v/+qgGxkgg4yAGdeL1M8G45n8lJEnU=; b=RjSIkE0eMMyxYPZUKvAk6Riqx7suAdy6vcQJ1fAE+71gcrV70pFzSZWAMlq+vSD8V7Skf9 Osv7+W9HtZ/DBKwM+g+zsEuBcHFyTLwVCRSw6rvky5lhSLq/2OBimACD6HlWK7mMDjDmiG m7/3IR1A+PMge9hcVszJAS8QfNzDXqqElYsYP5g2K8ePye3l3ltp/Ci806lv0F7Ovy91Tq /Bm2dDLTx+Is6wy3hEA0i2eKyIXnmHEb6hkh7v1Bw/aOuvebPEFBJc+Wt5QkKHrhbEUXnR S1rrp/Hlbe45ZNDjKzewQ2cFigrv6BN7r8X4UW88STccmuNhUpwGw21NCe6hpA== From: Jeremy Bryant To: bug-gnu-emacs@gnu.org Subject: [PATCH] New debugger-trap function to break to GDB Date: Sat, 02 Aug 2025 00:19:26 +0100 Message-ID: <87qzxuy6ip.fsf@jeremybryant.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::bc; envelope-from=jb@jeremybryant.net; helo=out-188.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: , Eli Zaretskii , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Here is a patch to add a default command debugger-trap to break into GDB, together with a default breakpoint set in .gdbinit The immediate benefit for developers is a standard command to use where there isn't one at the moment, as explained in DEBUG, only general guidance. The long-term benefit is it can be the foundation for further work to enhance debugging in Emacs with GDB, with the ability to programmatically break into GDB, something I am working on as part of C/Lisp hybrid debugging aids. This patch has received substantial advice and reviewed by Eli. It is posted here for the benefit of the community for further discussion. To recap, we need a do-nothing primitive, whose sole purpose is to allow setting a breakpoint there to get control to GDB. redraw-display and similar functions are usually okay, but they could get in the way if what they do modifies Emacs in a way that interferes with debugging, for example if they remove some display artifact one is debugging, or run functions as side effect that modify the global state. Adding Paul Eggert as the main recent contributor to etc/DEBUG for thoughts. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-New-debugger-trap-function-to-break-to-GDB.patch >From 8f790c3fb884668a829b11ea00c1ffc6e4f37488 Mon Sep 17 00:00:00 2001 From: Jeremy Bryant Date: Wed, 23 Jul 2025 23:35:01 +0100 Subject: [PATCH] New debugger-trap function to break to GDB * src/eval.c: new primitive debugger-trap * src/.gdbinit: set breakpoint to Fdebugger_trap * etc/DEBUG: document it. Remove suggestion to use Fredraw_display. This do-nothing primitive gives control to GDB, and for debugging convenience a breakpoint is set by default in .gdbinit. --- etc/DEBUG | 11 ++++++----- src/.gdbinit | 5 +++++ src/eval.c | 10 ++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/etc/DEBUG b/etc/DEBUG index 25049ad42b4..44f19900c64 100644 --- a/etc/DEBUG +++ b/etc/DEBUG @@ -211,16 +211,17 @@ the debugger, but before running it, is the most efficient way of making sure control will be returned to the debugger when you need that. +There is a default function to give control to the debugger. It is +called debugger-trap. This is a do-nothing primitive, as a convenient +point to return control to the debugger. You can invoke interactively +with "M-x debugger-trap RET". The src/.gdbinit file in the Emacs source +distribution sets a breakpoint on this function. + 'Fsignal' is a very useful place to put a breakpoint in. All Lisp errors go through there. If you are only interested in errors that would fire the Lisp debugger, breaking at 'maybe_call_debugger' is useful. -Another technique for getting control to the debugger is to put a -breakpoint in some rarely used function. One such convenient function -is Fredraw_display, which you can invoke at will interactively with -"M-x redraw-display RET". - It is also useful to have a guaranteed way to return to the debugger at any arbitrary time. When using X, this is easy: type C-z at the window where you are interacting with GDB, and it will stop Emacs just diff --git a/src/.gdbinit b/src/.gdbinit index d3bfad59486..0eab7ac9afa 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -1314,6 +1314,11 @@ if defined_WINDOWSNT end end +# Break at default trap function to give control to GDB. +# Call from Emacs with M-x debugger-trap +break Fdebugger_trap + + # Put the Python code at the end of .gdbinit so that if GDB does not # support Python, GDB will do all the above initializations before # reporting an error. diff --git a/src/eval.c b/src/eval.c index 5e2b5bff796..baea44b8ce1 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3089,6 +3089,15 @@ FUNCTIONP (Lisp_Object object) return false; } +DEFUN ("debugger-trap", Fdebugger_trap, Sdebugger_trap, 0, 0, "", + doc: /* Trap execution flow and hand over control to GDB. +To use, set up a breakpoint to this function from GDB. +The function itself is a do-nothing primitive. */) + (void) +{ + return Qnil; +} + Lisp_Object funcall_general (Lisp_Object fun, ptrdiff_t numargs, Lisp_Object *args) { @@ -4615,4 +4624,5 @@ syms_of_eval (void) defsubr (&Sspecial_variable_p); DEFSYM (Qfunctionp, "functionp"); defsubr (&Sfunctionp); + defsubr (&Sdebugger_trap); } -- 2.47.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 01 20:29:51 2025 Received: (at submit) by debbugs.gnu.org; 2 Aug 2025 00:29:51 +0000 Received: from localhost ([127.0.0.1]:59403 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ui08E-0003RJ-6J for submit@debbugs.gnu.org; Fri, 01 Aug 2025 20:29:50 -0400 Received: from lists.gnu.org ([2001:470:142::17]:48074) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ui089-0003QP-1s for submit@debbugs.gnu.org; Fri, 01 Aug 2025 20:29:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ui081-0003fM-Qa for bug-gnu-emacs@gnu.org; Fri, 01 Aug 2025 20:29:38 -0400 Received: from mail.cs.ucla.edu ([131.179.128.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ui080-0008H8-0T; Fri, 01 Aug 2025 20:29:37 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 8DE703C010860; Fri, 1 Aug 2025 17:29:33 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id LU4LT_piYGHc; Fri, 1 Aug 2025 17:29:33 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 647423C0149D1; Fri, 1 Aug 2025 17:29:33 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 647423C0149D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1754094573; bh=ZSGFpwsoUSp/JnurqlSDUYqrmtOU7MMLn0aub+CA4VE=; h=Message-ID:Date:MIME-Version:To:From; b=KUT7iGKIkOZWvNwSlItLQDUIzYV3Lc1+NAN/Aaoyv8g3RXudy8hsflmzAEPdATrH1 tDJlTU8QjOcMY+WgjG2SC1QKmNFasXhARHGr3qqPiI9tu1BFSU3GafApFbAIbshIxp 1FXg4VMIcRNRHbX1n0IGTMhWl6a6gAsG6WI6vLlNZh7LF0gvhYrUPqnbBxRcZwrSVS pw0HbI5ZAbUU+f+rqH2TN/jeHuIGtLpJ7BLTf1cIf1hpw00Wcp+h6ipkJZwuu4C1Mu xO7hVNKmJujTZu9lqu98NT+XiJ4vhwahq/bubQ1XIN0R6FDstX1q1yu/uzgP4kii9T +AJEJTxlgJM5Q== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id iiqfITdK7acH; Fri, 1 Aug 2025 17:29:33 -0700 (PDT) Received: from penguin.cs.ucla.edu (47-154-30-222.fdr01.snmn.ca.ip.frontiernet.net [47.154.30.222]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id 43F1C3C010860; Fri, 1 Aug 2025 17:29:33 -0700 (PDT) Message-ID: Date: Fri, 1 Aug 2025 17:29:32 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] New debugger-trap function to break to GDB To: Jeremy Bryant , bug-gnu-emacs@gnu.org References: <87qzxuy6ip.fsf@jeremybryant.net> Content-Language: en-US From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <87qzxuy6ip.fsf@jeremybryant.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=131.179.128.66; envelope-from=eggert@cs.ucla.edu; helo=mail.cs.ucla.edu X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 2025-08-01 16:19, Jeremy Bryant wrote: > redraw-display and similar functions are usually okay, but they could > get in the way if what they do modifies Emacs in a way that interferes > with debugging In the past I've used Facos for this purpose, under the theory that nobody ever calls acos so I know a breakpoint there means I want the debugger trap. With that in mind I suggest documenting in the doc string that Emacs never calls this function except to do X, Y and Z, where X Y and Z are spelled out clearly. (I assume X Y and Z all have to do with debugging.) Also, shouldn't there be something about the new function in doc/lispref/debugging.texi? From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 01 22:54:15 2025 Received: (at 79144) by debbugs.gnu.org; 2 Aug 2025 02:54:15 +0000 Received: from localhost ([127.0.0.1]:60263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ui2Ny-0004t0-Sj for submit@debbugs.gnu.org; Fri, 01 Aug 2025 22:54:15 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:43380) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1ui2Nu-0004sS-2J for 79144@debbugs.gnu.org; Fri, 01 Aug 2025 22:54:12 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-24022261323so42358455ad.1 for <79144@debbugs.gnu.org>; Fri, 01 Aug 2025 19:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754103244; x=1754708044; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=9Ux5A4CrtjTXw/MF0XPUExu1A29eWWUTQEm0OoAfnf8=; b=UyadKOk/Ay3Z7KK0RgpUxtsJqPL0NYqAQLv96lRxOyc3e60y6ivuW7rMMK6xISZjIG Q2V65UL+OxvfDAyawCcsGd5gD2jriDylz5t/8/FVuyWt+3ihLWYlukeD0iUpwx5QAXmo 0Jjxpe2lxYVOkevE35nRn+WnZ+uF/xeeb3hdOGNXEJP8Mso+YbyuWEt/oS2mjM1fmrAd C0khDryIaXTwBZqW813SvA8SDw+NvxMr6gKbUJnGtRtF2wryQYmV6nclJcXCNT/pmd7J 1lxKDjz89wLiiLZ9uHtuvIglGzLWHI/9HkUR++ThmgJgTP+Pz9TuHn98mjSB22Cy4nZ3 ueZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754103244; x=1754708044; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9Ux5A4CrtjTXw/MF0XPUExu1A29eWWUTQEm0OoAfnf8=; b=t3MKxz5GG0pzzqvXNGnVzMoj++qa0LLJuzqXBWSrY5C9omXepH3bKSRa89KgZeX7oB zZty94SecmpKFpAPWCOZCTZE5dRdkIonQiWMxgKhFlVt+5RjVKZhZ1I2Ti1HGcDivth6 DIP/G9n2DY73XiN2iSfsYmJGJEQbyLfwYoMbcvy4cTSvOPhOYk6aYByU2Hki41buyN1M 8wRIkD5XAPxTrmHtR11ygkB61cLbbpCxj3xUr8+1z4vTnk/fiTYYzblBaJikPRh20Nqc pr5jJhvyaZ5TimPA+qHFKnPjyUP4ye1MnxFcl6kR1imJ5Yj1MGXoN6M5H6ED/w23WNG0 xaUQ== X-Forwarded-Encrypted: i=1; AJvYcCVOanl2fqAEKdmNpo7HXLGlED/YNI/nsEl6ywJ6lUQU99oIPfEpFfKyBElLuUH/oaNRznH6zQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxE57PtLEQj4gOPMMcx1ugMLjOhVpFdkeITf1lDCMVToq+cjwyH NWBxT9S1ykBFepEB5LuLcA2ce6eymCAuYc3+yxalwLhIXv0kvLQMUSoa X-Gm-Gg: ASbGncud33bdHYSrfbeb1Lc9FezmTX1HKHyxuBHyNgGqRKRkmylsnX38LbvZxA1lhSZ yQGIdiYCQEbjLigPKSgPoGoHKyByDsXe0+1dCGbp2YdJkp26HJz/te1qG9ytJNQQNybDD+uC3ft J3okIL0TO9wkeGRNDcuxpj64wC1N0RxGUP3Ii6JbhhQnMRX6aN2AyorIrXkaiCrBFgKAk9rV+yo MzSMqTUIfcajx8Js8Lo59PGGBe59e12xyaWDY3U5DILsEjRGNRlzgLNkPOPaaDncfJlUwYBDZCU uJL2zbJYq7bNBoIOLcNPjMxgaCqhNQeOAGi2vK2TvEoMQGp7cWVgFKXFLFK535Yp2WLKEBpfHLU BJN9/gw7haYyBjXB4/N4VkzyFs4q5AvppdaX7T7LT3IpNTJCDKdObwvs3E8p2KYNENLNyECmGQD UwH9PGZrP6m9xh X-Google-Smtp-Source: AGHT+IFFJRTsCUfG4ciCF5ukZg6AwsyjMiB+JjxPLtwICdgW9idVoaUD7Yp+B2se2cvyDd5pWU0VEw== X-Received: by 2002:a17:902:e5c6:b0:235:e1d6:2ac0 with SMTP id d9443c01a7336-24200d8cdc5mr115845585ad.24.1754103243840; Fri, 01 Aug 2025 19:54:03 -0700 (PDT) Received: from [192.168.1.2] (syn-076-168-144-128.res.spectrum.com. [76.168.144.128]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-241e899a8cdsm54835175ad.121.2025.08.01.19.54.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Aug 2025 19:54:03 -0700 (PDT) Message-ID: <5120c6ec-fd37-87e3-a257-88353a466886@gmail.com> Date: Fri, 1 Aug 2025 19:54:03 -0700 MIME-Version: 1.0 Subject: Re: bug#79144: [PATCH] New debugger-trap function to break to GDB Content-Language: en-US To: Jeremy Bryant , 79144@debbugs.gnu.org References: <87qzxuy6ip.fsf@jeremybryant.net> From: Jim Porter In-Reply-To: <87qzxuy6ip.fsf@jeremybryant.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79144 Cc: Eli Zaretskii , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 8/1/2025 4:19 PM, Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Here is a patch to add a default command debugger-trap to break into > GDB, together with a default breakpoint set in .gdbinit > The immediate benefit for developers is a standard command to use where > there isn't one at the moment, as explained in DEBUG, only general guidance. This looks like a good idea. It might be useful to document more thoroughly that this is for setting a breakpoint in GDB and friends, rather than in the Elisp debugger. (Unless the plan is to support the Elisp debugger too somehow?) From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 03:03:02 2025 Received: (at 79144) by debbugs.gnu.org; 2 Aug 2025 07:03:02 +0000 Received: from localhost ([127.0.0.1]:33442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ui6Gk-0002hX-Ah for submit@debbugs.gnu.org; Sat, 02 Aug 2025 03:03:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36694) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ui6Gi-0002h7-7V for 79144@debbugs.gnu.org; Sat, 02 Aug 2025 03:03:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ui6Gc-0003Lu-Tz; Sat, 02 Aug 2025 03:02:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=wqZlLzsZrvtkt3fcvK71Kf2VjivYQ1qyW4RukTL7rl0=; b=e3xOe3/LX/lD UVRUy+KEd3juWkqMhfWELPm5NSsrYc+49C6J2JDVeCq/T9DzaKQX6i1HKEo5+UYXCd8ptIpMGK4Yb lKXJNPu+5UQDB3MyuVdXkBx9853hcmY3UgTGqDSLg/8nPnLmcVDljkRKu2O7Nx7BujI/pwaJkAs5O Y9fC2YR1lxLLJLxI5OFxMTe5LDqYaUIPCiFroIwClOuy8RFm6Co1ltCMaaE+OB9bQYXnnkqt2BAMW tbNIcgbGU9Le9iShuh18nhay645O6sMA+h3BrPIGuzidx2xnzxHq+BJF4lGR8rMu2d7lSCR2h7eMh Ta55xnMeHF1FbQFTI/WKHw==; Date: Sat, 02 Aug 2025 10:02:51 +0300 Message-Id: <86y0s2rysk.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-Reply-To: (message from Paul Eggert on Fri, 1 Aug 2025 17:29:32 -0700) Subject: Re: [PATCH] New debugger-trap function to break to GDB References: <87qzxuy6ip.fsf@jeremybryant.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79144 Cc: jb@jeremybryant.net, 79144@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Fri, 1 Aug 2025 17:29:32 -0700 > Cc: Eli Zaretskii > From: Paul Eggert > > Also, shouldn't there be something about the new function in > doc/lispref/debugging.texi? That part of the manual doesn't currently describe debugging Emacs with GDB. When Jeremy finishes his work on C/Lisp hybrid debugging, the techniques that supports should indeed be added to that part of the manual. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 16:11:00 2025 Received: (at submit) by debbugs.gnu.org; 2 Aug 2025 20:11:00 +0000 Received: from localhost ([127.0.0.1]:38019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiIZH-00054C-S1 for submit@debbugs.gnu.org; Sat, 02 Aug 2025 16:11:00 -0400 Received: from lists.gnu.org ([2001:470:142::17]:59358) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uiIZF-00053Z-5f for submit@debbugs.gnu.org; Sat, 02 Aug 2025 16:10:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uiIYk-00024q-CO for bug-gnu-emacs@gnu.org; Sat, 02 Aug 2025 16:10:35 -0400 Received: from out-183.mta1.migadu.com ([2001:41d0:203:375::b7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uiIYh-0001LK-LE; Sat, 02 Aug 2025 16:10:25 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeremybryant.net; s=key1; t=1754165419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=v0pt8AdItESPzzoeqcU70xxRCt7Jl0ILzdQhbO/+5YY=; b=Z8a0FHLGN7aIohgk8THUCOmYsJkD7neOdiD+in3wlOejYf8UdH80qG90dcFXGdX/qJkWhf Z/LeR6zDi5NPP4LM+MhFtdhlbB5YT1oIKSwFvCMY5bP6+0tklq+AdkhAi8Pxastsey7cXp oObplyvSnxswPvWjyVE4Q8dkKqX5Xgvzd4KDi6E/gS2turXwKCH2y2vbDu6bxt3z1VQtsa wEmDHl1ytgNmVMVr2LAoZ8974l+pIPoC8+ogUVCbJ5YZOMjF9yzx57rensBJYFFZk2VsfQ wt/BYCgmfDxe8A/Q6Jupley7SfmEPiVKzKI9FJLsXVzl0zLP6Isl8A2pm47tZQ== From: Jeremy Bryant To: Paul Eggert Subject: Re: [PATCH] New debugger-trap function to break to GDB In-Reply-To: (Paul Eggert's message of "Fri, 1 Aug 2025 17:29:32 -0700") References: <87qzxuy6ip.fsf@jeremybryant.net> Date: Sat, 02 Aug 2025 21:10:14 +0100 Message-ID: <87a54hxz6h.fsf@jeremybryant.net> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::b7; envelope-from=jb@jeremybryant.net; helo=out-183.mta1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Paul Eggert writes: > On 2025-08-01 16:19, Jeremy Bryant wrote: >> redraw-display and similar functions are usually okay, but they could >> get in the way if what they do modifies Emacs in a way that interferes >> with debugging > > In the past I've used Facos for this purpose, under the theory that > nobody ever calls acos so I know a breakpoint there means I want the > debugger trap. > > With that in mind I suggest documenting in the doc string that Emacs > never calls this function except to do X, Y and Z, where X Y and Z are > spelled out clearly. (I assume X Y and Z all have to do with > debugging.) Thanks, the doc string currently says this: doc: /* Trap execution flow and hand over control to GDB. To use, set up a breakpoint to this function from GDB. The function itself is a do-nothing primitive. */) Would the following clarification be clearer from your perspective? doc: /* Trap execution flow and hand over control to GDB. To use, set up a breakpoint in GDB with break Fdebugger_trap This is done in the Emacs source distribution in src/.gdbinit. The function itself is a do-nothing primitive. It is reserved for debugging purposes, and not called by Emacs otherwise. */) From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 16:21:27 2025 Received: (at 79144) by debbugs.gnu.org; 2 Aug 2025 20:21:27 +0000 Received: from localhost ([127.0.0.1]:38061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiIjO-00009a-Ip for submit@debbugs.gnu.org; Sat, 02 Aug 2025 16:21:26 -0400 Received: from out-172.mta0.migadu.com ([2001:41d0:1004:224b::ac]:59921) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uiIjM-000096-My for 79144@debbugs.gnu.org; Sat, 02 Aug 2025 16:21:25 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeremybryant.net; s=key1; t=1754166077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LMYqd9teDOw6YTbdLyxbXtKODxeA0VcHyCWjmi2Ovxc=; b=rlIaisrOTHjcsX0t1YgX+defapSd58LxiUZ4rdk3EdrDbsBsoNb5CeLKTP4r+L31WwoPj8 FFI+xIc20kZKbKRaC/D9CqhCxsKycHG/3ggAJ6n7HWqLuLEWm7P1k6ytAhi/KNB81k2Y8r Xp4OqDx4rmjzlIyWR+GmHzT0SDBJ2bQRpTSeoJJV1nJ+3sfFa9uPgEZyL+ByfAaOGxWIvN AkMOgeyoYQp+dF8dZcOeIup4Kyj1UG9opQiLWYwRuDDfKYWG/ntOF6HEaZZBB0ydGZc5Dd tzsIZUsfZsC8esEsiO6fskL6gsV4Gm/Amc2F9LjbHBYx5gCMnSoRIQhBGefZtA== From: Jeremy Bryant To: Jim Porter Subject: Re: bug#79144: [PATCH] New debugger-trap function to break to GDB In-Reply-To: <5120c6ec-fd37-87e3-a257-88353a466886@gmail.com> (Jim Porter's message of "Fri, 1 Aug 2025 19:54:03 -0700") References: <87qzxuy6ip.fsf@jeremybryant.net> <5120c6ec-fd37-87e3-a257-88353a466886@gmail.com> Date: Sat, 02 Aug 2025 21:21:15 +0100 Message-ID: <874iupxyo4.fsf@jeremybryant.net> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 79144 Cc: 79144@debbugs.gnu.org, Paul Eggert , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jim Porter writes: > On 8/1/2025 4:19 PM, Jeremy Bryant via Bug reports for GNU Emacs, the > Swiss army knife of text editors wrote: >> Here is a patch to add a default command debugger-trap to break into >> GDB, together with a default breakpoint set in .gdbinit >> The immediate benefit for developers is a standard command to use where >> there isn't one at the moment, as explained in DEBUG, only general guidance. > > This looks like a good idea. It might be useful to document more > thoroughly that this is for setting a breakpoint in GDB and friends, > rather than in the Elisp debugger. (Unless the plan is to support the > Elisp debugger too somehow?) Thanks, maybe this can be clarified - what makes you think of elisp debugging in this version? The file debug.el? >From a user point of view, the proposed docstring doesn't mention Elisp, only GDB. It is proposed for debug.el (not edebug.el), for this generality, and due to the natural fit in this file, although admittedly. ;;; debug.el --- debuggers and related commands for Emacs Beyond the immediate benefit to developers, the plan and prototype is to use the Lisp debugger debug or edebug to then have the hybrid debugging, so that choice of file also makes sense for this future plan. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 02 16:58:08 2025 Received: (at 79144) by debbugs.gnu.org; 2 Aug 2025 20:58:08 +0000 Received: from localhost ([127.0.0.1]:38236 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiJIu-0005Qw-5o for submit@debbugs.gnu.org; Sat, 02 Aug 2025 16:58:08 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:46546) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uiJIr-0005QI-Km for 79144@debbugs.gnu.org; Sat, 02 Aug 2025 16:58:06 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-31f017262d9so2481249a91.1 for <79144@debbugs.gnu.org>; Sat, 02 Aug 2025 13:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754168279; x=1754773079; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=Am3K+EIhQ7NDwCt7GZBCIcTt+RLVXBJOiz6AIjeVwdI=; b=ebLeKLa5XNYysqHKEeLfyKG0YQ0kJIqoXCGbSn6pazmPo+nA0WcP9SvyBBGrEFMuzi tSS2DqQX/t8HUUkpsI9U3XOBtS6Y3sitsJm81MOZLZyCiEYpjyqwtGCqt28XQ+ZYG94i T2t3kZvAJhIijUbY3P6cgB+NYVxFpk8PzKDkcpbhc1LCPejIUx/B6v4eFE8PxtJgk3Nh gg28hPdydepoh6IH0UhVFlQ5+s58H+K+oP7kItDNzR+J1JqOPM9FEZrJRAnaZ64HqQGF Io1B+b1yN/X4588ov7Z/BQRC/tGlwbvZyIy/YPkg/+xsj/Rj+B1toaCXd3VrvsR3TK6w Y2Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754168279; x=1754773079; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Am3K+EIhQ7NDwCt7GZBCIcTt+RLVXBJOiz6AIjeVwdI=; b=cqlPfiKLFLzhTi+RBVeHaDPdtLxGgiWlycVQU7ZLqs5kG0TAjB86OnN9fXfxAiwc3O eJVGnaOT+AxgQMvLRUZkOTD+7wfiw/eKJyZk3xeJahwL3QJ8IHiK301u1naaZe/Yv5g+ j64dygkKoOgFCgy20egVHFR0f6zrmIh1e+AOzm02rFNPoQHaz+Pj0L7ilhKlGWF6cfsP D2l7/v+NzdEkBf7krtfkIb+xWQCZkGJMqpNdZkiWISU7oy0B47+NLRBHWaO/cmkYjPSc C7CEpSHGdrqfNV32ucS5m5imQ3/FyG8YJKntH+H7rKbcEN52/aB1cbo48A985nieKEAa SwPQ== X-Gm-Message-State: AOJu0YyKSNfEGPfpqlhRMbhKNus83e/MrAuDTTIU3xe/b3wZocsWEQHT Y9mYz5qy7SFLEYF3CCYWcCHzpnmXXh4+gJ91uRqdzFnXeYujq+EXS08z X-Gm-Gg: ASbGncsuEmwF/HshH1pBtHtqkLaQWo5zT1UELI5qhBE7zo26OTZGsbQmyk41HTrS0h9 crEPO8RDD4NIn2J5ACJ2qrG+yaHsdV7MJLP1XJAJ9UtIraXxMhJCF44iJyC+3eAF+tuuV1seaYZ q1SX9TDUzkdzu5qrTeY19tJMDX6FdjxJxJ15B51Ysx2Nqa8ghDb3kUcapAm81vqFuh7K6HzMJVW DQciHgcgL1VGDMD1QkltII3gAQkih4fE9nNEjG33vsX0yuedLK6dSHBPtL81xcwcyD+8bRkRsV+ bCusXX/7lQ8S6v6IHmlTTeVaxM2pvGqmBrrl6IOAQ8WDOViiMEgiNaYrGJFTeOZ7EFzbsckbe3F q2leScXJETBaHNxBa0JYxTed0AvyV3yX9kOzd+WKxrj9EkCC1CN7JDiCW7hpopHix6Ao4G4k3JY FP9A== X-Google-Smtp-Source: AGHT+IHf1341+QRdU0/IK1IC1kz7jvNjr4NFh4ydSE7rESFTYlfuSDI+m1gP37ofDP4R45xOeyDXSA== X-Received: by 2002:a17:90b:1e0d:b0:321:27d5:623e with SMTP id 98e67ed59e1d1-32127d5658amr1246971a91.23.1754168279418; Sat, 02 Aug 2025 13:57:59 -0700 (PDT) Received: from [192.168.1.2] (syn-076-168-144-128.res.spectrum.com. [76.168.144.128]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-3207eba6abbsm7917107a91.7.2025.08.02.13.57.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Aug 2025 13:57:58 -0700 (PDT) Message-ID: <7ab5a3c8-38ec-1907-6be0-8f405e3ca1d9@gmail.com> Date: Sat, 2 Aug 2025 13:57:58 -0700 MIME-Version: 1.0 Subject: Re: bug#79144: [PATCH] New debugger-trap function to break to GDB Content-Language: en-US To: Jeremy Bryant References: <87qzxuy6ip.fsf@jeremybryant.net> <5120c6ec-fd37-87e3-a257-88353a466886@gmail.com> <874iupxyo4.fsf@jeremybryant.net> From: Jim Porter In-Reply-To: <874iupxyo4.fsf@jeremybryant.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79144 Cc: 79144@debbugs.gnu.org, Paul Eggert , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 8/2/2025 1:21 PM, Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Thanks, maybe this can be clarified - what makes you think of elisp > debugging in this version? The file debug.el? Initially, just reading the patch, the notes in etc/DEBUG didn't mention which debugger, but after reading the rest of that file, I see the context is clearer there. For the 'debugger-trap' docstring though, it could be useful to point to the 'debug' command (which is roughly the Elisp debugger's equivalent), and possibly vice-versa. That way users can get redirected to the correct function from either docstring. > Beyond the immediate benefit to developers, the plan and prototype is to > use the Lisp debugger debug or edebug to then have the hybrid debugging, > so that choice of file also makes sense for this future plan. That would be very nice indeed. Debugging/instrumenting across the C/Lisp boundary is something I've never managed to do, and having a straightforward way to set it up would help a lot. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 03 11:42:35 2025 Received: (at submit) by debbugs.gnu.org; 3 Aug 2025 15:42:35 +0000 Received: from localhost ([127.0.0.1]:45259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiar5-0007y6-5D for submit@debbugs.gnu.org; Sun, 03 Aug 2025 11:42:35 -0400 Received: from lists.gnu.org ([2001:470:142::17]:44542) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uiar3-0007xl-Fj for submit@debbugs.gnu.org; Sun, 03 Aug 2025 11:42:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uiaqv-0000Cu-RW for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2025 11:42:26 -0400 Received: from mail.cs.ucla.edu ([131.179.128.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uiaqt-00014c-T0; Sun, 03 Aug 2025 11:42:25 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 10F883C0149CB; Sun, 3 Aug 2025 08:42:20 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id 1ZBG2ET0P3RZ; Sun, 3 Aug 2025 08:42:19 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id D9A9B3C0149D0; Sun, 3 Aug 2025 08:42:19 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu D9A9B3C0149D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1754235739; bh=hxSewj+O26MV92sNkfW4MT7Nbua8UT54DW9XFNLYxjA=; h=Message-ID:Date:MIME-Version:To:From; b=aUDjho8w5z3SaMmjqtWNaD3nnHtlBWypVfgcx4QstFfXSJFrc+ajxkZ92Y1fdN4yI ChEinPXXYZAogBLxbIf2WZd/cN8li7c7EI4Tzwnwvpxfq4cYeMPYt0ZRh7aprvEl3Z qnxg0UXf5uqPSyE8pBt8QSVesfgCKru3kYT9wqHZQtjo//HFffnN4eZFYC6JCpu/IS /jebveq6yROMAR664rFWgwJozLguYGJF80dIdb0A9KF4cqmlER8W/DFlKkjH3H9q9B V8WLv/N7lLrgy/vB4koPgzRHsyLVHLw4N5zSrcBQkk+OmO0DdnzvrCuY7UQmAZS7YX VDCyWOtzsK4lw== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id CVdRr3GS2q4f; Sun, 3 Aug 2025 08:42:19 -0700 (PDT) Received: from penguin.cs.ucla.edu (unknown [47.154.30.222]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id BA2223C0149CB; Sun, 3 Aug 2025 08:42:19 -0700 (PDT) Message-ID: <81dda8d0-f947-43d1-947f-74017971aca7@cs.ucla.edu> Date: Sun, 3 Aug 2025 08:42:19 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] New debugger-trap function to break to GDB To: Jeremy Bryant References: <87qzxuy6ip.fsf@jeremybryant.net> <87a54hxz6h.fsf@jeremybryant.net> Content-Language: en-US From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <87a54hxz6h.fsf@jeremybryant.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=131.179.128.66; envelope-from=eggert@cs.ucla.edu; helo=mail.cs.ucla.edu X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 2025-08-02 13:10, Jeremy Bryant wrote: > Would the following clarification be clearer from your perspective? > > doc: /* Trap execution flow and hand over control to GDB. > To use, set up a breakpoint in GDB with > break Fdebugger_trap > This is done in the Emacs source distribution in src/.gdbinit. > > The function itself is a do-nothing primitive. It is reserved for > debugging purposes, and not called by Emacs otherwise. */) Yes, thanks. Some minor wording tweaks, which make it easier for me to understand: Trap execution flow and hand over control to GDB. The Emacs source file src/.gdbinit uses this via the GDB command "break Fdebugger trap". This function has no effect. It is reserved for debugging, and is not called by Emacs otherwise. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 03 17:41:45 2025 Received: (at submit) by debbugs.gnu.org; 3 Aug 2025 21:41:45 +0000 Received: from localhost ([127.0.0.1]:46132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uigSf-0003SU-3d for submit@debbugs.gnu.org; Sun, 03 Aug 2025 17:41:45 -0400 Received: from lists.gnu.org ([2001:470:142::17]:33554) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uigSc-0003S4-IO for submit@debbugs.gnu.org; Sun, 03 Aug 2025 17:41:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uigSU-0003Yi-Oz for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2025 17:41:34 -0400 Received: from out-173.mta0.migadu.com ([2001:41d0:1004:224b::ad]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uigSS-0005R6-GZ for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2025 17:41:34 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeremybryant.net; s=key1; t=1754257280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QhWAZSG2dRWULgODJQJsoUAVRGq7P2IuV8uyJYjdfJw=; b=YfA/wsE7CZnkcSNnxt2tgII03P9q+DxsMRI/S/rJ48la4PY91bnjvP5RebqgrKaepEY3fR E/tNvOiQRDsly5nGx+6qNerbFzkA6P42LTVnhbrb0V78IpzI7FHPyg4cjDsmGSzuMtKaWb wB1jtNhT83iQ/vi1aL4FSux11iaTvZKUbu3zGTZdykLR2fhSc0Sgoz4r3mx1NZOMDxGanX qYtJdTJKhiG/v4bQqbVXciNOr4To8kdvAs67e5fT+d8sVzL6noj4EGi0ndEYDV2ai0l3ll DF/R+bE02iRq+iPHJBSiQR5F/cjMxfeDe0f09XgF0cCF9EAA1F5SFkf+ACxlTQ== From: Jeremy Bryant To: Paul Eggert Subject: Re: [PATCH] New debugger-trap function to break to GDB In-Reply-To: <81dda8d0-f947-43d1-947f-74017971aca7@cs.ucla.edu> (Paul Eggert's message of "Sun, 3 Aug 2025 08:42:19 -0700") References: <87qzxuy6ip.fsf@jeremybryant.net> <87a54hxz6h.fsf@jeremybryant.net> <81dda8d0-f947-43d1-947f-74017971aca7@cs.ucla.edu> Date: Sun, 03 Aug 2025 22:41:18 +0100 Message-ID: <87sei8w0ap.fsf@jeremybryant.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::ad; envelope-from=jb@jeremybryant.net; helo=out-173.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit Cc: Jim Porter , bug-gnu-emacs@gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Paul Eggert writes: > On 2025-08-02 13:10, Jeremy Bryant wrote: >> Would the following clarification be clearer from your perspective? >> doc: /* Trap execution flow and hand over control to GDB. >> To use, set up a breakpoint in GDB with >> break Fdebugger_trap >> This is done in the Emacs source distribution in src/.gdbinit. >> The function itself is a do-nothing primitive. It is reserved for >> debugging purposes, and not called by Emacs otherwise. */) > > Yes, thanks. Some minor wording tweaks, which make it easier for me to > understand: > > Trap execution flow and hand over control to GDB. The Emacs source > file src/.gdbinit uses this via the GDB command "break Fdebugger > trap". > > This function has no effect. It is reserved for debugging, and is not > called by Emacs otherwise. OK, revised patch attached for consideration. The change is in the docstring, incorporating your suggestion, Paul, as well as the addition proposed by Jim, at the end. What do people think of this change now? Extract of patch for the docstring:- DEFUN ("debugger-trap", Fdebugger_trap, Sdebugger_trap, 0, 0, "", doc: /* Trap execution flow and hand over control to GDB. The Emacs source file src/.gdbinit uses this via the GDB command "break Fdebugger_trap". This function has no effect. It is reserved for debugging, and is not called by Emacs otherwise. For Lisp debugging see debug, as well as edebug, in the manual: "(elisp) Debugging". */) (void) { return Qnil; } --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-New-debugger-trap-function-to-break-to-GDB.patch >From 0a8dc27576090e863c92a0abc5461b0241714313 Mon Sep 17 00:00:00 2001 From: Jeremy Bryant Date: Wed, 23 Jul 2025 23:35:01 +0100 Subject: [PATCH] New debugger-trap function to break to GDB * src/eval.c: new primitive debugger-trap * src/.gdbinit: set breakpoint to Fdebugger_trap * etc/DEBUG: document it. Remove suggestion to use Fredraw_display. This do-nothing primitive gives control to GDB, and for debugging convenience a breakpoint is set by default in .gdbinit. --- etc/DEBUG | 11 ++++++----- src/.gdbinit | 5 +++++ src/eval.c | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/etc/DEBUG b/etc/DEBUG index 25049ad42b4..44f19900c64 100644 --- a/etc/DEBUG +++ b/etc/DEBUG @@ -211,16 +211,17 @@ the debugger, but before running it, is the most efficient way of making sure control will be returned to the debugger when you need that. +There is a default function to give control to the debugger. It is +called debugger-trap. This is a do-nothing primitive, as a convenient +point to return control to the debugger. You can invoke interactively +with "M-x debugger-trap RET". The src/.gdbinit file in the Emacs source +distribution sets a breakpoint on this function. + 'Fsignal' is a very useful place to put a breakpoint in. All Lisp errors go through there. If you are only interested in errors that would fire the Lisp debugger, breaking at 'maybe_call_debugger' is useful. -Another technique for getting control to the debugger is to put a -breakpoint in some rarely used function. One such convenient function -is Fredraw_display, which you can invoke at will interactively with -"M-x redraw-display RET". - It is also useful to have a guaranteed way to return to the debugger at any arbitrary time. When using X, this is easy: type C-z at the window where you are interacting with GDB, and it will stop Emacs just diff --git a/src/.gdbinit b/src/.gdbinit index d3bfad59486..0eab7ac9afa 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -1314,6 +1314,11 @@ if defined_WINDOWSNT end end +# Break at default trap function to give control to GDB. +# Call from Emacs with M-x debugger-trap +break Fdebugger_trap + + # Put the Python code at the end of .gdbinit so that if GDB does not # support Python, GDB will do all the above initializations before # reporting an error. diff --git a/src/eval.c b/src/eval.c index 5e2b5bff796..ab2d53815de 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3089,6 +3089,21 @@ FUNCTIONP (Lisp_Object object) return false; } +DEFUN ("debugger-trap", Fdebugger_trap, Sdebugger_trap, 0, 0, "", + doc: /* Trap execution flow and hand over control to GDB. +The Emacs source file src/.gdbinit uses this via the GDB command +"break Fdebugger_trap". + +This function has no effect. It is reserved for debugging, and is not +called by Emacs otherwise. + +For Lisp debugging see debug, as well as edebug, in the manual: +"(elisp) Debugging". */) + (void) +{ + return Qnil; +} + Lisp_Object funcall_general (Lisp_Object fun, ptrdiff_t numargs, Lisp_Object *args) { @@ -4615,4 +4630,5 @@ syms_of_eval (void) defsubr (&Sspecial_variable_p); DEFSYM (Qfunctionp, "functionp"); defsubr (&Sfunctionp); + defsubr (&Sdebugger_trap); } -- 2.47.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 03 18:01:41 2025 Received: (at submit) by debbugs.gnu.org; 3 Aug 2025 22:01:41 +0000 Received: from localhost ([127.0.0.1]:46189 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uiglw-0004gl-Q7 for submit@debbugs.gnu.org; Sun, 03 Aug 2025 18:01:41 -0400 Received: from lists.gnu.org ([2001:470:142::17]:35084) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uiglu-0004g8-Dy for submit@debbugs.gnu.org; Sun, 03 Aug 2025 18:01:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uiglm-0006pi-Gu for bug-gnu-emacs@gnu.org; Sun, 03 Aug 2025 18:01:30 -0400 Received: from mail.cs.ucla.edu ([131.179.128.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uiglj-0000Xy-LW; Sun, 03 Aug 2025 18:01:30 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 2B8BA3C0149D1; Sun, 3 Aug 2025 15:01:23 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id CJ8lfecloOrl; Sun, 3 Aug 2025 15:01:23 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 039B43C0149D0; Sun, 3 Aug 2025 15:01:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 039B43C0149D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1754258483; bh=yvlui+3gyMNXr2Airkj1R0A62umWRZ4y4q8WPwP7OZ8=; h=Message-ID:Date:MIME-Version:To:From; b=AEU++iOlk70lGMB2nunlIP3bvq1W8QEVgcqcApvAUBvfgvqH+fVC9q+j7uvj24ka7 OYMaKKaZiVScpBpJj3LrA747xOIwFR3hd8730i06ur7vfI0d2wJPfzJfGFjQ7pNMjx Q5yMLuydx9xJR2tWC21Ewb9SwtDUox7FswdHz4RnlUVyTXUiQehBrRcB1IeGW1Fb91 sA01JiVCLH+8Rrqd02hC/DtN/6hOdcI0bOdJt7FMxkeITnaIZJIa1RQXZbIs5hbiHC N5tAClECx04cfmMLTbFk1suBb0+w6wE/TaSKU6a+XGTFybTJDKeCW8vB0L0wOAEJVG 9G3xIrRgkbPnQ== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id PSdZONeYrhpf; Sun, 3 Aug 2025 15:01:22 -0700 (PDT) Received: from penguin.cs.ucla.edu (47-154-30-222.fdr01.snmn.ca.ip.frontiernet.net [47.154.30.222]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id D1C193C0149D1; Sun, 3 Aug 2025 15:01:22 -0700 (PDT) Message-ID: <6ac61dc9-8dd3-4ae5-bfa3-48a9f12ec61d@cs.ucla.edu> Date: Sun, 3 Aug 2025 15:01:22 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] New debugger-trap function to break to GDB To: Jeremy Bryant References: <87qzxuy6ip.fsf@jeremybryant.net> <87a54hxz6h.fsf@jeremybryant.net> <81dda8d0-f947-43d1-947f-74017971aca7@cs.ucla.edu> <87sei8w0ap.fsf@jeremybryant.net> Content-Language: en-US From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <87sei8w0ap.fsf@jeremybryant.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=131.179.128.66; envelope-from=eggert@cs.ucla.edu; helo=mail.cs.ucla.edu X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: Jim Porter , bug-gnu-emacs@gnu.org, Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Thanks, looks good to me. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 07 09:40:48 2025 Received: (at 79144-done) by debbugs.gnu.org; 7 Aug 2025 13:40:48 +0000 Received: from localhost ([127.0.0.1]:34126 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uk0rP-0008WI-Qg for submit@debbugs.gnu.org; Thu, 07 Aug 2025 09:40:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42560) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uk0rN-0008W0-Az for 79144-done@debbugs.gnu.org; Thu, 07 Aug 2025 09:40:46 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uk0rG-0006xC-Ni; Thu, 07 Aug 2025 09:40:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=thR9uV1znB0+24btrJPZvSI8Z5KlWzxlL6QZr9/GS74=; b=UwoUK4jl8Yj+ 7wYwTtihcyDkLm1xBVzGyh56Om84sNs/QSXr9qFE8sK50JTmopmR+D8VaHYe/k5VzQEDcSxfHaLVN aL2R085vqKOSUYHFbl55CWtVVchrTmHJbchys2+KCs89dMIcPA4LJ3an+AUtRkKFJshUa7B0OQUmn kSic98I6fIxmsk1PXUCOymC9lDc+kaIfchOTxPrFbdGF8TkSrHXo8rUhT9UoB2/tThcMHWIAslN+g f6mtzLhTgqwgXzTXPUzTZCNb3MLW+dDhmhmI5pHp4tSz2eJ0fAWG/gP/dn4GlbtqXjK6zZV7PAhSb 2gjrsOoYJf68OYOtErfCrw==; Date: Thu, 07 Aug 2025 16:40:34 +0300 Message-Id: <865xezqmgd.fsf@gnu.org> From: Eli Zaretskii To: Jeremy Bryant In-Reply-To: <87sei8w0ap.fsf@jeremybryant.net> (message from Jeremy Bryant on Sun, 03 Aug 2025 22:41:18 +0100) Subject: Re: [PATCH] New debugger-trap function to break to GDB References: <87qzxuy6ip.fsf@jeremybryant.net> <87a54hxz6h.fsf@jeremybryant.net> <81dda8d0-f947-43d1-947f-74017971aca7@cs.ucla.edu> <87sei8w0ap.fsf@jeremybryant.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79144-done Cc: jporterbugs@gmail.com, 79144-done@debbugs.gnu.org, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Jeremy Bryant > Cc: bug-gnu-emacs@gnu.org, Eli Zaretskii , Jim Porter > > Date: Sun, 03 Aug 2025 22:41:18 +0100 > > OK, revised patch attached for consideration. > > The change is in the docstring, incorporating your suggestion, Paul, as > well as the addition proposed by Jim, at the end. > > What do people think of this change now? Thanks, I've now installed this on the master branch, with a few minor followup changes in the documentation parts, and I'm closing this.