Re: [rfc/rfa] Use ARM exception tables as GDB unwinder

Ulrich Weigand
2010-12-01T16:45:44Z

Dan Jacobowitz wrote:
> On Thu, Oct 21, 2010 at 10:29:32PM +0200, Ulrich Weigand wrote:
> > Right, for C code there should be no problem. The problems I've been
> > seeing all come from *assembler* source files using the DO_CALL macro.
> > This gets CFI correct, but doesn't create any unwind records ...
>
> Oh.... yes, we could move that out of line for ARM too. I don't like
> the solution much though, because it lengthens all syscall backtraces
> unnecessarily.
>
> We're getting into the point where backtraces using the ARM unwinder
> are not useful for GDB because they're flow-insensitive. But if all
> the callers of DO_CALL don't contain any other calls, we have the
> option to record the ip = r7 save as if the syscall is the only
> possible 'call site'.

Hmm, looking at DO_CALL a bit more I think this can actually be handled
inline just fine:

#define DO_CALL(syscall_name, args) \
DOARGS_##args; \
mov ip, r7; \
cfi_register (r7, ip); \
ldr r7, =SYS_ify (syscall_name); \
swi 0x0; \
mov r7, ip; \
cfi_restore (r7); \
UNDOARGS_##args

Note the calls to DOARGS_... / UNDOARGS_..., which actually save and
restore registers on the stack anyway (just not r7). Why not simply
have (a variant) of [UN]DOARGS_... save r7 to the stack, and then
provide both correct CFI and ARM unwind records for it? [ Saving
to IP would then be no longer necessary. ]

Am I missing something here?