Re-indent INIT_ARRAY.
[deliverable/binutils-gdb.git] / gdb / i386nbsd-nat.c
CommitLineData
9062529b
MK
1/* Native-dependent code for NetBSD/i386.
2
4c38e0a4
JB
3 Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
4 Free Software Foundation, Inc.
9062529b
MK
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
9062529b
MK
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
9062529b
MK
20
21#include "defs.h"
22#include "gdbcore.h"
23#include "regcache.h"
9692934b 24#include "target.h"
9062529b
MK
25
26#include "i386-tdep.h"
9692934b 27#include "i386bsd-nat.h"
9062529b
MK
28
29/* Support for debugging kernel virtual memory images. */
30
31#include <sys/types.h>
32#include <machine/frame.h>
33#include <machine/pcb.h>
34
84c5b489 35#include "nbsd-nat.h"
9062529b
MK
36#include "bsd-kvm.h"
37
38static int
39i386nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
40{
41 struct switchframe sf;
42
43 /* The following is true for NetBSD 1.6.2:
44
45 The pcb contains %esp and %ebp at the point of the context switch
46 in cpu_switch(). At that point we have a stack frame as
47 described by `struct switchframe', which for NetBSD 1.6.2 has the
48 following layout:
49
50 interrupt level
51 %edi
52 %esi
53 %ebx
54 %eip
55
56 we reconstruct the register state as it would look when we just
57 returned from cpu_switch(). */
58
59 /* The stack pointer shouldn't be zero. */
60 if (pcb->pcb_esp == 0)
61 return 0;
62
df80278b 63 read_memory (pcb->pcb_esp, (gdb_byte *)&sf, sizeof sf);
9062529b
MK
64 pcb->pcb_esp += sizeof (struct switchframe);
65 regcache_raw_supply (regcache, I386_EDI_REGNUM, &sf.sf_edi);
66 regcache_raw_supply (regcache, I386_ESI_REGNUM, &sf.sf_esi);
67 regcache_raw_supply (regcache, I386_EBP_REGNUM, &pcb->pcb_ebp);
68 regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_esp);
69 regcache_raw_supply (regcache, I386_EBX_REGNUM, &sf.sf_ebx);
70 regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
71
72 return 1;
73}
74\f
75
76/* Provide a prototype to silence -Wmissing-prototypes. */
77void _initialize_i386nbsd_nat (void);
78
79void
80_initialize_i386nbsd_nat (void)
81{
84c5b489 82 struct target_ops *t;
9692934b 83
84c5b489
MK
84 /* Add some extra features to the common *BSD/i386 target. */
85 t = i386bsd_target ();
86 t->to_pid_to_exec_file = nbsd_pid_to_exec_file;
87 add_target (t);
88
9062529b
MK
89 /* Support debugging kernel virtual memory images. */
90 bsd_kvm_add_target (i386nbsd_supply_pcb);
91}
This page took 0.421199 seconds and 4 git commands to generate.