ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/pack/freebsd/devel/gdb6/files/kvm-fbsd-i386.h
Revision: 2
Committed: 2007-01-31T14:59:36-08:00 (18 years, 5 months ago) by douglas
Content type: text/x-c
Original Path: freebsd/gdb6/files/kvm-fbsd-i386.h
File size: 4527 byte(s)
Log Message:
This needs fixing...

File Contents

# User Rev Content
1 douglas 2 /* 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.
4    
5     This file is part of GDB.
6    
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.
11    
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.
16    
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.
20     */
21    
22     __FBSDID("$FreeBSD: ports/devel/gdb6/files/kvm-fbsd-i386.h,v 1.2 2004/08/23 06:34:48 obrien Exp $");
23    
24     #include <machine/frame.h>
25     #include "i386-tdep.h"
26    
27     static CORE_ADDR
28     ksym_maxuseraddr (void)
29     {
30     static CORE_ADDR maxuseraddr;
31     struct minimal_symbol *sym;
32    
33     if (maxuseraddr == 0)
34     {
35     sym = lookup_minimal_symbol ("PTmap", NULL, NULL);
36     if (sym == NULL) {
37     maxuseraddr = VM_MAXUSER_ADDRESS;
38     } else {
39     maxuseraddr = SYMBOL_VALUE_ADDRESS (sym);
40     }
41     }
42     return maxuseraddr;
43     }
44    
45    
46     /* Symbol names of kernel entry points. Use special frames. */
47     #define KSYM_TRAP "calltrap"
48     #define KSYM_INTR "Xintr"
49     #define KSYM_FASTINTR "Xfastintr"
50     #define KSYM_OLDSYSCALL "Xlcall_syscall"
51     #define KSYM_SYSCALL "Xint0x80_syscall"
52    
53     /* The following is FreeBSD-specific hackery to decode special frames
54     and elide the assembly-language stub. This could be made faster by
55     defining a frame_type field in the machine-dependent frame information,
56     but we don't think that's too important right now. */
57     enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
58    
59     #if __FreeBSD_version >= 500032
60     CORE_ADDR
61     fbsd_kern_frame_saved_pc (struct frame_info *fi)
62     {
63     struct minimal_symbol *sym;
64     CORE_ADDR this_saved_pc;
65     enum frametype frametype;
66    
67     this_saved_pc = read_memory_integer (get_frame_base (fi) + 4, 4);
68     sym = lookup_minimal_symbol_by_pc (this_saved_pc);
69     frametype = tf_normal;
70     if (sym != NULL)
71     {
72     if (strcmp (DEPRECATED_SYMBOL_NAME (sym), KSYM_TRAP) == 0)
73     frametype = tf_trap;
74     else
75     if (strncmp (DEPRECATED_SYMBOL_NAME (sym), KSYM_INTR,
76     strlen (KSYM_INTR)) == 0 || strncmp (DEPRECATED_SYMBOL_NAME(sym),
77     KSYM_FASTINTR, strlen (KSYM_FASTINTR)) == 0)
78     frametype = tf_interrupt;
79     else
80     if (strcmp (DEPRECATED_SYMBOL_NAME (sym), KSYM_SYSCALL) == 0 ||
81     strcmp (DEPRECATED_SYMBOL_NAME (sym), KSYM_OLDSYSCALL) == 0)
82     frametype = tf_syscall;
83     }
84    
85     switch (frametype)
86     {
87     default:
88     case tf_normal:
89     return (this_saved_pc);
90     #define oEIP offsetof (struct trapframe, tf_eip)
91    
92     case tf_trap:
93     return (read_memory_integer (get_frame_base (fi) + 8 + oEIP, 4));
94    
95     case tf_interrupt:
96     return (read_memory_integer (get_frame_base (fi) + 12 + oEIP, 4));
97    
98     case tf_syscall:
99     return (read_memory_integer (get_frame_base (fi) + 8 + oEIP, 4));
100     #undef oEIP
101     }
102     }
103     #endif
104    
105     static void
106     fetch_kcore_registers (struct pcb *pcb)
107     {
108     int i;
109     int noreg;
110    
111     /* Get the register values out of the sys pcb and store them where
112     `read_register' will find them. */
113     /*
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.
118     */
119     noreg = 0;
120     for (i = 0; i < 3; ++i) /* eax,ecx,edx */
121     regcache_raw_supply (current_regcache, i, (char *)&noreg);
122    
123     /* DEO:XXX use SP_REGNUM and PC_REGNUM -- this is GDB_MULTI_ARCH */
124     regcache_raw_supply (current_regcache, 3, (char *) &pcb->pcb_ebx);
125     regcache_raw_supply (current_regcache, SP_REGNUM, (char *) &pcb->pcb_esp);
126     regcache_raw_supply (current_regcache, I386_EBP_REGNUM, (char *) &pcb->pcb_ebp);
127     regcache_raw_supply (current_regcache, 6, (char *) &pcb->pcb_esi);
128     regcache_raw_supply (current_regcache, 7, (char *) &pcb->pcb_edi);
129     regcache_raw_supply (current_regcache, PC_REGNUM, (char *) &pcb->pcb_eip);
130    
131     for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es, fs */
132     regcache_raw_supply (current_regcache, i, (char *) &noreg);
133     regcache_raw_supply (current_regcache, 15, (char *) &pcb->pcb_gs);
134    
135     /* XXX 80387 registers? */
136     }