2 Copyright © 2011, The AROS Development Team. All rights reserved.
3 $Id: alert_cpu.c 36262 2010-12-27 12:17:48Z sonic $
5 Desc: CPU context parsing routines, x86-64 version.
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
= "RAX=%P RBX=%P RCX=%P RDX=%P\n"
18 "RSI=%P RDI=%P RSP=%P RBP=%P\n"
19 "R8 =%P R9 =%P R10=%P R11=%P\n"
20 "R12=%P R13=%P R14=%P R15=%P\n"
21 "RIP=%P RSP=%P RFLAGS=%P";
23 static const char *seg_fmt
= "\nCS=%04lx SS=%04lx DS=%04lx\n"
24 "ES=%04lx FS=%04lx GS=%04lx";
26 char *FormatCPUContext(char *buffer
, struct ExceptionContext
*ctx
, struct ExecBase
*SysBase
)
30 buf
= NewRawDoFmt(gpr_fmt
, RAWFMTFUNC_STRING
, buffer
,
31 ctx
->rax
, ctx
->rbx
, ctx
->rcx
, ctx
->rdx
,
32 ctx
->rsi
, ctx
->rdi
, ctx
->rsp
, ctx
->rbp
,
33 ctx
->r8
, ctx
->r9
, ctx
->r10
, ctx
->r11
,
34 ctx
->r12
, ctx
->r13
, ctx
->r14
, ctx
->r15
,
35 ctx
->rip
, ctx
->rsp
, ctx
->rflags
);
36 if (ctx
->Flags
& ECF_SEGMENTS
)
38 buf
= NewRawDoFmt(seg_fmt
, RAWFMTFUNC_STRING
, buf
- 1,
39 ctx
->cs
, ctx
->ss
, ctx
->ds
,
40 ctx
->es
, ctx
->fs
, ctx
->gs
);
47 * Unwind a single stack frame. CPU-dependent.
48 * Note that for this to work you need to supply -fno-omit-frame-pointer to gcc.
50 APTR
UnwindFrame(APTR fp
, APTR
*caller
)
54 *caller
= rbp
[1]; /* Fill in caller address */
55 return rbp
[0]; /* Return pointer to the previous frame */