1 /* Kernel core dump functions below target vector, for GDB on FreeBSD/i386.
2 Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 __FBSDID("$FreeBSD$");
24 #include <machine/frame.h>
27 ksym_maxuseraddr (void)
29 static CORE_ADDR maxuseraddr;
30 struct minimal_symbol *sym;
34 sym = lookup_minimal_symbol ("PTmap", NULL, NULL);
36 maxuseraddr = VM_MAXUSER_ADDRESS;
38 maxuseraddr = SYMBOL_VALUE_ADDRESS (sym);
45 /* Symbol names of kernel entry points. Use special frames. */
46 #define KSYM_TRAP "calltrap"
47 #define KSYM_INTR "Xintr"
48 #define KSYM_FASTINTR "Xfastintr"
49 #define KSYM_OLDSYSCALL "Xlcall_syscall"
50 #define KSYM_SYSCALL "Xint0x80_syscall"
52 /* The following is FreeBSD-specific hackery to decode special frames
53 and elide the assembly-language stub. This could be made faster by
54 defining a frame_type field in the machine-dependent frame information,
55 but we don't think that's too important right now. */
56 enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
59 fbsd_kern_frame_saved_pc (struct frame_info *fi)
61 struct minimal_symbol *sym;
62 CORE_ADDR this_saved_pc;
63 enum frametype frametype;
65 this_saved_pc = read_memory_integer (fi->frame + 4, 4);
66 sym = lookup_minimal_symbol_by_pc (this_saved_pc);
67 frametype = tf_normal;
70 if (strcmp (SYMBOL_NAME (sym), KSYM_TRAP) == 0)
73 if (strncmp (SYMBOL_NAME (sym), KSYM_INTR,
74 strlen (KSYM_INTR)) == 0 || strncmp (SYMBOL_NAME(sym),
75 KSYM_FASTINTR, strlen (KSYM_FASTINTR)) == 0)
76 frametype = tf_interrupt;
78 if (strcmp (SYMBOL_NAME (sym), KSYM_SYSCALL) == 0 ||
79 strcmp (SYMBOL_NAME (sym), KSYM_OLDSYSCALL) == 0)
80 frametype = tf_syscall;
86 return (this_saved_pc);
87 #define oEIP offsetof (struct trapframe, tf_eip)
90 return (read_memory_integer (fi->frame + 8 + oEIP, 4));
93 return (read_memory_integer (fi->frame + 12 + oEIP, 4));
96 return (read_memory_integer (fi->frame + 8 + oEIP, 4));
102 fetch_kcore_registers (struct pcb *pcb)
107 /* Get the register values out of the sys pcb and store them where
108 `read_register' will find them. */
110 * XXX many registers aren't available.
111 * XXX for the non-core case, the registers are stale - they are for
112 * the last context switch to the debugger.
113 * XXX gcc's register numbers aren't all #defined in tm-i386.h.
116 for (i = 0; i < 3; ++i) /* eax,ecx,edx */
117 supply_register (i, (char *)&noreg);
119 supply_register (3, (char *) &pcb->pcb_ebx);
120 supply_register (SP_REGNUM, (char *) &pcb->pcb_esp);
121 supply_register (FP_REGNUM, (char *) &pcb->pcb_ebp);
122 supply_register (6, (char *) &pcb->pcb_esi);
123 supply_register (7, (char *) &pcb->pcb_edi);
124 supply_register (PC_REGNUM, (char *) &pcb->pcb_eip);
126 for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es, fs */
127 supply_register (i, (char *) &noreg);
128 supply_register (15, (char *) &pcb->pcb_gs);
130 /* XXX 80387 registers? */