1 /*
2  * x86-specific gdb stub routines
3  * based on x86 cdb(xen/arch/x86/cdb.c), but Extensively modified.
4  *
5  * Copyright (C) 2006 Isaku Yamahata <yamahata at valinux co jp>
6  *                    VA Linux Systems Japan. K.K.
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
10  * the Free Software Foundation; either version 2 of the License, or
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
19  * along with this program; If not, see <http://www.gnu.org/licenses/>.
20  */
21 #include <asm/debugger.h>
22 
23 u16
gdb_arch_signal_num(struct cpu_user_regs * regs,unsigned long cookie)24 gdb_arch_signal_num(struct cpu_user_regs *regs, unsigned long cookie)
25 {
26     return 5;   /* TRAP signal.  see include/gdb/signals.h */
27 }
28 
29 /*
30  * Use __copy_*_user to make us page-fault safe, but not otherwise restrict
31  * our access to the full virtual address space.
32  */
33 unsigned int
gdb_arch_copy_from_user(void * dest,const void * src,unsigned len)34 gdb_arch_copy_from_user(void *dest, const void *src, unsigned len)
35 {
36     return __copy_from_user(dest, src, len);
37 }
38 
39 unsigned int
gdb_arch_copy_to_user(void * dest,const void * src,unsigned len)40 gdb_arch_copy_to_user(void *dest, const void *src, unsigned len)
41 {
42     return __copy_to_user(dest, src, len);
43 }
44 
45 void
gdb_arch_print_state(struct cpu_user_regs * regs)46 gdb_arch_print_state(struct cpu_user_regs *regs)
47 {
48     /* XXX */
49 }
50 
51 void
gdb_arch_enter(struct cpu_user_regs * regs)52 gdb_arch_enter(struct cpu_user_regs *regs)
53 {
54     /* nothing */
55 }
56 
57 void
gdb_arch_exit(struct cpu_user_regs * regs)58 gdb_arch_exit(struct cpu_user_regs *regs)
59 {
60     /* nothing */
61 }
62 
63 void
gdb_arch_resume(struct cpu_user_regs * regs,unsigned long addr,unsigned long type,struct gdb_context * ctx)64 gdb_arch_resume(struct cpu_user_regs *regs,
65                 unsigned long addr, unsigned long type,
66                 struct gdb_context *ctx)
67 {
68     if ( addr != -1UL )
69         regs->rip = addr;
70 
71     regs->eflags &= ~X86_EFLAGS_TF;
72 
73     /* Set eflags.RF to ensure we do not re-enter. */
74     regs->eflags |= X86_EFLAGS_RF;
75 
76     /* Set the trap flag if we are single stepping. */
77     if ( type == GDB_STEP )
78         regs->eflags |= X86_EFLAGS_TF;
79 }
80 
81 /*
82  * Local variables:
83  * mode: C
84  * c-file-style: "BSD"
85  * c-basic-offset: 4
86  * tab-width: 4
87  * End:
88  */
89