Stack backtrace for ARM/Thumb

Stern, Eli eli.stern@ti.com
Mon Jul 26 09:11:00 GMT 2010


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?

Thanx

Eli Stern



More information about the Gcc-help mailing list