1 /* $FreeBSD: ports/devel/gdb6/files/kvm-fbsd-i386.h,v 1.1 2004/06/20 22:22:02 obrien Exp $ */
2 /* $DragonFly: src/gnu/usr.bin/gdb/gdb/Attic/kvm-fbsd-i386.h,v 1.3 2005/01/12 11:24:24 joerg Exp $ */
4 /* Kernel core dump functions below target vector, for GDB on FreeBSD/i386.
5 Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995
6 Free Software Foundation, Inc.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include <machine/frame.h>
27 #include "i386-tdep.h"
30 ksym_maxuseraddr (void)
32 static CORE_ADDR maxuseraddr;
33 struct minimal_symbol *sym;
37 sym = lookup_minimal_symbol ("PTmap", NULL, NULL);
39 maxuseraddr = VM_MAXUSER_ADDRESS;
41 maxuseraddr = SYMBOL_VALUE_ADDRESS (sym);
48 /* Symbol names of kernel entry points. Use special frames. */
49 #define KSYM_TRAP "calltrap"
50 #define KSYM_INTR "Xintr"
51 #define KSYM_FASTINTR "Xfastintr"
52 #define KSYM_OLDSYSCALL "Xlcall_syscall"
53 #define KSYM_SYSCALL "Xint0x80_syscall"
55 /* The following is FreeBSD-specific hackery to decode special frames
56 and elide the assembly-language stub. This could be made faster by
57 defining a frame_type field in the machine-dependent frame information,
58 but we don't think that's too important right now. */
59 enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
62 fbsd_kern_frame_saved_pc (struct frame_info *fi)
64 struct minimal_symbol *sym;
65 CORE_ADDR this_saved_pc;
66 enum frametype frametype;
68 this_saved_pc = read_memory_integer (get_frame_base (fi) + 4, 4);
69 sym = lookup_minimal_symbol_by_pc (this_saved_pc);
70 frametype = tf_normal;
73 if (strcmp (DEPRECATED_SYMBOL_NAME (sym), KSYM_TRAP) == 0)
76 if (strncmp (DEPRECATED_SYMBOL_NAME (sym), KSYM_INTR,
77 strlen (KSYM_INTR)) == 0 || strncmp (DEPRECATED_SYMBOL_NAME(sym),
78 KSYM_FASTINTR, strlen (KSYM_FASTINTR)) == 0)
79 frametype = tf_interrupt;
81 if (strcmp (DEPRECATED_SYMBOL_NAME (sym), KSYM_SYSCALL) == 0 ||
82 strcmp (DEPRECATED_SYMBOL_NAME (sym), KSYM_OLDSYSCALL) == 0)
83 frametype = tf_syscall;
90 return (this_saved_pc);
91 #define oEIP offsetof (struct trapframe, tf_eip)
94 return (read_memory_integer (get_frame_base (fi) + 8 + oEIP, 4));
97 return (read_memory_integer (get_frame_base (fi) + 12 + oEIP, 4));
100 return (read_memory_integer (get_frame_base (fi) + 8 + oEIP, 4));
106 kgdb_fetch_registers (struct pcb *pcb)
111 /* Get the register values out of the sys pcb and store them where
112 `read_register' will find them. */
114 * XXX many registers aren't available.
115 * XXX for the non-core case, the registers are stale - they are for
116 * the last context switch to the debugger.
117 * XXX gcc's register numbers aren't all #defined in tm-i386.h.
120 for (i = 0; i < 3; ++i) /* eax,ecx,edx */
121 supply_register (i, (char *)&noreg);
123 /* DEO:XXX use SP_REGNUM and PC_REGNUM -- this is GDB_MULTI_ARCH */
124 supply_register (3, (char *) &pcb->pcb_ebx);
125 supply_register (SP_REGNUM, (char *) &pcb->pcb_esp);
126 supply_register (I386_EBP_REGNUM, (char *) &pcb->pcb_ebp);
127 supply_register (6, (char *) &pcb->pcb_esi);
128 supply_register (7, (char *) &pcb->pcb_edi);
129 supply_register (PC_REGNUM, (char *) &pcb->pcb_eip);
131 for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es, fs */
132 supply_register (i, (char *) &noreg);
133 supply_register (15, (char *) &pcb->pcb_gs);
135 /* XXX 80387 registers? */