* Emacs 21.2 -- debugger-frame-offset is 8, should be 6
@ 2008-01-29 22:35 Derek Peschel
2008-01-29 23:53 ` Derek Peschel
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Derek Peschel @ 2008-01-29 22:35 UTC (permalink / raw)
To: bug-gnu-emacs
The debugger (not edebug, the one in debug.el) uses the
debugger-frame-offset constant to affect breakpoints on stack frames.
So if the constant becomes wrong, breakpoint commands will appear to work
but actually affect the wrong frame. I have included a patch. I don't
think the problem (and the change) depend on or affect any other parts
of Emacs, but I haven't checked.
The guidelines on bug reporting basically don't trust users to analyze
problems, so I have also included steps you can follow to see if you
agree with me. As a side effect they add a new function and keystroke
to debug.el, so that Emacs can help find the correct value of
debugger-frame-offset in the future. This is much easier than having
to go into gdb (I know, I did that), and I suggest keeping the function
in debug.el even if it's not bound to any keys.
Please let me know if you have any questions.
-- Derek
My system:
----------
I'm running Mac OS 10.3.7 -- uname -a gives
Darwin Derek-Peschels-Computer.local 7.7.0 Darwin Kernel Version 7.7.0: Sun Nov 7 16:06:51 PST 2004; root:xnu/xnu-517.9.5.obj~1/RELEASE_PPC Power Macintosh powerpc
My Emacs is the one Apple shipped -- M-x emacs-version gives
GNU Emacs 21.2.1 (powerpc-apple-darwin7.0) of 1976-04-01 on localhost
The shell commands below use bash -- echo $BASH_VERSION gives
2.05b.0(1)-release
The shell commands also use patch -- patch -v starts with
patch 2.5.8
Copyright (C) 1988 Larry Wall
Copyright (C) 2002 Free Software Foundation, Inc.
Notations:
----------
?> refers to a step I haven't written commands for
shell> refers to a command typed at the bash prompt.
emacs> refers to keys typed in Emacs.
emacs= followed by a space and a line of text shows the message line
(which could be a prompt for an argument, or the result of a command).
emacs= followed by dashes, a screen of text, and dashes shows the contents
of a buffer.
Included files:
---------------
debug.el.patch-fix patch to apply fix -- not used
in the procedure
debug.el.patch-test-orig patch to add information command
debug.el.patch-test-fix patch to add information command
and apply fix
debugger-frame-offset-test.el LISP code to set up debugger
for tests described in this procedure
Created or changed files:
-------------------------
working directory created below (or may already exist)
debug.el.patch-test-orig copied from mail
debug.el.patch-test-fix copied from mail
debugger-frame-offset-test.el copied from mail
debug.el created below
debug.elc created below
debug.el.old created below
debug.el.new created below
debug.el.disabled-during-bug-fix temporary name for existing debug.el
debug.elc.disabled-during-bug-fix temporary name for existing debug.elc
home directory
.emacs created below
.emacs.disabled-during-bug-fix temporary name for existing .emacs
Procedure -- Setup:
-------------------
1. start a new shell since current directory and some environment variables
will be changed
?>
2. create working directory, then change to it
shell> export WORK=~/share/emacs/site-lisp could be any directory
since it will be added
to Emacs's load-path later
shell> mkdir -p $WORK create it if needed
shell> cd $WORK
3. put debug.el.patch-test-orig and debug.el.patch-test-fix and
debugger-frame-offset-test.el in working directory
?>
4. create versions of debug.el used by later steps
shell> mv -i debug.el debug.el.disabled-during-bug-fix
if debug.el exists
shell> mv -i debug.elc debug.elc.disabled-during-bug-fix
if debug.elc exists
shell> cp /usr/share/emacs/21.2/lisp/emacs-lisp/debug.el .
or from another appropriate
directory
shell> cp -i debug.el debug.el.new
shell> patch <debug.el.patch-test-orig patches debug.el
shell> patch <debug.el.patch-test-fix patches debug.el.new
5. create working .emacs
shell> mv -i ~/.emacs ~/.emacs.disabled-during-bug-fix
if .emacs exists
shell> emacs ~/.emacs
emacs> (add-to-list 'load-path "~/share/emacs/site-lisp") RET
string in quotes must match
WORK
emacs> C-x C-c
6. byte-compile debug.el (it must run byte-compiled)
shell> emacs
emacs> M-x byte-compile-file RET
emacs= Byte compile file: ~/share/emacs/site-lisp/
prompt matches WORK
emacs> debug.el RET I get warnings about
unread-command-char being
obsolete; the debugger saves
and restores it, probably so
you can debug old code
emacs> C-x C-c
Procedure -- Show existing bug:
-------------------------------
7. load test case, run test case
shell> emacs
emacs> M-x load-file RET
emacs= Load file: ~/share/emacs/site-lisp/
emacs> debugger-frame-offset-test.el RET
emacs=
------------------------------------------------------------------------------
Debugger entered: ("in fun8")
fun8()
fun7()
fun6()
fun5()
fun4()
fun3()
fun2()
fun1()
eval-buffer(#<buffer *load*> nil "/Users/dpeschel/share/emacs/site-lisp/debugger-frame-offset-test.el" nil t)
load-with-code-conversion("/Users/dpeschel/share/emacs/site-lisp/debugger-frame-offset-test.el" "/Users/dpeschel/share/emacs/site-lisp/debugger-frame-offset-test.el" nil nil)
load("/Users/dpeschel/share/emacs/site-lisp/debugger-frame-offset-test.el" nil nil t)
load-file("~/share/emacs/site-lisp/debugger-frame-offset-test.el")
* call-interactively(load-file)
execute-extended-command(nil)
call-interactively(execute-extended-command)
------------------------------------------------------------------------------
8. in debugger, move to a frame, look at what "i" command says
emacs> i
emacs= (t fun6) does not match function name
of frame at cursor
emacs> C-u C-n C-u C-n C-u C-n get to
"call-interactively(load-file)"
frame, last one that I expect
to have a printout
corresponding to a real frame
emacs> i
emacs= (t call-interactively execute-extended-command)
does not match function name
of frame at cursor
emacs> C-n if expectation is right,
going down onscreen
should not have a printout
corresponding to a real frame
emacs> i
emacs= nil does not match any function
emacs> C-x C-c
Procedure -- Apply fix:
-----------------------
9. switch debug.el versions
shell> rm -f debug.elc
shell> mv -i debug.el debug.el.old
shell> mv -i debug.el.new debug.el
10. byte-compile debug.el
(repeat step #6)
Procedure -- Test fix:
----------------------
11. restart emacs, load test case, run test case
(repeat step #7; debugger window contents should be same)
12. in debugger, move to a frame, look at what "i" command says
emacs> i
emacs= (t fun8) matches function name of
frame at cursor
emacs> C-u C-n C-u C-n C-u C-n get to
"call-interactively(load-file)"
frame, which was a boundary
case before the fix was
applied
emacs> i
emacs= (t call-interactively load-file) matches function name of
frame at cursor
emacs> C-n test next frame onscreen,
which was past the boundary
case before the fix was
applied
emacs> i
emacs= (t execute-extended-command nil) matches function name of
frame at cursor
emacs> C-n test next frame onscreen,
boundary case now
emacs= (t call-interactively execute-extended-command)
matches function name of
frame at cursor
emacs> C-x C-c
Procedure -- Undo setup:
------------------------
13. undo changes to ~/.emacs
shell> rm ~/.emacs if .emacs didn't exist
before this procedure
shell> mv ~/.emacs.disabled-during-bug-fix ~/.emacs
if .emacs already existed
before this procedure
14. undo changes to working directory
If the directory didn't exist before this procedure:
shell> cd or whatever was the
current directory when WORK
was created
shell> rm -rf $WORK
If the directory did exist before this procedure:
shell> mv debug.el.disabled-during-bug-fix debug.el
if debug.el already existed
before this procedure
shell> mv debug.elc.disabled-during-bug-fix debug.elc
if debug.elc already existed
before this procedure
shell> rm debug.el.patch-test-orig
shell> rm debug.el-patch-test-fix
shell> rm debugger-frame-offset-test.el
shell> rm debug.el.old
shell> rm debug.el.new
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Emacs 21.2 -- debugger-frame-offset is 8, should be 6
2008-01-29 22:35 Emacs 21.2 -- debugger-frame-offset is 8, should be 6 Derek Peschel
@ 2008-01-29 23:53 ` Derek Peschel
2008-01-30 6:26 ` Nick Roberts
2008-01-30 20:52 ` Richard Stallman
2 siblings, 0 replies; 4+ messages in thread
From: Derek Peschel @ 2008-01-29 23:53 UTC (permalink / raw)
To: bug-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 148 bytes --]
Sorry, I used mutt with a command line format I don't normally use, and
didn't have a chance to attach the patches and other files. Here they are.
[-- Attachment #2: debug.el.patch-fix --]
[-- Type: text/plain, Size: 434 bytes --]
--- debug.el Mon Jan 28 13:10:09 2008
+++ debug.el Mon Jan 28 13:10:34 2008
@@ -300,7 +300,7 @@
;; within the first one that appears in the backtrace buffer.
;; Assumes debugger-frame is called from a key;
;; will be wrong if it is called with Meta-x.
-(defconst debugger-frame-offset 8 "")
+(defconst debugger-frame-offset 6 "")
(defun debugger-jump ()
"Continue to exit from this frame, with all debug-on-entry suspended."
[-- Attachment #3: debug.el.patch-test-fix --]
[-- Type: text/plain, Size: 1228 bytes --]
--- debug.el.new Mon Jan 28 13:23:15 2008
+++ debug.el.new Mon Jan 28 13:25:05 2008
@@ -300,7 +300,7 @@
;; within the first one that appears in the backtrace buffer.
;; Assumes debugger-frame is called from a key;
;; will be wrong if it is called with Meta-x.
-(defconst debugger-frame-offset 8 "")
+(defconst debugger-frame-offset 6 "")
(defun debugger-jump ()
"Continue to exit from this frame, with all debug-on-entry suspended."
@@ -379,6 +379,11 @@
(insert ? )))
(beginning-of-line))
+(defun debugger-frame-info ()
+ "Show information about the frame at point."
+ (interactive)
+ (beginning-of-line)
+ (message "%s" (prin1-to-string (backtrace-frame (+ (debugger-frame-number) debugger-frame-offset)))))
(put 'debugger-env-macro 'lisp-indent-function 0)
@@ -452,6 +457,7 @@
(define-key debugger-mode-map "j" 'debugger-jump)
(define-key debugger-mode-map "r" 'debugger-return-value)
(define-key debugger-mode-map "u" 'debugger-frame-clear)
+ (define-key debugger-mode-map "i" 'debugger-frame-info)
(define-key debugger-mode-map "d" 'debugger-step-through)
(define-key debugger-mode-map "l" 'debugger-list-functions)
(define-key debugger-mode-map "h" 'describe-mode)
[-- Attachment #4: debug.el.patch-test-orig --]
[-- Type: text/plain, Size: 862 bytes --]
--- debug.el Mon Jan 28 13:23:15 2008
+++ debug.el Mon Jan 28 13:24:00 2008
@@ -379,6 +379,11 @@
(insert ? )))
(beginning-of-line))
+(defun debugger-frame-info ()
+ "Show information about the frame at point."
+ (interactive)
+ (beginning-of-line)
+ (message "%s" (prin1-to-string (backtrace-frame (+ (debugger-frame-number) debugger-frame-offset)))))
(put 'debugger-env-macro 'lisp-indent-function 0)
@@ -452,6 +457,7 @@
(define-key debugger-mode-map "j" 'debugger-jump)
(define-key debugger-mode-map "r" 'debugger-return-value)
(define-key debugger-mode-map "u" 'debugger-frame-clear)
+ (define-key debugger-mode-map "i" 'debugger-frame-info)
(define-key debugger-mode-map "d" 'debugger-step-through)
(define-key debugger-mode-map "l" 'debugger-list-functions)
(define-key debugger-mode-map "h" 'describe-mode)
[-- Attachment #5: debugger-frame-offset-test.el --]
[-- Type: text/plain, Size: 223 bytes --]
q(defun fun1 ()
(fun2))
(defun fun2 ()
(fun3))
(defun fun3 ()
(fun4))
(defun fun4 ()
(fun5))
(defun fun5 ()
(fun6))
(defun fun6 ()
(fun7))
(defun fun7 ()
(fun8))
(defun fun8 ()
(debug nil "in fun8"))
(fun1)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Emacs 21.2 -- debugger-frame-offset is 8, should be 6
2008-01-29 22:35 Emacs 21.2 -- debugger-frame-offset is 8, should be 6 Derek Peschel
2008-01-29 23:53 ` Derek Peschel
@ 2008-01-30 6:26 ` Nick Roberts
2008-01-30 20:52 ` Richard Stallman
2 siblings, 0 replies; 4+ messages in thread
From: Nick Roberts @ 2008-01-30 6:26 UTC (permalink / raw)
To: Derek Peschel; +Cc: bug-gnu-emacs
> The guidelines on bug reporting basically don't trust users to analyze
> problems,
What guidelines are these? The Emacs manual has a node on how to send patches.
and clearly most of us would rather receive a patch than have to fix a bug
ourselves.
> so I have also included steps you can follow to see if you
> agree with me.
This is an extensive report but have you tried Emacs 22.1 to see if the bug
is still present there?
--
Nick http://www.inet.net.nz/~nickrob
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Emacs 21.2 -- debugger-frame-offset is 8, should be 6
2008-01-29 22:35 Emacs 21.2 -- debugger-frame-offset is 8, should be 6 Derek Peschel
2008-01-29 23:53 ` Derek Peschel
2008-01-30 6:26 ` Nick Roberts
@ 2008-01-30 20:52 ` Richard Stallman
2 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2008-01-30 20:52 UTC (permalink / raw)
To: Derek Peschel; +Cc: bug-gnu-emacs
The guidelines on bug reporting basically don't trust users to analyze
problems,
I wouldn't put it that way. When a user does, as you did, show us
precisely what is wrong and what the fix is, we appreciate that
greatly. (Thank you!)
Our advice about giving a test case is because (1) if the user doesn't
provide a fix, we need the test case to start from, and (2) if the
user does provide the fix, the test case enables us to verify that it
is right.
As a side effect they add a new function and keystroke
to debug.el, so that Emacs can help find the correct value of
debugger-frame-offset in the future.
Very interesting -- thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-30 20:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-29 22:35 Emacs 21.2 -- debugger-frame-offset is 8, should be 6 Derek Peschel
2008-01-29 23:53 ` Derek Peschel
2008-01-30 6:26 ` Nick Roberts
2008-01-30 20:52 ` Richard Stallman
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).