How to generate meaningfull stacktraces with RTEMS on the Leon3

Chris Johns chrisj at rtems.org
Tue Dec 6 22:36:25 UTC 2016


On 06/12/2016 01:46, Jan Sommer wrote:
> Is there a common way how to create stacktraces in RTEMS?

Not that I know of.

> I tried to use the _Unwind_Backtrace_-function from gcc, but so far it
> only returns _URC_END_OF_STACK if I call it from a leaf function
> (haven't tried a trap handler yet).

The end of stack code means the unwinder could not find any data about 
the frames in the stack. The default DWARF unwinder, which SPARC uses, 
searches for a valid Frame Description Entry (FDE) and if not found 
reports the end of stack code. If an FDE is found the Common Information 
Entry (CIE) is extracted from that data and the frame info decoded.

C++ uses the same process for exceptions. A .eh_frame plus some other 
sections are created and the frames effected by the exceptions added to 
these sections. These sections are registered at start up. For a DWARF 
unwinder, which includes the SPARC, the DWARF standard is used for the 
format of these sections.

> I am not sure if that is the way to go.

I am not 100% sure myself. I think you would need to include some level 
of DWARF related information in the executable to do this. This 
information would need to be registered with the DWARF unwinder code via 
something like 'void __register_frame (void *begin)'.

I would also take a look at FreeBSD and see how they implement the 
unwinder. I do not know if the FreeBSD kernel has one.

> Are there any recommendations or examples for this topic?

The DWARF standard website is the best source of info:

http://dwarfstd.org/

Chris




More information about the users mailing list