[Ecls-list] Any way to get stack out of condition?

Peter Enerccio enerccio at gmail.com
Tue Feb 19 00:14:19 UTC 2013


I used this method:

(defun print-error-log (eout e)
  (format eout "Unhandled error detected: ~%")
  (format eout "~A~%" e)
  (when (c-code::error-data-p)
    (format eout "Additional error data: ~%~A~%" (c-code::get-error-data)))
  (format eout "Backtrace: ~%")
  (loop for x from (- (si::ihs-top) 2) downto 1
     do
       (format eout "~A~%" (si::ihs-fun x))
       (format eout " Args:~%")
       (let ((env (si::decode-ihs-env (si::ihs-env x))))
     (dolist (ip env)
       (format eout "      ~A= ~A~%" (car ip) (cdr ip))))
       (format eout "~%"))
  (format eout "~%")
  (format eout "C stack: ~%")
  (c-code::print-c-stack eout)
  (format eout "~%"))

which relies on two c side things, c-code::print-c-stack which is just
platform dependent method for printing c stack and
c-code::error-data-p / c-code::get-error-data, which is a c global value
accessor (reason why is isn't lisp global value is that
unfortunately, ecl handles this in separate thread/context, thus every
special variable is nil).

this method is then used in handler-bind:

(defun handle-any-error-log (e)
  (with-open-file (eout "errors.txt"
            :direction :output)
    (print-error-log eout e))
  (print-error-log *standard-output* e)
  (throw :end-execution-on-error :error-handled))

(eval-when (:load-toplevel :execute)
  (catch :end-execution-on-error
    (handler-bind
    ((error #'handle-any-error-log))
      (post-initialization))))



Output is pretty nice, imo:

Unhandled error detected:
Thats enough!
Backtrace:
#<bytecompiled-function UPDATE>
 Args:
      DELTA-TIME= 876
      SCENE= #<a DEFVN::TEST-SCENE>
      WINDOW= #<a CORE:WINDOW>

G26
 Args:
      CORE::W= #<a CORE:WINDOW>

#<bytecompiled-function MAIN>
 Args:
      WINDOW= #<a CORE:WINDOW>

#<bytecompiled-function BYTECODES>
 Args:

LOAD-INTERNAL
 Args:
      CORE::LOC-NAME= code/init.lisp
      CORE::GLO-NAME=
/media/home/home/enerccio/projects/gaia/gaia/pakdata/code/init.lisp
      CORE::LISP-FILE= init.lisp

POST-INITIALIZATION
 Args:


C stack:
/media/home/home/enerccio/projects/gaia/gaia/Debug/gaia(c_stack+0x62)
[0x4090f2]
/media/home/home/enerccio/projects/gaia/gaia/postinit.fas(+0x4f15)
[0x7fbec1145f15]
/media/home/home/enerccio/projects/gaia/gaia/postinit.fas(+0x4857)
[0x7fbec1145857]
/usr/lib/libecl.so.12.12(+0x12eb99) [0x7fbec5129b99]
/usr/lib/libecl.so.12.12(+0x12ed88) [0x7fbec5129d88]
/usr/lib/libecl.so.12.12(cl_funcall+0x78) [0x7fbec51649e8]
/usr/lib/libecl.so.12.12(cl_error+0xd6) [0x7fbec5185406]
/usr/lib/libecl.so.12.12(ecl_interpret+0x1cad) [0x7fbec51671bd]
/usr/lib/libecl.so.12.12(cl_apply+0x29b) [0x7fbec5164d2b]
/usr/lib/libecl.so.12.12(+0x111ae4) [0x7fbec510cae4]
/usr/lib/libecl.so.12.12(+0x117031) [0x7fbec5112031]
/usr/lib/libecl.so.12.12(_ecl_standard_dispatch+0x198) [0x7fbec516fed8]
/usr/lib/libecl.so.12.12(cl_funcall+0x78) [0x7fbec51649e8]
/media/home/home/enerccio/projects/gaia/gaia/Debug/gaia(render_once+0x128)
[0x408d8d]
/media/home/home/enerccio/projects/gaia/gaia/Debug/gaia(start_loop+0x33)
[0x408c02]
/media/home/home/enerccio/projects/gaia/gaia/Debug/gaia(cl_start_loop+0x25)
[0x408c43]
/media/home/home/enerccio/projects/gaia/gaia/postinit.fas(+0x3ad2)
[0x7fbec1144ad2]
/usr/lib/libecl.so.12.12(cl_apply+0x29b) [0x7fbec5164d2b]
/usr/lib/libecl.so.12.12(+0x111ae4) [0x7fbec510cae4]
/usr/lib/libecl.so.12.12(+0x117031) [0x7fbec5112031]
/usr/lib/libecl.so.12.12(_ecl_standard_dispatch+0x198) [0x7fbec516fed8]
/usr/lib/libecl.so.12.12(ecl_interpret+0x1f97) [0x7fbec51674a7]
/usr/lib/libecl.so.12.12(ecl_interpret+0x1ece) [0x7fbec51673de]
/usr/lib/libecl.so.12.12(+0x17118f) [0x7fbec516c18f]
/usr/lib/libecl.so.12.12(si_eval_with_env+0x2eb) [0x7fbec516dd3b]
/usr/lib/libecl.so.12.12(si_load_source+0x191) [0x7fbec51bce41]
/usr/lib/libecl.so.12.12(cl_funcall+0x78) [0x7fbec51649e8]
/usr/lib/libecl.so.12.12(cl_load+0x46d) [0x7fbec51bd6bd]
/media/home/home/enerccio/projects/gaia/gaia/postinit.fas(+0x5561)
[0x7fbec1146561]
/media/home/home/enerccio/projects/gaia/gaia/postinit.fas(+0x599e)
[0x7fbec114699e]
/media/home/home/enerccio/projects/gaia/gaia/postinit.fas(init_fas_CODE+0x2036)
[0x7fbec114e276]
/usr/lib/libecl.so.12.12(ecl_init_module+0x409) [0x7fbec5181bb9]
/usr/lib/libecl.so.12.12(si_load_binary+0x9a) [0x7fbec51bcb7a]
/usr/lib/libecl.so.12.12(cl_funcall+0x78) [0x7fbec51649e8]
/usr/lib/libecl.so.12.12(cl_load+0x46d) [0x7fbec51bd6bd]
/media/home/home/enerccio/projects/gaia/gaia/Debug/gaia(init_common_lisp_subsystem+0xf0)
[0x40907e]
/media/home/home/enerccio/projects/gaia/gaia/Debug/gaia(main+0x25)
[0x408e61]
/usr/lib/libc.so.6(__libc_start_main+0xf5) [0x7fbec3e5d725]
/media/home/home/enerccio/projects/gaia/gaia/Debug/gaia() [0x403ee9]

what I don't like is that I can't get fas compiled objects to show c debug
symbol names, no matter if I add -fdynamic or not, it will only show
init_fas_CODE symbol,
and nothing else. Oh well...


2013/2/19 Anton Vodonosov <avodonosov at yandex.ru>

> 03.02.2013, 05:34, "Peter Enerccio" <enerccio at gmail.com>:
> > I actually got it working, so it was most likely problem on my side.
> Thanks!
>
> Could you share your findings? What is the right reciepe for printing
> backtrace?
>



-- 
Bc. Peter Vaňušanik
http://www.bishojo.tk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20130219/7b8e75ea/attachment.html>


More information about the ecl-devel mailing list