[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improving representation of EIEIO objects in backtraces/error messag

From: Eric Abrahamsen
Subject: Re: Improving representation of EIEIO objects in backtraces/error messages
Date: Sat, 31 Dec 2016 12:48:45 -0800
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/26.0.50 (gnu/linux)

Eric Ludlam <address@hidden> writes:

> On 12/29/2016 02:02 PM, Eric Abrahamsen wrote:
>> I can't be the first one to be bitten by this...
>> When developing using EIEIO objects, backtraces and edebug messages
>> can be very difficult to use. In edebug, if you're lucky, you get the
>> #<object-class I'm an object> representation, but if you're unlucky,
>> you get the vector. In backtraces, you always get the vector.
>> For large objects, or those involving recursive data structures, this
>> makes error reporting frustrating, to put it delicately. It can take
>> the printer a good couple seconds to barf up the representation of an
>> object, and when it does it makes a huge mess of the minibuffer
>> and/or *Message* buffer.
> Hi Eric,
> CEDET includes a 'data-debug' package.  If you enable that it provides a
> way to navigate giant data structures as you might get with EIEIO.  It
> is also a part of Emacs now, though I'm not that familiar with how it
> all was merged.
> I have this in my .emacs file to take advantage of it:
> (require 'data-debug)
> (global-set-key "\M-:" 'data-debug-eval-expression)

That's interesting, thanks! I'll play with it a bit, it might be nice to
add the slot names in with the values.

> I also include this for eieio:
> (add-hook 'edebug-setup-hook
>         (lambda ()
>           (defalias 'edebug-prin1-to-string 'eieio-edebug-prin1-to-string)))
> though I'm not sure if something equivalent is enabled by default
> during the EIEIO merge.

We did end up enabling this by default, as an advice on
`edebug-prin1-to-string'. It's a great relief when it works, which it
only does sometimes (perhaps related to how deeply nested the objects
are in the data being printed? hard to tell).

> In the CEDET repository, you can get cedet-edebug.el.  It includes
> these two snippets that bind "A" to data debug.
> ;;;###autoload
> (add-hook 'edebug-setup-hook
>         (lambda ()
>           (require 'cedet-edebug)
>           ;; I suspect this isn't the best way to do this, but when
>           ;; cust-print was used on my system all my objects
>           ;; appeared as "#1 =" which was not useful.  This allows
>           ;; edebug to print my objects in the nice way they were
>           ;; meant to with `object-print' and `class-name'
>           (defalias 'edebug-prin1-to-string 'cedet-edebug-prin1-to-string)
>           ;; Add a fancy binding into EDEBUG's keymap for ADEBUG.
>           (define-key edebug-mode-map "A" 'data-debug-edebug-expr)
>           ))
> ;; This seems like as good a place as any to stick this hack.
> ;;;###autoload
> (add-hook 'debugger-mode-hook
>         (lambda ()
>           (require 'cedet-edebug)
>           ;; Add a fancy binding into the debug mode map for ADEBUG.
>           (define-key debugger-mode-map "A" 'data-debug-edebug-expr)
>           ))
> Eric

These are all good for me as a developer, but I would also like to
protect users from backtraces that might, ahem, arise from my code. Do
you have any opinion on the discussion in
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25295 ? Anything would be

Thanks for your message!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]