From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "Michael Heerdegen" <michael_heerdegen@web.de>,
brandon.irizarry@gmail.com,
"Mattias Engdegård" <mattias.engdegard@gmail.com>,
"Michael Albinus" <michael.albinus@gmx.de>,
65344@debbugs.gnu.org
Subject: bug#65344: 28.2; Unable to Edebug cl-flet form which uses argument destructuring
Date: Sun, 03 Sep 2023 07:51:14 +0200 [thread overview]
Message-ID: <m2r0nfrei5.fsf@Pro.fritz.box> (raw)
In-Reply-To: <jwvjzt8tmr3.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 02 Sep 2023 15:27:51 -0400")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> In this case, the code for F will be run in the body of the
>>> flet. Doesn't that qualify as being run later, as you describe above,
>>> ignoring the "non-instrumented" part, maybe?
>>
>> No, in the above case the `def-form` is
>>
>> (lambda () (list 1 2))
>>
>> which will be "run" right when we enter the `cl-flet` ("run" is an
>> exaggeration here since this lambda is a constant so it'll just
>> self-evaluate) and not when `f` is called.
Thanks. I've skimmed through the docs and Edebug code a bit this today,
and I think I understand you a bit better now.
>
> More specifically, the annotated code of
>
> (defun sm-foo (x)
> (cl-flet ((f (prog1 (lambda (y) (+ x y)) 0)))
> (f 5)))
>
> stored into (symbol-function 'sm-foo) now looks like:
>
For posterity, if somone reads this in a few years, including myself,
maybe...
If I understand correctly, the edebug-before and -after instrumentation
forms lead, via edebug-behavior, to calls to edebug-slow-{before,after},
when test coverage is demanded by edebug-test-coverage being non-nil.
Otherwise, when e-t-c is nil, another pair of functions with 'fast' in
their names is used.
The slow functions update edebug-freq-count. E-f-q seems to be a
special variable that edebug-default-enter binds to a vector
that is obtained from the symbol-plist of the function name, which is an
argument of e-d-e.
I haven't checked what exactly e-default-e is. I'm just assuming from
its name it gets called when encountering edebug-enter.
> (closure (t) (x)
> (edebug-enter 'sm-foo (list x)
So, in the line above, we obtain the frequency vector from the name
'sm-foo.
> #'(lambda nil :closure-dont-trim-context
> (edebug-after (edebug-before 0) 3
And the line above accesses that vector found in edebug-frequency-count.
> (let* ((--cl-f--
> (edebug-enter 'f@cl-flet@4 nil
> #'(lambda nil :closure-dont-trim-context
> (edebug-after (edebug-before 0) 1
Here the same mechanism for the local-function
> (prog1
> #'(lambda (y)
> (edebug-enter 'edebug-anon5 (list y)
> #'(lambda nil :closure-dont-trim-context
> (edebug-after (edebug-before 0) 3
And here again the same mechanism, but with a bogus name. That's what
you are referring to, right?
> (+ (edebug-after 0 1 x)
> (edebug-after 0 2 y))))))
> 0))))))
> (progn
> (edebug-after (edebug-before 1) 2
> (funcall --cl-f-- 5))))))))
>
> As you can see for `sm-foo` itself, the
>
> (edebug-enter 'sm-foo (list x)
> #'(lambda nil :closure-dont-trim-context
>
> is (correctly) placed at the very beginning of the body of the function,
> so that code coverage can track whether `sm-foo` was called or not.
Understood (I think). The lambda will land in edebug-default-enter,
which funcalls it. That lands in the "(edebug-enter 'f@cl-flet@4 ...",
and so on.
>
> In contrast the
>
> (edebug-enter 'f@cl-flet@4 nil
> #'(lambda nil :closure-dont-trim-context
>
> is placed around the code which will compute&return the `f@cl-flet@4`
> function, but not inside its body, which instead gets
>
> (edebug-enter 'edebug-anon5 (list y)
> #'(lambda nil :closure-dont-trim-context
Right. I think I found that, too.
> It's actually difficult (and in general impossible) to associate the
> name `f@cl-flet@4` with the corresponding `lambda`, so the use of
> `edebug-anon5` is largely unavoidable here. But making the code-coverage
> say that `f@cl-flet@4` is called just because we computed that function
> (regardless if it's been called) is a problem.
Ok, understood. I hope, or did I get lost somewhere?
Do you perhaps an idea how to solve that?
next prev parent reply other threads:[~2023-09-03 5:51 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 18:21 bug#65344: 28.2; Unable to Edebug cl-flet form which uses argument destructuring Brandon Irizarry
2023-08-17 0:55 ` Michael Heerdegen
2023-08-17 5:29 ` Gerd Möllmann
2023-08-17 15:42 ` Brandon Irizarry
2023-08-17 15:56 ` Eli Zaretskii
2023-08-17 18:23 ` Gerd Möllmann
2023-08-17 23:07 ` Michael Heerdegen
2023-08-18 5:19 ` Gerd Möllmann
2023-08-18 5:58 ` Michael Heerdegen
2023-08-18 6:43 ` Gerd Möllmann
2023-08-19 8:08 ` Gerd Möllmann
2023-08-20 3:57 ` Michael Heerdegen
2023-08-20 5:32 ` Gerd Möllmann
2023-08-20 6:08 ` Michael Heerdegen
2023-08-20 6:48 ` Gerd Möllmann
2023-08-21 1:19 ` Michael Heerdegen
2023-08-21 7:01 ` Gerd Möllmann
2023-08-21 7:10 ` Gerd Möllmann
2023-08-21 7:30 ` Gerd Möllmann
2023-08-22 0:54 ` Michael Heerdegen
2023-08-22 5:48 ` Gerd Möllmann
2023-08-22 6:10 ` Michael Heerdegen
2023-08-22 8:05 ` Gerd Möllmann
2023-08-22 21:06 ` Brandon Irizarry
2023-08-23 0:35 ` Michael Heerdegen
2023-08-23 0:32 ` Michael Heerdegen
2023-08-23 1:25 ` Drew Adams
2023-08-23 6:06 ` Gerd Möllmann
2023-08-23 14:23 ` Drew Adams
2023-08-24 3:16 ` Michael Heerdegen
2023-08-24 9:10 ` Gerd Möllmann
2023-08-24 23:04 ` Michael Heerdegen
2023-08-25 1:53 ` Drew Adams
2023-08-25 4:07 ` Michael Heerdegen
2023-08-25 14:50 ` Drew Adams
2023-08-26 0:16 ` Michael Heerdegen
2023-08-26 2:02 ` Drew Adams
2023-08-20 4:39 ` Michael Heerdegen
2023-08-20 5:15 ` Gerd Möllmann
2023-08-23 9:25 ` Mattias Engdegård
2023-08-23 9:31 ` Mattias Engdegård
2023-08-23 11:10 ` Gerd Möllmann
2023-08-23 14:08 ` Gerd Möllmann
2023-08-24 1:14 ` Michael Heerdegen
2023-08-24 6:17 ` Gerd Möllmann
2023-08-25 4:10 ` Michael Heerdegen
2023-08-25 6:19 ` Gerd Möllmann
2023-08-25 4:22 ` Michael Heerdegen
2023-08-25 6:33 ` Gerd Möllmann
2023-08-25 17:53 ` Michael Heerdegen
2023-08-26 5:39 ` Gerd Möllmann
2023-08-27 4:02 ` Michael Heerdegen
2023-08-27 6:34 ` Gerd Möllmann
2023-09-01 23:24 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-02 5:10 ` Gerd Möllmann
2023-09-02 17:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-02 19:27 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 5:51 ` Gerd Möllmann [this message]
2023-09-03 16:09 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-03 16:47 ` Gerd Möllmann
2023-09-04 21:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-23 9:33 ` Gerd Möllmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2r0nfrei5.fsf@Pro.fritz.box \
--to=gerd.moellmann@gmail.com \
--cc=65344@debbugs.gnu.org \
--cc=brandon.irizarry@gmail.com \
--cc=mattias.engdegard@gmail.com \
--cc=michael.albinus@gmx.de \
--cc=michael_heerdegen@web.de \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.