* How to highlight the offending line of code with edebug @ 2022-12-22 21:09 Davin Pearson 2022-12-22 21:13 ` Davin Pearson 0 siblings, 1 reply; 10+ messages in thread From: Davin Pearson @ 2022-12-22 21:09 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 590 bytes --] When I write the following code: (progn (setq edebug-on-error t) (setq edebug-all-defs t)) (foo) (defun foo () tomcat ) How do I invoke the edebug debugger when you get an error: Symbol’s value as variable is void: tomcat I want the debugger to point to the offending line of code, in this case tomcat. The way that I currently find errors such as these is to put checkpoints on every second line except the last line of defuns. However this approach is rather cumbersome as I have to add a lot of checkpoints and then remove them when I find the bug. [-- Attachment #2: Type: text/html, Size: 749 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2022-12-22 21:09 How to highlight the offending line of code with edebug Davin Pearson @ 2022-12-22 21:13 ` Davin Pearson 2022-12-23 7:20 ` Eli Zaretskii 0 siblings, 1 reply; 10+ messages in thread From: Davin Pearson @ 2022-12-22 21:13 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 692 bytes --] I have fixed a bug in an earlier email where (foo) was called before foo was defined. When I write the following code: (progn (setq edebug-on-error t) (setq edebug-all-defs t)) (defun foo () tomcat ) (foo) How do I invoke the edebug debugger when you get an error: Symbol’s value as variable is void: tomcat I want the debugger to point to the offending line of code, in this case tomcat. The way that I currently find errors such as these is to put checkpoints on every second line except the last line of defuns. However this approach is rather cumbersome as I have to add a lot of checkpoints and then remove them when I find the bug. *Davin.* [-- Attachment #2: Type: text/html, Size: 914 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2022-12-22 21:13 ` Davin Pearson @ 2022-12-23 7:20 ` Eli Zaretskii 2022-12-23 7:36 ` Michael Welsh Duggan 0 siblings, 1 reply; 10+ messages in thread From: Eli Zaretskii @ 2022-12-23 7:20 UTC (permalink / raw) To: Davin Pearson; +Cc: emacs-devel > From: Davin Pearson <davin.pearson@gmail.com> > Date: Fri, 23 Dec 2022 10:13:33 +1300 > > When I write the following code: > > (progn > (setq edebug-on-error t) > (setq edebug-all-defs t)) > > (defun foo () > tomcat > ) > (foo) > > How do I invoke the edebug debugger when you get an error: I don't think you can. Edebug requires that you instrument the function(s) you want to debug in advance. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2022-12-23 7:20 ` Eli Zaretskii @ 2022-12-23 7:36 ` Michael Welsh Duggan 2022-12-23 8:39 ` Eli Zaretskii 0 siblings, 1 reply; 10+ messages in thread From: Michael Welsh Duggan @ 2022-12-23 7:36 UTC (permalink / raw) To: Davin Pearson; +Cc: emacs-devel Eli Zaretskii <eliz@gnu.org> writes: >> From: Davin Pearson <davin.pearson@gmail.com> >> Date: Fri, 23 Dec 2022 10:13:33 +1300 >> >> When I write the following code: >> >> (progn >> (setq edebug-on-error t) >> (setq edebug-all-defs t)) >> >> (defun foo () >> tomcat >> ) >> (foo) >> >> How do I invoke the edebug debugger when you get an error: > > I don't think you can. Edebug requires that you instrument the > function(s) you want to debug in advance. An approach to this is to use `M-x toggle-debug-on-error` and then run the offending command. That will get you a backtrace with which you can determine what function it is actually failing within. Then you can instrument that function with edebug, toggle debug-on-error again, and run again. -- Michael Welsh Duggan (md5i@md5i.com) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2022-12-23 7:36 ` Michael Welsh Duggan @ 2022-12-23 8:39 ` Eli Zaretskii 2022-12-26 0:54 ` Davin Pearson 0 siblings, 1 reply; 10+ messages in thread From: Eli Zaretskii @ 2022-12-23 8:39 UTC (permalink / raw) To: Michael Welsh Duggan; +Cc: davin.pearson, emacs-devel > From: Michael Welsh Duggan <mwd@md5i.com> > Cc: emacs-devel@gnu.org > Date: Fri, 23 Dec 2022 02:36:15 -0500 > > Eli Zaretskii <eliz@gnu.org> writes: > > >> How do I invoke the edebug debugger when you get an error: > > > > I don't think you can. Edebug requires that you instrument the > > function(s) you want to debug in advance. > > An approach to this is to use `M-x toggle-debug-on-error` and then run > the offending command. That will get you a backtrace with which you can > determine what function it is actually failing within. Then you can > instrument that function with edebug, toggle debug-on-error again, and > run again. Yes, that's what everyone does. But note that even after instrumenting the offending function, there's AFAIK no way of asking Edebug to kick in only when the error happens. Instead, you need to step through the function and see where it signals an error. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2022-12-23 8:39 ` Eli Zaretskii @ 2022-12-26 0:54 ` Davin Pearson 2022-12-26 12:29 ` Eli Zaretskii 0 siblings, 1 reply; 10+ messages in thread From: Davin Pearson @ 2022-12-26 0:54 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Michael Welsh Duggan, emacs-devel [-- Attachment #1: Type: text/plain, Size: 1177 bytes --] Consider the following code: (progn (defun foo () tomcat ) (defun bar () (foo)) ) (bar) When I instrument the foo and bar defuns for debugging by entering the command C-u M-C-x over the (progn ...) sexp and pressing the "n" key it comes with a black triangle next to tomcat, thus indicating that we are stepping through the foo function which is what I want. The error message is this: edebug-after: Symbol’s value as variable is void: tomcat This is all good. What I need to know is how to instrument every function for debugging. I tried the following command at the top of my ~/.emacs file: (progn (setq edebug-on-error t) (setq edebug-all-defs t)) When I put the above foo/bar/tomcat code in another file and I try to instrument the foo and bar methods for debugging, again with C-u M-C-x it comes back with the following error: bar: Symbol’s value as variable is void: tomcat Note that there is no black triangle next to the tomcat sexp, indicating we are using the debug module and not the edebug module, which is not what I want. How do I get every function marked as instrumented? TIA, [-- Attachment #2: Type: text/html, Size: 1331 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2022-12-26 0:54 ` Davin Pearson @ 2022-12-26 12:29 ` Eli Zaretskii 2023-01-02 0:27 ` Davin Pearson 0 siblings, 1 reply; 10+ messages in thread From: Eli Zaretskii @ 2022-12-26 12:29 UTC (permalink / raw) To: Davin Pearson; +Cc: mwd, emacs-devel > From: Davin Pearson <davin.pearson@gmail.com> > Date: Mon, 26 Dec 2022 13:54:39 +1300 > Cc: Michael Welsh Duggan <mwd@md5i.com>, emacs-devel@gnu.org > > Consider the following code: > > (progn > (defun foo () > tomcat > ) > (defun bar () > (foo)) > ) > > (bar) > > When I instrument the foo and bar defuns for debugging by > entering the command C-u M-C-x over the (progn ...) sexp and > pressing the "n" key it comes with a black triangle next to > tomcat, thus indicating that we are stepping through the foo > function which is what I want. > > The error message is this: > > edebug-after: Symbol’s value as variable is void: tomcat > > This is all good. What I need to know is how to instrument every > function for debugging. I tried the following command at > the top of my ~/.emacs file: > > (progn > (setq edebug-on-error t) > (setq edebug-all-defs t)) > > When I put the above foo/bar/tomcat code in another file and I > try to instrument the foo and bar methods for debugging, again > with C-u M-C-x it comes back with the following error: > > bar: Symbol’s value as variable is void: tomcat > > Note that there is no black triangle next to the tomcat sexp, > indicating we are using the debug module and not the edebug > module, which is not what I want. > > How do I get every function marked as instrumented? According to the manual: If ‘edebug-all-defs’ is non-‘nil’, then the commands ‘eval-region’, ‘eval-current-buffer’, and ‘eval-buffer’ also instrument any definitions they evaluate. Similarly, ‘edebug-all-forms’ controls whether ‘eval-region’ should instrument _any_ form, even non-defining forms. This doesn’t apply to loading or evaluations in the minibuffer. The command ‘M-x edebug-all-forms’ toggles this option. Another command, ‘M-x edebug-eval-top-level-form’, is available to instrument any top-level form regardless of the values of ‘edebug-all-defs’ and ‘edebug-all-forms’. ‘edebug-defun’ is an alias for ‘edebug-eval-top-level-form’. I think this answers your questions. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2022-12-26 12:29 ` Eli Zaretskii @ 2023-01-02 0:27 ` Davin Pearson 2023-01-02 11:57 ` Eli Zaretskii 0 siblings, 1 reply; 10+ messages in thread From: Davin Pearson @ 2023-01-02 0:27 UTC (permalink / raw) To: Eli Zaretskii; +Cc: mwd, emacs-devel [-- Attachment #1: Type: text/plain, Size: 3481 bytes --] (progn (setq edebug-eval-top-level-form t) (setq edebug-all-defs t) (setq edebug-all-forms t) (setq edebug-on-error t)) (defun smegulator () void-variable-smeg ) ;;(smegulator) (defmacro dmp-quote (&rest rest) t) (dmp-quote When I put the following code at the start of my .emacs file it executes without errors as it should. However when I evaluate (smegulator) it brings up the following message, without a black triangle elisp--eval-last-sexp: Symbol’s value as variable is void: void-variable-smeg When I execute C-u C-M-x on (defun smegulator () void-variable-smeg) it brings up the following messages. edebug-after: Symbol’s value as variable is void: void-variable-smeg elisp--eval-last-sexp: Symbol’s value as variable is void: void-variable-smeg with a black triangle indicating we are in edebug mode. How do I get the black triangle online in other files for debugging my code? i.e. how do you get Emacs to do a C-u C-M-x on every defun without doing it manually C-u C-M-x for every function one at a time? ) *Davin.* On Tue, 27 Dec 2022 at 01:29, Eli Zaretskii <eliz@gnu.org> wrote: > > From: Davin Pearson <davin.pearson@gmail.com> > > Date: Mon, 26 Dec 2022 13:54:39 +1300 > > Cc: Michael Welsh Duggan <mwd@md5i.com>, emacs-devel@gnu.org > > > > Consider the following code: > > > > (progn > > (defun foo () > > tomcat > > ) > > (defun bar () > > (foo)) > > ) > > > > (bar) > > > > When I instrument the foo and bar defuns for debugging by > > entering the command C-u M-C-x over the (progn ...) sexp and > > pressing the "n" key it comes with a black triangle next to > > tomcat, thus indicating that we are stepping through the foo > > function which is what I want. > > > > The error message is this: > > > > edebug-after: Symbol’s value as variable is void: tomcat > > > > This is all good. What I need to know is how to instrument every > > function for debugging. I tried the following command at > > the top of my ~/.emacs file: > > > > (progn > > (setq edebug-on-error t) > > (setq edebug-all-defs t)) > > > > When I put the above foo/bar/tomcat code in another file and I > > try to instrument the foo and bar methods for debugging, again > > with C-u M-C-x it comes back with the following error: > > > > bar: Symbol’s value as variable is void: tomcat > > > > Note that there is no black triangle next to the tomcat sexp, > > indicating we are using the debug module and not the edebug > > module, which is not what I want. > > > > How do I get every function marked as instrumented? > > According to the manual: > > If ‘edebug-all-defs’ is non-‘nil’, then the commands ‘eval-region’, > ‘eval-current-buffer’, and ‘eval-buffer’ also instrument any definitions > they evaluate. Similarly, ‘edebug-all-forms’ controls whether > ‘eval-region’ should instrument _any_ form, even non-defining forms. > This doesn’t apply to loading or evaluations in the minibuffer. The > command ‘M-x edebug-all-forms’ toggles this option. > > Another command, ‘M-x edebug-eval-top-level-form’, is available to > instrument any top-level form regardless of the values of > ‘edebug-all-defs’ and ‘edebug-all-forms’. ‘edebug-defun’ is an alias > for ‘edebug-eval-top-level-form’. > > I think this answers your questions. > [-- Attachment #2: Type: text/html, Size: 4465 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2023-01-02 0:27 ` Davin Pearson @ 2023-01-02 11:57 ` Eli Zaretskii 2023-01-02 22:11 ` Davin Pearson 0 siblings, 1 reply; 10+ messages in thread From: Eli Zaretskii @ 2023-01-02 11:57 UTC (permalink / raw) To: Davin Pearson; +Cc: mwd, emacs-devel > From: Davin Pearson <davin.pearson@gmail.com> > Date: Mon, 2 Jan 2023 13:27:08 +1300 > Cc: mwd@md5i.com, emacs-devel@gnu.org > > (progn > (setq edebug-eval-top-level-form t) > (setq edebug-all-defs t) > (setq edebug-all-forms t) > (setq edebug-on-error t)) > > (defun smegulator () > void-variable-smeg > ) > > ;;(smegulator) > > (defmacro dmp-quote (&rest rest) > t) > > (dmp-quote > > When I put the following code at the start of > my .emacs file it executes without errors as > it should. > > However when I evaluate (smegulator) it brings > up the following message, without a black triangle > > elisp--eval-last-sexp: Symbol’s value as variable is void: void-variable-smeg > > When I execute C-u C-M-x on (defun smegulator () void-variable-smeg) > it brings up the following messages. > > edebug-after: Symbol’s value as variable is void: void-variable-smeg > > elisp--eval-last-sexp: Symbol’s value as variable is void: void-variable-smeg > with a black triangle indicating we are in edebug mode. > > How do I get the black triangle online in other files for debugging my code? > > i.e. how do you get Emacs to do a C-u C-M-x on every defun without doing > it manually C-u C-M-x for every function one at a time? According to the manual, you should do the following, in the order shown: . set edebug-all-forms to a non-nil value . mark the region around your code . type "M-x eval-region RET" ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to highlight the offending line of code with edebug 2023-01-02 11:57 ` Eli Zaretskii @ 2023-01-02 22:11 ` Davin Pearson 0 siblings, 0 replies; 10+ messages in thread From: Davin Pearson @ 2023-01-02 22:11 UTC (permalink / raw) To: Eli Zaretskii; +Cc: mwd, emacs-devel [-- Attachment #1: Type: text/plain, Size: 3715 bytes --] ;; I am trying to instrument all functions in all of my *.el files ;; but I am running into grief Getting *Debugging* ;; Please consider the following code that belongs at the top of the ;; file: ~/.emacs: (defmacro dmp-quote (&rest rest) t) (progn (require 'debug) (require 'edebug) ;;(setq debug-on-error nil) (setq edebug-all-defs t) (setq edebug-all-forms t) (setq edebug-on-error t) (edebug-eval-top-level-form) ;; <-- bug in my earlier code is a function not a variable ) (defun smegulator () smegulator-void-var ) ;;(smegulator) ;; NOTE: commented for later evaluation (dmp-quote ;; NOTE: strictly for Davin's use... (progn (load-file "~/dlisp/custom-set-faces.el") (setq load-path (cons "~/dlisp/jtw-start/" load-path)) (require 'dmp-safe--require) ) ) (dmp-quote When I put the following code at the start of my .emacs file it executes without errors as it should. However when I evaluate (smegulator) it brings up the following message in the *Backtrace* buffer: Debugger entered--Lisp error: (void-function smegulator) (smegulator) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) command-execute(eval-last-sexp) without a black triangle indicating we are not in the edebug *Debugging* When I put the cursor inside (defun smegulator () smegulator-void-var) and evaluate C-M-x it comes back with the following error, again without a black triangle so edebug mode is not activated. edebug-after: Symbol’s value as variable is void: smegulator-void-var again without a black triangle indicating the edebug mode is not activated i.e. how do you get Emacs to do a C-u C-M-x on every defun in every *.el files without doing it manually C-u C-M-x for every function one at a time? Sometimes when I evaluate M-C-x or C-u M-C-x it brings up a black triangle indicating we are entering edebug mode, but the correct behaviour is pretty much a hit and miss affair. ) *Davin.* On Tue, 3 Jan 2023 at 00:57, Eli Zaretskii <eliz@gnu.org> wrote: > > From: Davin Pearson <davin.pearson@gmail.com> > > Date: Mon, 2 Jan 2023 13:27:08 +1300 > > Cc: mwd@md5i.com, emacs-devel@gnu.org > > > > (progn > > (setq edebug-eval-top-level-form t) > > (setq edebug-all-defs t) > > (setq edebug-all-forms t) > > (setq edebug-on-error t)) > > > > (defun smegulator () > > void-variable-smeg > > ) > > > > ;;(smegulator) > > > > (defmacro dmp-quote (&rest rest) > > t) > > > > (dmp-quote > > > > When I put the following code at the start of > > my .emacs file it executes without errors as > > it should. > > > > However when I evaluate (smegulator) it brings > > up the following message, without a black triangle > > > > elisp--eval-last-sexp: Symbol’s value as variable is void: > void-variable-smeg > > > > When I execute C-u C-M-x on (defun smegulator () void-variable-smeg) > > it brings up the following messages. > > > > edebug-after: Symbol’s value as variable is void: void-variable-smeg > > > > elisp--eval-last-sexp: Symbol’s value as variable is void: > void-variable-smeg > > with a black triangle indicating we are in edebug mode. > > > > How do I get the black triangle online in other files for debugging my > code? > > > > i.e. how do you get Emacs to do a C-u C-M-x on every defun without doing > > it manually C-u C-M-x for every function one at a time? > > According to the manual, you should do the following, in the order > shown: > > . set edebug-all-forms to a non-nil value > . mark the region around your code > . type "M-x eval-region RET" > [-- Attachment #2: Type: text/html, Size: 4804 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-01-02 22:11 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-12-22 21:09 How to highlight the offending line of code with edebug Davin Pearson 2022-12-22 21:13 ` Davin Pearson 2022-12-23 7:20 ` Eli Zaretskii 2022-12-23 7:36 ` Michael Welsh Duggan 2022-12-23 8:39 ` Eli Zaretskii 2022-12-26 0:54 ` Davin Pearson 2022-12-26 12:29 ` Eli Zaretskii 2023-01-02 0:27 ` Davin Pearson 2023-01-02 11:57 ` Eli Zaretskii 2023-01-02 22:11 ` Davin Pearson
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).