blob: 320c532bf09a2a4562ad6f98b0ea0c8b8bdea817 [file] [log] [blame]
tomf4c23102005-10-31 17:05:21 +00001
2/*--------------------------------------------------------------------*/
3/*--- Dumping core. coredump-x86-linux.c ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
10 Copyright (C) 2000-2005 Julian Seward
11 jseward@acm.org
12
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
31#include "pub_core_basics.h"
32#include "pub_core_libcbase.h"
33#include "pub_core_coredump.h"
34#include "pub_core_threadstate.h"
35
36#include "priv_elf.h"
37
38void ML_(fill_elfregs_from_tst)(struct vki_user_regs_struct* regs,
39 const ThreadArchState* arch)
40{
sewardjcf4ac712005-11-01 00:03:40 +000041 regs->eflags = LibVEX_GuestX86_get_eflags( &((ThreadArchState*)arch)->vex );
tomf4c23102005-10-31 17:05:21 +000042 regs->esp = arch->vex.guest_ESP;
43 regs->eip = arch->vex.guest_EIP;
44
45 regs->ebx = arch->vex.guest_EBX;
46 regs->ecx = arch->vex.guest_ECX;
47 regs->edx = arch->vex.guest_EDX;
48 regs->esi = arch->vex.guest_ESI;
49 regs->edi = arch->vex.guest_EDI;
50 regs->ebp = arch->vex.guest_EBP;
51 regs->eax = arch->vex.guest_EAX;
52
53 regs->cs = arch->vex.guest_CS;
54 regs->ds = arch->vex.guest_DS;
55 regs->ss = arch->vex.guest_SS;
56 regs->es = arch->vex.guest_ES;
57 regs->fs = arch->vex.guest_FS;
58 regs->gs = arch->vex.guest_GS;
59}
60
61//:: static void fill_fpu(vki_elf_fpregset_t *fpu, const Char *from)
62//:: {
63//:: if (VG_(have_ssestate)) {
64//:: UShort *to;
65//:: Int i;
66//::
67//:: /* This is what the kernel does */
68//:: VG_(memcpy)(fpu, from, 7*sizeof(long));
69//::
70//:: to = (UShort *)&fpu->st_space[0];
71//:: from += 18 * sizeof(UShort);
72//::
73//:: for (i = 0; i < 8; i++, to += 5, from += 8)
74//:: VG_(memcpy)(to, from, 5*sizeof(UShort));
75//:: } else
76//:: VG_(memcpy)(fpu, from, sizeof(*fpu));
77//:: }
78
79void ML_(fill_elffpregs_from_tst)(vki_elf_fpregset_t* fpu,
80 const ThreadArchState* arch)
81{
82//:: fill_fpu(fpu, (const Char *)&arch->m_sse);
83}
84
85void ML_(fill_elffpxregs_from_tst)(vki_elf_fpxregset_t* xfpu,
86 const ThreadArchState* arch)
87{
88//:: xfpu->cwd = ?;
89//:: xfpu->swd = ?;
90//:: xfpu->twd = ?;
91//:: xfpu->fop = ?;
92//:: xfpu->fip = ?;
93//:: xfpu->fcs = ?;
94//:: xfpu->foo = ?;
95//:: xfpu->fos = ?;
96//:: xfpu->mxcsr = ?;
97 xfpu->reserved = 0;
98//:: xfpu->st_space = ?;
99
100# define DO(n) VG_(memcpy)(xfpu->xmm_space + n * 4, &arch->vex.guest_XMM##n, sizeof(arch->vex.guest_XMM##n))
101 DO(0); DO(1); DO(2); DO(3); DO(4); DO(5); DO(6); DO(7);
102# undef DO
103
104 VG_(memset)(xfpu->padding, 0, sizeof(xfpu->padding));
105}
106
107void VG_(make_coredump)(ThreadId tid, const vki_siginfo_t *si, UInt max_size)
108{
109 ML_(make_elf_coredump)(tid, si, max_size);
110}