cl调试,察看出错具体到行

26 views
Skip to first unread message

Jeova Sanctus Unus

unread,
Feb 23, 2012, 8:10:15 AM2/23/12
to lis...@googlegroups.com
代码如下
(declaim (optimize (debug 3)))
(in-package :cl-user)

(defun abc (n)
(- 1 n)
(/ 1 n)
)

启动sbcl之后,切换到这个文件的buffer
C-c C-k
然后,到repl,运行(abc 0)
出错,然后,在sldb里面移动到(abc 0),按v键,可以看到光标在出错的行上面。
但是,同样的操作,allegro只把光标显示在了(defun abc上面。
这样,如果是个比较长的程序,用sbcl的话,可以马上知道哪行出错了。allegro怎么办到呢?

Jianshi Huang

unread,
Feb 23, 2012, 8:37:12 AM2/23/12
to lis...@googlegroups.com
compiler 不支持的话估计没办法,或者slime没实现。

2012/2/23 Jeova Sanctus Unus <jeova.san...@gmail.com>:

> --
> Lisp-cn(Lisp中文用户组)
> CLUG http://lisp.org.cn

--
黄 澗石 (Jianshi Huang)
http://huangjs.net/

Jeova Sanctus Unus

unread,
Feb 23, 2012, 8:45:10 AM2/23/12
to lis...@googlegroups.com
哦。这样子。我浏览了下allegro文档的debug部分。貌似没有提到相关的。

Xiaofeng Yang

unread,
Feb 23, 2012, 11:19:18 AM2/23/12
to lis...@googlegroups.com
我试了,在ACL IDE里面。
8.1 -> 只能到(defun abc ...
8.2 -> 能到出错的那一句(/ n 0)

8.2在调试方面做了增强,看起来还是有变化的。

     Best regards,
Xiaofeng Yang


Xiaofeng Yang

unread,
Feb 23, 2012, 11:25:59 AM2/23/12
to lis...@googlegroups.com
写错了,是(/ 1 n)

     Best regards,
Xiaofeng Yang

刘滔

unread,
Feb 23, 2012, 9:34:59 PM2/23/12
to lis...@googlegroups.com
受教了,才知道原来按v键可以调用这种功能啊,调试居然这么方便……
--
Liutos Love Linux LaTeX Lisp Ling

我的博客,纪念我死去的GAE

bruce li

unread,
Feb 23, 2012, 9:40:09 PM2/23/12
to lis...@googlegroups.com
弱弱的问一句,如何让sbcl默认以debug 3的方式启动?貌似要能够直接定位到代码,要在 .lisp文件头部加入(declaim ...)才可以,在repl里面直接出入这句话不起作用。。 但感觉每个文件头部加个这个还是很麻烦呢。。

Jeova Sanctus Unus

unread,
Feb 23, 2012, 9:41:37 PM2/23/12
to lis...@googlegroups.com
我是64位的系统,跑不了32的allegro的图形,我试了下82 32bit的linux的alisp
出错后,到(abc 0)那里按v
显示:
`(82)' is not of the expected type `NUMBER'
[Condition of type TYPE-ERROR]

Restarts:
0: [ABORT] Return to sldb level 1.
1: [RETRY] Retry SLIME REPL evaluation request.
2: [*ABORT] Return to SLIME's top level.
3: [ABORT] Abort entirely from this (lisp) process.

Backtrace:
0: (ERROR TYPE-ERROR :DATUM (82) :EXPECTED-TYPE NUMBER ...)
1: ((:INTERNAL SWANK-BACKEND::BUFFER-OR-FILE-LOCATION 0) "/tmp/a.lisp")
--more--

对这个`(82)' is not of the expected type `NUMBER' 不明白。。

在 2012年2月24日 上午12:19,Xiaofeng Yang <n.akr....@gmail.com> 写道:

Jeova Sanctus Unus

unread,
Feb 23, 2012, 9:59:43 PM2/23/12
to lis...@googlegroups.com
看下sbcl info的4.3 Compiler Policy

貌似这么用,在repl里:
(sb-ext:restrict-compiler-policy 'debug 3)
这样好像是强制debug的最小值为三

Xiaofeng Yang

unread,
Feb 23, 2012, 10:14:26 PM2/23/12
to lis...@googlegroups.com
(82)的类型当然不是NUMBER了。
有可能是slime的bug,不支持新的acl,具体得调试才知道是怎么回事。

P.S. 你装上32位支持库一样能跑32位的allegro IDE。起码ubuntu 10.04可以。

     Best regards,
Xiaofeng Yang

Jianshi Huang

unread,
Feb 24, 2012, 3:15:47 AM2/24/12
to lis...@googlegroups.com
global declaration:

(proclaim '(optimize ...))

在所有 CL 里都可以

2012/2/24 bruce li <leil...@gmail.com>:


> 弱弱的问一句,如何让sbcl默认以debug 3的方式启动?貌似要能够直接定位到代码,要在 .lisp文件头部加入(declaim
> ...)才可以,在repl里面直接出入这句话不起作用。。 但感觉每个文件头部加个这个还是很麻烦呢。。
>
> 在 2012年2月24日 上午10:34,刘滔 <mat.l...@gmail.com>写道:
>

>> 受教了,才知道原来按v键可以调用这种功能啊,调试居然这么方便......

--

oni...@gmail.com

unread,
Feb 26, 2012, 8:53:47 PM2/26/12
to Lisp-cn(Lisp中文用户组)
Slime的快捷键文档里:
C-c C-c
M-x slime-compile-defun
Compile the top-level form at point. The region blinks
shortly to give some feedback which part was chosen.

With (positive) prefix argument the form is compiled with
maximal debug settings (C-u C-c C-c). With negative prefix argument it
is compiled for speed (M-- C-c C-c).

The code for the region is executed after compilation. In
principle, the command writes the region to a file, compiles that
file, and loads the resulting code.

看中间那行,可以使用prefix argument改变默认的编译策略。同理也可以应用在C-c M-k上。


On Feb 24, 11:40 am, bruce li <leilmy...@gmail.com> wrote:
> 弱弱的问一句,如何让sbcl默认以debug 3的方式启动?貌似要能够直接定位到代码,要在 .lisp文件头部加入(declaim
> ...)才可以,在repl里面直接出入这句话不起作用。。 但感觉每个文件头部加个这个还是很麻烦呢。。
>

> 在 2012年2月24日 上午10:34,刘滔 <mat.liu...@gmail.com>写道:
>
>
>
>
>
>
>
> > 受教了,才知道原来按v键可以调用这种功能啊,调试居然这么方便......


>
> > 在 2012年2月24日 上午12:25,Xiaofeng Yang <n.akr.aki...@gmail.com>写道:
>
> > 写错了,是(/ 1 n)
>
> >> Best regards,
> >> Xiaofeng Yang
>

> >> 在 2012年2月24日 上午12:19,Xiaofeng Yang <n.akr.aki...@gmail.com>写道:
>
> >> 我试了,在ACL IDE里面。
> >>> 8.1 -> 只能到(defun abc ...
> >>> 8.2 -> 能到出错的那一句(/ n 0)
>
> >>> 8.2在调试方面做了增强,看起来还是有变化的。
>
> >>> Best regards,
> >>> Xiaofeng Yang
>

> >>> 在 2012年2月23日 下午9:10,Jeova Sanctus Unus <jeova.sanctus.u...@gmail.com>写道:
>
> >>> 代码如下
> >>>> (declaim (optimize (debug 3)))
> >>>> (in-package :cl-user)
>
> >>>> (defun abc (n)
> >>>> (- 1 n)
> >>>> (/ 1 n)
> >>>> )
>
> >>>> 启动sbcl之后,切换到这个文件的buffer
> >>>> C-c C-k
> >>>> 然后,到repl,运行(abc 0)
> >>>> 出错,然后,在sldb里面移动到(abc 0),按v键,可以看到光标在出错的行上面。
> >>>> 但是,同样的操作,allegro只把光标显示在了(defun abc上面。
> >>>> 这样,如果是个比较长的程序,用sbcl的话,可以马上知道哪行出错了。allegro怎么办到呢?
>
> >>>> --
> >>>> Lisp-cn(Lisp中文用户组)
> >>>> CLUGhttp://lisp.org.cn
>
> >> --
> >> Lisp-cn(Lisp中文用户组)

> >> CLUGhttp://lisp.org.cn


>
> > --
> > Liutos Love Linux LaTeX Lisp Ling
>

> > 我的博客,纪念我死去的GAE <http://blog.sina.com.cn/u/2031941547>
>
> > --
> > Lisp-cn(Lisp中文用户组)
> > CLUGhttp://lisp.org.cn

Reply all
Reply to author
Forward
0 new messages