David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 1 | /* a.out coredump register dumper |
| 2 | * |
| 3 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public Licence |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the Licence, or (at your option) any later version. |
| 10 | */ |
| 11 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 12 | #ifndef _ASM_X86_A_OUT_CORE_H |
| 13 | #define _ASM_X86_A_OUT_CORE_H |
David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 14 | |
| 15 | #ifdef __KERNEL__ |
| 16 | #ifdef CONFIG_X86_32 |
| 17 | |
| 18 | #include <linux/user.h> |
| 19 | #include <linux/elfcore.h> |
Frederic Weisbecker | 9f6b3c2 | 2009-11-09 21:03:43 +0100 | [diff] [blame] | 20 | #include <asm/debugreg.h> |
David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * fill in the user structure for an a.out core dump |
| 24 | */ |
| 25 | static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump) |
| 26 | { |
David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 27 | /* changed the size calculations - should hopefully work better. lbt */ |
| 28 | dump->magic = CMAGIC; |
| 29 | dump->start_code = 0; |
| 30 | dump->start_stack = regs->sp & ~(PAGE_SIZE - 1); |
Joe Perches | b03aa8c | 2008-03-23 01:01:38 -0700 | [diff] [blame] | 31 | dump->u_tsize = ((unsigned long)current->mm->end_code) >> PAGE_SHIFT; |
| 32 | dump->u_dsize = ((unsigned long)(current->mm->brk + (PAGE_SIZE - 1))) |
| 33 | >> PAGE_SHIFT; |
David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 34 | dump->u_dsize -= dump->u_tsize; |
| 35 | dump->u_ssize = 0; |
Frederic Weisbecker | 9f6b3c2 | 2009-11-09 21:03:43 +0100 | [diff] [blame] | 36 | aout_dump_debugregs(dump); |
David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 37 | |
| 38 | if (dump->start_stack < TASK_SIZE) |
Joe Perches | b03aa8c | 2008-03-23 01:01:38 -0700 | [diff] [blame] | 39 | dump->u_ssize = ((unsigned long)(TASK_SIZE - dump->start_stack)) |
| 40 | >> PAGE_SHIFT; |
David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 41 | |
| 42 | dump->regs.bx = regs->bx; |
| 43 | dump->regs.cx = regs->cx; |
| 44 | dump->regs.dx = regs->dx; |
| 45 | dump->regs.si = regs->si; |
| 46 | dump->regs.di = regs->di; |
| 47 | dump->regs.bp = regs->bp; |
| 48 | dump->regs.ax = regs->ax; |
| 49 | dump->regs.ds = (u16)regs->ds; |
| 50 | dump->regs.es = (u16)regs->es; |
| 51 | dump->regs.fs = (u16)regs->fs; |
Tejun Heo | d9a89a2 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 52 | dump->regs.gs = get_user_gs(regs); |
David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 53 | dump->regs.orig_ax = regs->orig_ax; |
| 54 | dump->regs.ip = regs->ip; |
| 55 | dump->regs.cs = (u16)regs->cs; |
| 56 | dump->regs.flags = regs->flags; |
| 57 | dump->regs.sp = regs->sp; |
| 58 | dump->regs.ss = (u16)regs->ss; |
| 59 | |
Joe Perches | b03aa8c | 2008-03-23 01:01:38 -0700 | [diff] [blame] | 60 | dump->u_fpvalid = dump_fpu(regs, &dump->i387); |
David Howells | 7fa3031 | 2008-02-08 04:19:28 -0800 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | #endif /* CONFIG_X86_32 */ |
| 64 | #endif /* __KERNEL__ */ |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 65 | #endif /* _ASM_X86_A_OUT_CORE_H */ |