On 07/26/2010 09:04 AM, Stern, Eli wrote: > I am using uClibc (as opposed to glibc), so the backtrace() functions do not exist. > > I am trying to write a backtrace function, but cannot determine the stack frame for Thumb code, since it seems inconsistent. > > I have done several experiments: > 1. Compiled using "-mtpcs-frame -mtpcs-leaf-frame". This creates a consistent stack frame, but is very expensive. It adds approximately 15 Thumb instructions per function. > 2. Compiled using "-fno-omit-frame-pointer". There were 2 problems here. > 2.1 When returning from main(), I did not reach a NULL fp. > 2.2 The stack frame was different depending on the optimization. Tried without -O and with -O1. Got different structure of the stack frame. > > Is there a way to backtrace interworked ARM/Thumb code, without using tpcs? I'd have a look at using _Unwind_Backtrace, which is in libgcc. You'll have to compile with full unwinder data and link with --no-merge-exidx-entries. I think the unwinder should be able to cope with a mixture of Thumb and ARM frames. Andrew.