wanted: DISASSEMBLE arguments :include-argument-parsing, :include-anonymous-functions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
:INCLUDE-
comes before no-arg-
:INCLUDE-
display the disassembly of lambda functions referenced in a function.
For example:
(defun quux (alist)
(declare (optimize speed))
(remove "foo" alist :test #'(lambda (x y)
(disassemble #'quux)
; disassembly for QUUX
; 0B803C31: 8B15FC3B800B MOV EDX, [#xB803BFC] ; "foo"
; 37: 8B35003C800B MOV ESI, [#xB803C00] ; :TEST
; 3D: 8B05F83B800B MOV EAX, [#xB803BF8] ; #<FUNCTION (LAMBDA
; 43: 8945F8 MOV [EBP-8], EAX
; 46: 8B05043C800B MOV EAX, [#xB803C04] ; #<FDEFINITION object for REMOVE>
; 4C: B910000000 MOV ECX, 16
; 51: FF7504 PUSH DWORD PTR [EBP+4]
; 54: FF6005 JMP DWORD PTR [EAX+5]
; 57: CC0A BREAK 10 ; error trap
; 59: 02 BYTE #X02
; 5A: 18 BYTE #X18 ; INVALID-
; 5B: 4D BYTE #X4D ; ECX
I'd also like to see the disassembly of the #<FUNCTION (LAMBDA ...) {B80382D}> object.
It's not always easy to extract the source of such a lambda out to pass it to DISASSEMBLE
because of closures and other lexical dependencies (like the optimize settings in the example.)
Changed in sbcl: | |
importance: | Undecided → Wishlist |
status: | New → Confirmed |
I'm not wild about the names, but I definitely agree with the sentiment. How to display the disassembly of the referenced anon (or just local!) function is a good question, though.
As a stopgap measure here is something I sometimes use:
(defun disassemble- code-object- functions (code-object &key ignore) %code-entry- points code-object)))
(format t "~%===~%~S~%===~%" (sb-kernel: %simple- fun-name ep))
(disassemble ep)) %simple- fun-next ep)))))
(let ((ep (sb-kernel:
(loop while ep
do (unless (member ep ignore)
(setf ep (sb-kernel:
(defun disassemble- component (fun &key ignore) code-object- functions kernel: fun-code- header (sb-kernel:%fun-fun fun))
(sb-kernel: %fun-fun (fdefinition name)))
ignore) ))
(disassemble-
(sb-
:ignore (mapcar (lambda (name)
Note that it doesn't really get the elsewhere segment right: the disassembly for (LAMBDA (X Y)) here includes the invalid arg-count traps for both the lambda and the main function. (Which, incidentally, is bad: since the arg count is in ECX in both cases -- like always -- there should be just one trap.)