This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Solution sought to GCC 4.1.1 backtrace problem


Backtracing through segfaults is hard.  The approach we use in
glibc/GNU/Linux is a function called *_fallback_frame_state, which
copies the saved registers on the stack into the unwinder data.
However, this only works if you're using DWARF-style unwinder data,
which is used in the EABI port of ARM.

If you're not using EABI, you really need to write your own version of
backtrace() that starts from a signal fram and unwinds through it.
The SIGCONTEXT ctx that's passed to your segfault handler contains the
registers at the point the segfault occurred, and you can unwind
starting from there.

Don't do this:

   void *fp = __builtin_frame_address (0);

Instead, pull fp and sp out of the SIGCONTEXT ctx.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]