Page 1 of 1

CEGUI::Exception Stack Trace

Posted: Tue Nov 27, 2007 06:14
by tgraupmann
I'm looking at the CEGUI::Exception:

Code: Select all

class  CEGUIEXPORT Exception
      Construction and Destruction
   Exception(const String& message);
   virtual ~Exception(void);

      Return a reference to the String object describing the reason for the exception being thrown.

      String object containing a message describing the reason for the exception.
   const String&   getMessage(void) const      {return d_message;}

   String   d_message;

Why isn't there a way to get a stack trace? There isn't a place for function, file, or line number to be recorded. This would help with debugging...

Posted: Tue Nov 27, 2007 11:42
by scriptkid
If you are using the SVN version, then this might be what you are looking for:


Posted: Tue Nov 27, 2007 13:54
by fjeronimo
Hi tgraupmann,

The SVN CEGUI trunk version already has line and file exception info (link scriptkid supplied above).

I'm currently working on adding stack trace to the CELayoutEditor - initially on windows platforms and later on linux. Unfortunately, there isn't a "standard" way of achieving this goal on all platforms and it isn't as trivial as it might sound at first (lots of little nuances)...

Also, on windows, without using nasty hacks that aren't guaranteed to work on all cases, there isn't an easy way to obtain the stack trace at the exception level itself. The safest and most efficient method is by using VEH (Vectored Exception Handling). This difficults inserting the stack trace mechanism inside CEGUI itself (which is why it is being handled in the CELayoutEditor application, where it can manage not only CEGUI exceptions but all thrown exceptions including fatal win32 ones).

Afterwards, I can perhaps create a tutorial document explaining how to do this in any other application that uses CEGUI (although this is generic and can be used in many other situations).

On linux, the backtrace() and backtrace_symbols() functions (execinfo.h) greatly ease the process and allow you to obtain stack trace at the exception level (e.g. exception->printStackTrace()).

I hope this helps. :)

Posted: Tue Nov 27, 2007 23:56
by tgraupmann
This is a nice feature to have. I'll wait for the official release. When do you think the next version of CEGUI will be coming out? Are you going to finish the port for all platforms first?

Posted: Wed Nov 28, 2007 11:51
by fjeronimo
It's still a little too soon to talk about a release date, but work is being done in that direction. :)

I'll start by finishing the Windows stack trace (on CELayoutEditor, not on CEGUI for the reasons stated above) which will be included in the next CELayoutEditor SVN update and then add linux stack trace (probably at exception level in CEGUI itself).

Then, at a later stage, I'll check if it is possible and desirable to add windows stack trace inside CEGUI itself (I'm guessing this will be quite a thorn)...

In the meantime, if you use CEGUI SVN trunk you'll get file and line info, which will already help in the debug process. :)

Posted: Wed Nov 28, 2007 20:35
by tgraupmann
For now, I've increased the CEGUI log level which helps with debugging. I'm slowly upgrading my layout files from CEGUI 4 to 5.

Posted: Thu Dec 06, 2007 20:42
by fjeronimo
There's a new update to the CELayoutEditor SVN trunk that adds stack trace support.

Check it here :