GDBserver
/home/stan/gdb/src/gdb/gdbserver/linux-ia64-low.c
Go to the documentation of this file.
00001 /* GNU/Linux/IA64 specific low level interface, for the remote server for GDB.
00002    Copyright (C) 1995-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 #include "server.h"
00020 #include "linux-low.h"
00021 
00022 #ifdef HAVE_SYS_REG_H
00023 #include <sys/reg.h>
00024 #endif
00025 
00026 /* Defined in auto-generated file reg-ia64.c.  */
00027 void init_registers_ia64 (void);
00028 extern const struct target_desc *tdesc_ia64;
00029 
00030 #define ia64_num_regs 462
00031 
00032 #include <asm/ptrace_offsets.h>
00033 
00034 static int ia64_regmap[] =
00035   {
00036     /* general registers */
00037     -1,         /* gr0 not available; i.e, it's always zero */
00038     PT_R1,
00039     PT_R2,
00040     PT_R3,
00041     PT_R4,
00042     PT_R5,
00043     PT_R6,
00044     PT_R7,
00045     PT_R8,
00046     PT_R9,
00047     PT_R10,
00048     PT_R11,
00049     PT_R12,
00050     PT_R13,
00051     PT_R14,
00052     PT_R15,
00053     PT_R16,
00054     PT_R17,
00055     PT_R18,
00056     PT_R19,
00057     PT_R20,
00058     PT_R21,
00059     PT_R22,
00060     PT_R23,
00061     PT_R24,
00062     PT_R25,
00063     PT_R26,
00064     PT_R27,
00065     PT_R28,
00066     PT_R29,
00067     PT_R30,
00068     PT_R31,
00069     /* gr32 through gr127 not directly available via the ptrace interface */
00070     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00071     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00072     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00073     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00074     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00075     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00076     /* Floating point registers */
00077     -1, -1,     /* f0 and f1 not available (f0 is +0.0 and f1 is +1.0) */
00078     PT_F2,
00079     PT_F3,
00080     PT_F4,
00081     PT_F5,
00082     PT_F6,
00083     PT_F7,
00084     PT_F8,
00085     PT_F9,
00086     PT_F10,
00087     PT_F11,
00088     PT_F12,
00089     PT_F13,
00090     PT_F14,
00091     PT_F15,
00092     PT_F16,
00093     PT_F17,
00094     PT_F18,
00095     PT_F19,
00096     PT_F20,
00097     PT_F21,
00098     PT_F22,
00099     PT_F23,
00100     PT_F24,
00101     PT_F25,
00102     PT_F26,
00103     PT_F27,
00104     PT_F28,
00105     PT_F29,
00106     PT_F30,
00107     PT_F31,
00108     PT_F32,
00109     PT_F33,
00110     PT_F34,
00111     PT_F35,
00112     PT_F36,
00113     PT_F37,
00114     PT_F38,
00115     PT_F39,
00116     PT_F40,
00117     PT_F41,
00118     PT_F42,
00119     PT_F43,
00120     PT_F44,
00121     PT_F45,
00122     PT_F46,
00123     PT_F47,
00124     PT_F48,
00125     PT_F49,
00126     PT_F50,
00127     PT_F51,
00128     PT_F52,
00129     PT_F53,
00130     PT_F54,
00131     PT_F55,
00132     PT_F56,
00133     PT_F57,
00134     PT_F58,
00135     PT_F59,
00136     PT_F60,
00137     PT_F61,
00138     PT_F62,
00139     PT_F63,
00140     PT_F64,
00141     PT_F65,
00142     PT_F66,
00143     PT_F67,
00144     PT_F68,
00145     PT_F69,
00146     PT_F70,
00147     PT_F71,
00148     PT_F72,
00149     PT_F73,
00150     PT_F74,
00151     PT_F75,
00152     PT_F76,
00153     PT_F77,
00154     PT_F78,
00155     PT_F79,
00156     PT_F80,
00157     PT_F81,
00158     PT_F82,
00159     PT_F83,
00160     PT_F84,
00161     PT_F85,
00162     PT_F86,
00163     PT_F87,
00164     PT_F88,
00165     PT_F89,
00166     PT_F90,
00167     PT_F91,
00168     PT_F92,
00169     PT_F93,
00170     PT_F94,
00171     PT_F95,
00172     PT_F96,
00173     PT_F97,
00174     PT_F98,
00175     PT_F99,
00176     PT_F100,
00177     PT_F101,
00178     PT_F102,
00179     PT_F103,
00180     PT_F104,
00181     PT_F105,
00182     PT_F106,
00183     PT_F107,
00184     PT_F108,
00185     PT_F109,
00186     PT_F110,
00187     PT_F111,
00188     PT_F112,
00189     PT_F113,
00190     PT_F114,
00191     PT_F115,
00192     PT_F116,
00193     PT_F117,
00194     PT_F118,
00195     PT_F119,
00196     PT_F120,
00197     PT_F121,
00198     PT_F122,
00199     PT_F123,
00200     PT_F124,
00201     PT_F125,
00202     PT_F126,
00203     PT_F127,
00204     /* predicate registers - we don't fetch these individually */
00205     -1, -1, -1, -1, -1, -1, -1, -1,
00206     -1, -1, -1, -1, -1, -1, -1, -1,
00207     -1, -1, -1, -1, -1, -1, -1, -1,
00208     -1, -1, -1, -1, -1, -1, -1, -1,
00209     -1, -1, -1, -1, -1, -1, -1, -1,
00210     -1, -1, -1, -1, -1, -1, -1, -1,
00211     -1, -1, -1, -1, -1, -1, -1, -1,
00212     -1, -1, -1, -1, -1, -1, -1, -1,
00213     /* branch registers */
00214     PT_B0,
00215     PT_B1,
00216     PT_B2,
00217     PT_B3,
00218     PT_B4,
00219     PT_B5,
00220     PT_B6,
00221     PT_B7,
00222     /* virtual frame pointer and virtual return address pointer */
00223     -1, -1,
00224     /* other registers */
00225     PT_PR,
00226     PT_CR_IIP,  /* ip */
00227     PT_CR_IPSR, /* psr */
00228     PT_CFM,     /* cfm */
00229     /* kernel registers not visible via ptrace interface (?) */
00230     -1, -1, -1, -1, -1, -1, -1, -1,
00231     /* hole */
00232     -1, -1, -1, -1, -1, -1, -1, -1,
00233     PT_AR_RSC,
00234     PT_AR_BSP,
00235     PT_AR_BSPSTORE,
00236     PT_AR_RNAT,
00237     -1,
00238     -1,         /* Not available: FCR, IA32 floating control register */
00239     -1, -1,
00240     -1,         /* Not available: EFLAG */
00241     -1,         /* Not available: CSD */
00242     -1,         /* Not available: SSD */
00243     -1,         /* Not available: CFLG */
00244     -1,         /* Not available: FSR */
00245     -1,         /* Not available: FIR */
00246     -1,         /* Not available: FDR */
00247     -1,
00248     PT_AR_CCV,
00249     -1, -1, -1,
00250     PT_AR_UNAT,
00251     -1, -1, -1,
00252     PT_AR_FPSR,
00253     -1, -1, -1,
00254     -1,         /* Not available: ITC */
00255     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00256     -1, -1, -1, -1, -1, -1, -1, -1, -1,
00257     PT_AR_PFS,
00258     PT_AR_LC,
00259     PT_AR_EC,
00260     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00261     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00262     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00263     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00264     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00265     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
00266     -1,
00267   };
00268 
00269 static int
00270 ia64_cannot_store_register (int regno)
00271 {
00272   return 0;
00273 }
00274 
00275 static int
00276 ia64_cannot_fetch_register (int regno)
00277 {
00278   return 0;
00279 }
00280 
00281 /* GDB register numbers.  */
00282 #define IA64_GR0_REGNUM         0
00283 #define IA64_FR0_REGNUM         128
00284 #define IA64_FR1_REGNUM         129
00285 
00286 static int
00287 ia64_fetch_register (struct regcache *regcache, int regnum)
00288 {
00289   /* r0 cannot be fetched but is always zero.  */
00290   if (regnum == IA64_GR0_REGNUM)
00291     {
00292       const gdb_byte zero[8] = { 0 };
00293 
00294       gdb_assert (sizeof (zero) == register_size (regcache->tdesc, regnum));
00295       supply_register (regcache, regnum, zero);
00296       return 1;
00297     }
00298 
00299   /* fr0 cannot be fetched but is always zero.  */
00300   if (regnum == IA64_FR0_REGNUM)
00301     {
00302       const gdb_byte f_zero[16] = { 0 };
00303 
00304       gdb_assert (sizeof (f_zero) == register_size (regcache->tdesc, regnum));
00305       supply_register (regcache, regnum, f_zero);
00306       return 1;
00307     }
00308 
00309   /* fr1 cannot be fetched but is always one (1.0).  */
00310   if (regnum == IA64_FR1_REGNUM)
00311     {
00312       const gdb_byte f_one[16] =
00313         { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
00314 
00315       gdb_assert (sizeof (f_one) == register_size (regcache->tdesc, regnum));
00316       supply_register (regcache, regnum, f_one);
00317       return 1;
00318     }
00319 
00320   return 0;
00321 }
00322 
00323 static struct usrregs_info ia64_usrregs_info =
00324   {
00325     ia64_num_regs,
00326     ia64_regmap,
00327   };
00328 
00329 static struct regs_info regs_info =
00330   {
00331     NULL, /* regset_bitmap */
00332     &ia64_usrregs_info
00333   };
00334 
00335 static const struct regs_info *
00336 ia64_regs_info (void)
00337 {
00338   return &regs_info;
00339 }
00340 
00341 static void
00342 ia64_arch_setup (void)
00343 {
00344   current_process ()->tdesc = tdesc_ia64;
00345 }
00346 
00347 
00348 struct linux_target_ops the_low_target = {
00349   ia64_arch_setup,
00350   ia64_regs_info,
00351   ia64_cannot_fetch_register,
00352   ia64_cannot_store_register,
00353   ia64_fetch_register,
00354 };
00355 
00356 void
00357 initialize_low_arch (void)
00358 {
00359   init_registers_ia64 ();
00360 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines