2 Copyright © 2010-2012, The AROS Development Team. All rights reserved.
5 Desc: CPU context parsing routines.
9 #include <exec/rawfmt.h>
10 #include <proto/exec.h>
14 #include "exec_intern.h"
15 #include "exec_util.h"
17 static const char *gpr_fmt
= "EAX=0x%08lx EBX=0x%08lx ECX=0x%08lx EDX=0x%08lx\n"
18 "ESI=0x%08lx EDI=0x%08lx ESP=0x%08lx EBP=0x%08lx\n"
19 "EIP=0x%08lx ESP=0x%08lx EFLAGS=0x%08lx";
21 static const char *seg_fmt
= "\nCS=%04lx SS=%04lx DS=%04lx\n"
22 "ES=%04lx FS=%04lx GS=%04lx";
24 char *FormatCPUContext(char *buffer
, struct ExceptionContext
*ctx
, struct ExecBase
*SysBase
)
26 VOID_FUNC dest
= buffer
? RAWFMTFUNC_STRING
: RAWFMTFUNC_SERIAL
;
29 buf
= NewRawDoFmt(gpr_fmt
, dest
, buffer
,
30 ctx
->eax
, ctx
->ebx
, ctx
->ecx
, ctx
->edx
,
31 ctx
->esi
, ctx
->edi
, ctx
->esp
, ctx
->ebp
,
32 ctx
->eip
, ctx
->esp
, ctx
->eflags
);
33 if (ctx
->Flags
& ECF_SEGMENTS
)
35 buf
= NewRawDoFmt(seg_fmt
, dest
, buf
- 1,
36 ctx
->cs
, ctx
->ss
, ctx
->ds
,
37 ctx
->es
, ctx
->fs
, ctx
->gs
);
43 /* Unwind a single stack frame. CPU-dependent. */
44 APTR
UnwindFrame(APTR fp
, APTR
*caller
)
48 *caller
= ebp
[1]; /* Fill in caller address */
49 return ebp
[0]; /* Return pointer to the previous frame */