Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [patches 2/2] struct switchframe/pcb improvements



On Thu, Jan 09, 2014 at 05:41:18PM -0500, Richard Hansen wrote:
> Hi all,
> 
> Here is the second round of patches.  (For context, see
> <http://mail-index.netbsd.org/port-i386/2014/01/09/msg003212.html>.)
> These patches should apply cleanly to NetBSD-current.
...
> I'd appreciate any feedback...

Alternate scheme for getting tracebacks that doesn't need a stack frame
for any function is to disassemble the code forwards tracking %sp and
%bp until you find a 'return' instruction.

You need to remember the un-processed conditional branch targets (with
sp/bp value) and the address ranges you've processed, so you can continue 
from a different label if you find a loop.

The only slight problems are if the crash in in a function that
doesn't return - when the stack correction code will be absent.

In general you only need to grok push; pop; sub %sp,n; mov %sp,%bp; jmp/br
and the 'return' instructions. You do need the size of everything else.

If the code can't find a way out, or the return address found is illegal,
search the stack for a likely address.

The code can probably be written almost architecture neutral.
It would also allow kernel code to be compiled without stack frames,
which is the ABI default for amd64.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index