Request: Getting the stack trace

Posted By: Talemon

Request: Getting the stack trace - 12/05/12 09:49

I would like a function that returns the stack trace to make debugging easier.
Posted By: WretchedSid

Re: Request: Getting the stack trace - 12/08/12 01:55

Not sure if Lite-C stores a stack frame, but if it does, you can grab the current one from the ebx register and then iterate over it. The layout of a stack frame looks like this:
Code:
struct stack_frame_s
{
	struct stack_frame_s *next;
	void *ret;
};



You can check if the stack frame is a aligned using this macro:
Code:
#define FramePointerIsAligned(a1) ((((uintptr_t)a1) & 0x1) == 0)



I'm afraid you have to get the ebx register using an external dll, however, if you are into dirty hacks, here are the required opcodes:
Code:
movl %eax, %ebx
ret

// ---

0x89 0xc3
0xc3



Symbolication can be done using engine_getscriptinfo()
Posted By: Talemon

Re: Request: Getting the stack trace - 12/10/12 08:24

Thanks JustSid, I guess I'll try to implement this.
© 2024 lite-C Forums