OSDN Git Service

PR 11123
[pf3gnuchains/pf3gnuchains3x.git] / gdb / gdbserver / nto-x86-low.c
1 /* QNX Neutrino specific low level interface, for the remote server
2    for GDB.
3    Copyright (C) 2009, 2010 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 3 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, see <http://www.gnu.org/licenses/>.  */
19
20
21 #include "nto-low.h"
22 #include "regdef.h"
23 #include "regcache.h"
24
25 #include <x86/context.h>
26
27
28 /* Definition auto generated from reg-i386.dep.  */
29 extern void init_registers_i386 ();
30 extern struct reg *regs_i386;
31
32 const unsigned char x86_breakpoint[] = { 0xCC };
33 #define x86_breakpoint_len 1
34
35 /* Returns offset in appropriate Neutrino's context structure.
36    Defined in x86/context.h.
37    GDBREGNO is index into regs_i386 array.  It is autogenerated and
38    hopefully doesn't change.  */
39 static int
40 nto_x86_register_offset (int gdbregno)
41 {
42   if (gdbregno >= 0 && gdbregno < 16)
43     {
44       X86_CPU_REGISTERS *dummy = (void*)0;
45       /* GPRs  */
46       switch (gdbregno)
47         {
48         case 0: 
49           return (int)&(dummy->eax);
50         case 1:
51           return (int)&(dummy->ecx);
52         case 2:
53           return (int)&(dummy->edx);
54         case 3:
55           return (int)&(dummy->ebx);
56         case 4:
57           return (int)&(dummy->esp);
58         case 5:
59           return (int)&(dummy->ebp);
60         case 6:
61           return (int)&(dummy->esi);
62         case 7:
63           return (int)&(dummy->edi);
64         case 8:
65           return (int)&(dummy->eip);
66         case 9:
67           return (int)&(dummy->efl);
68         case 10:
69           return (int)&(dummy->cs);
70         case 11:
71           return (int)&(dummy->ss);
72 #ifdef __SEGMENTS__
73         case 12:
74           return (int)&(dummy->ds);
75         case 13:
76           return (int)&(dummy->es);
77         case 14:
78           return (int)&(dummy->fs);
79         case 15:
80           return (int)&(dummy->gs);
81 #endif
82         default:
83           return -1;
84         }
85     }
86   return -1;
87 }
88
89 static void
90 nto_x86_arch_setup (void)
91 {
92   init_registers_i386 ();
93   the_low_target.num_regs = 16;
94 }
95
96 struct nto_target_ops the_low_target =
97 {
98   nto_x86_arch_setup,
99   0, /* num_regs */
100   nto_x86_register_offset,
101   x86_breakpoint,
102   x86_breakpoint_len
103 };
104
105
106