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
)
28 buf
= NewRawDoFmt(gpr_fmt
, RAWFMTFUNC_STRING
, buffer
,
29 ctx
->eax
, ctx
->ebx
, ctx
->ecx
, ctx
->edx
,
30 ctx
->esi
, ctx
->edi
, ctx
->esp
, ctx
->ebp
,
31 ctx
->eip
, ctx
->esp
, ctx
->eflags
);
32 if (ctx
->Flags
& ECF_SEGMENTS
)
34 buf
= NewRawDoFmt(seg_fmt
, RAWFMTFUNC_STRING
, buf
- 1,
35 ctx
->cs
, ctx
->ss
, ctx
->ds
,
36 ctx
->es
, ctx
->fs
, ctx
->gs
);
42 /* Unwind a single stack frame. CPU-dependent. */
43 APTR
UnwindFrame(APTR fp
, APTR
*caller
)
47 *caller
= ebp
[1]; /* Fill in caller address */
48 return ebp
[0]; /* Return pointer to the previous frame */