Fixes to comments.
[AROS.git] / arch / i386-all / exec / alert_cpu.c
blobf57585a2f48d94f9a50b76381edacbe1ec4239ca
1 /*
2 Copyright © 2010-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CPU context parsing routines.
6 Lang: english
7 */
9 #include <exec/rawfmt.h>
10 #include <proto/exec.h>
12 #include <string.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 char *buf;
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);
39 return buf - 1;
42 /* Unwind a single stack frame. CPU-dependent. */
43 APTR UnwindFrame(APTR fp, APTR *caller)
45 APTR *ebp = fp;
47 *caller = ebp[1]; /* Fill in caller address */
48 return ebp[0]; /* Return pointer to the previous frame */