GDBserver
/home/stan/gdb/src/gdb/gdbserver/nto-x86-low.c
Go to the documentation of this file.
00001 /* QNX Neutrino specific low level interface, for the remote server
00002    for GDB.
00003    Copyright (C) 2009-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "server.h"
00021 #include "nto-low.h"
00022 #include "regdef.h"
00023 #include "regcache.h"
00024 
00025 #include <x86/context.h>
00026 
00027 
00028 /* Definition auto generated from reg-i386.dep.  */
00029 extern void init_registers_i386 ();
00030 extern struct reg *regs_i386;
00031 extern const struct target_desc *tdesc_i386;
00032 
00033 const unsigned char x86_breakpoint[] = { 0xCC };
00034 #define x86_breakpoint_len 1
00035 
00036 /* Returns offset in appropriate Neutrino's context structure.
00037    Defined in x86/context.h.
00038    GDBREGNO is index into regs_i386 array.  It is autogenerated and
00039    hopefully doesn't change.  */
00040 static int
00041 nto_x86_register_offset (int gdbregno)
00042 {
00043   if (gdbregno >= 0 && gdbregno < 16)
00044     {
00045       X86_CPU_REGISTERS *dummy = (void*)0;
00046       /* GPRs  */
00047       switch (gdbregno)
00048         {
00049         case 0: 
00050           return (int)&(dummy->eax);
00051         case 1:
00052           return (int)&(dummy->ecx);
00053         case 2:
00054           return (int)&(dummy->edx);
00055         case 3:
00056           return (int)&(dummy->ebx);
00057         case 4:
00058           return (int)&(dummy->esp);
00059         case 5:
00060           return (int)&(dummy->ebp);
00061         case 6:
00062           return (int)&(dummy->esi);
00063         case 7:
00064           return (int)&(dummy->edi);
00065         case 8:
00066           return (int)&(dummy->eip);
00067         case 9:
00068           return (int)&(dummy->efl);
00069         case 10:
00070           return (int)&(dummy->cs);
00071         case 11:
00072           return (int)&(dummy->ss);
00073 #ifdef __SEGMENTS__
00074         case 12:
00075           return (int)&(dummy->ds);
00076         case 13:
00077           return (int)&(dummy->es);
00078         case 14:
00079           return (int)&(dummy->fs);
00080         case 15:
00081           return (int)&(dummy->gs);
00082 #endif
00083         default:
00084           return -1;
00085         }
00086     }
00087   return -1;
00088 }
00089 
00090 static void
00091 nto_x86_arch_setup (void)
00092 {
00093   init_registers_i386 ();
00094   the_low_target.num_regs = 16;
00095   nto_tdesc = tdesc_i386;
00096 }
00097 
00098 struct nto_target_ops the_low_target =
00099 {
00100   nto_x86_arch_setup,
00101   0, /* num_regs */
00102   nto_x86_register_offset,
00103   x86_breakpoint,
00104   x86_breakpoint_len
00105 };
00106 
00107 
00108 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines